···259259Compiling the kernel260260--------------------261261262262- - Make sure you have at least gcc 4.9 available.262262+ - Make sure you have at least gcc 5.1 available.263263 For more information, refer to :ref:`Documentation/process/changes.rst <changes>`.264264265265 Please note that you can still run a.out user programs with this kernel.
···991010All DISP device tree nodes must be siblings to the central MMSYS_CONFIG node.1111For a description of the MMSYS_CONFIG binding, see1212-Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt.1212+Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml.13131414DISP function blocks1515====================
···11+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause22+%YAML 1.233+---44+$id: http://devicetree.org/schemas/ufs/samsung,exynos-ufs.yaml#55+$schema: http://devicetree.org/meta-schemas/core.yaml#66+77+title: Samsung SoC series UFS host controller Device Tree Bindings88+99+maintainers:1010+ - Alim Akhtar <alim.akhtar@samsung.com>1111+1212+description: |1313+ Each Samsung UFS host controller instance should have its own node.1414+ This binding define Samsung specific binding other then what is used1515+ in the common ufshcd bindings1616+ [1] Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt1717+1818+properties:1919+2020+ compatible:2121+ enum:2222+ - samsung,exynos7-ufs2323+2424+ reg:2525+ items:2626+ - description: HCI register2727+ - description: vendor specific register2828+ - description: unipro register2929+ - description: UFS protector register3030+3131+ reg-names:3232+ items:3333+ - const: hci3434+ - const: vs_hci3535+ - const: unipro3636+ - const: ufsp3737+3838+ clocks:3939+ items:4040+ - description: ufs link core clock4141+ - description: unipro main clock4242+4343+ clock-names:4444+ items:4545+ - const: core_clk4646+ - const: sclk_unipro_main4747+4848+ interrupts:4949+ maxItems: 15050+5151+ phys:5252+ maxItems: 15353+5454+ phy-names:5555+ const: ufs-phy5656+5757+required:5858+ - compatible5959+ - reg6060+ - interrupts6161+ - phys6262+ - phy-names6363+ - clocks6464+ - clock-names6565+6666+additionalProperties: false6767+6868+examples:6969+ - |7070+ #include <dt-bindings/interrupt-controller/arm-gic.h>7171+ #include <dt-bindings/clock/exynos7-clk.h>7272+7373+ ufs: ufs@15570000 {7474+ compatible = "samsung,exynos7-ufs";7575+ reg = <0x15570000 0x100>,7676+ <0x15570100 0x100>,7777+ <0x15571000 0x200>,7878+ <0x15572000 0x300>;7979+ reg-names = "hci", "vs_hci", "unipro", "ufsp";8080+ interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH>;8181+ clocks = <&clock_fsys1 ACLK_UFS20_LINK>,8282+ <&clock_fsys1 SCLK_UFSUNIPRO20_USER>;8383+ clock-names = "core_clk", "sclk_unipro_main";8484+ pinctrl-names = "default";8585+ pinctrl-0 = <&ufs_rst_n &ufs_refclk_out>;8686+ phys = <&ufs_phy>;8787+ phy-names = "ufs-phy";8888+ };8989+...
+1-1
Documentation/networking/dsa/sja1105.rst
···296296Device Tree bindings and board design297297=====================================298298299299-This section references ``Documentation/devicetree/bindings/net/dsa/sja1105.txt``299299+This section references ``Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml``300300and aims to showcase some potential switch caveats.301301302302RMII PHY role and out-of-band signaling
+1-1
Documentation/process/changes.rst
···2929====================== =============== ========================================3030 Program Minimal version Command to check the version3131====================== =============== ========================================3232-GNU C 4.9 gcc --version3232+GNU C 5.1 gcc --version3333Clang/LLVM (optional) 10.0.1 clang --version3434GNU make 3.81 make --version3535binutils 2.23 ld -v
···2020 select NEED_SG_DMA_LENGTH2121 select VIRT_TO_BUS2222 select GENERIC_IRQ_PROBE2323- select GENERIC_PCI_IOMAP if PCI2323+ select GENERIC_PCI_IOMAP2424 select AUTO_IRQ_AFFINITY if SMP2525 select GENERIC_IRQ_SHOW2626 select ARCH_WANT_IPC_PARSE_VERSION···199199200200config ALPHA_JENSEN201201 bool "Jensen"202202- depends on BROKEN203202 select HAVE_EISA204203 help205204 DEC PC 150 AXP (aka Jensen): This is a very old Digital system - one
+1
arch/alpha/include/asm/asm-prototypes.h
···1616extern void __remlu(void);1717extern void __divqu(void);1818extern void __remqu(void);1919+extern unsigned long __udiv_qrnnd(unsigned long *, unsigned long, unsigned long , unsigned long);
+3-3
arch/alpha/include/asm/io.h
···6060 * Change virtual addresses to physical addresses and vv.6161 */6262#ifdef USE_48_BIT_KSEG6363-static inline unsigned long virt_to_phys(void *address)6363+static inline unsigned long virt_to_phys(volatile void *address)6464{6565 return (unsigned long)address - IDENT_ADDR;6666}···7070 return (void *) (address + IDENT_ADDR);7171}7272#else7373-static inline unsigned long virt_to_phys(void *address)7373+static inline unsigned long virt_to_phys(volatile void *address)7474{7575 unsigned long phys = (unsigned long)address;7676···106106extern unsigned long __direct_map_base;107107extern unsigned long __direct_map_size;108108109109-static inline unsigned long __deprecated virt_to_bus(void *address)109109+static inline unsigned long __deprecated virt_to_bus(volatile void *address)110110{111111 unsigned long phys = virt_to_phys(address);112112 unsigned long bus = phys + __direct_map_base;
+4-4
arch/alpha/include/asm/jensen.h
···111111 * convinced that I need one of the newer machines.112112 */113113114114-static inline unsigned int jensen_local_inb(unsigned long addr)114114+__EXTERN_INLINE unsigned int jensen_local_inb(unsigned long addr)115115{116116 return 0xff & *(vuip)((addr << 9) + EISA_VL82C106);117117}118118119119-static inline void jensen_local_outb(u8 b, unsigned long addr)119119+__EXTERN_INLINE void jensen_local_outb(u8 b, unsigned long addr)120120{121121 *(vuip)((addr << 9) + EISA_VL82C106) = b;122122 mb();123123}124124125125-static inline unsigned int jensen_bus_inb(unsigned long addr)125125+__EXTERN_INLINE unsigned int jensen_bus_inb(unsigned long addr)126126{127127 long result;128128···131131 return __kernel_extbl(result, addr & 3);132132}133133134134-static inline void jensen_bus_outb(u8 b, unsigned long addr)134134+__EXTERN_INLINE void jensen_bus_outb(u8 b, unsigned long addr)135135{136136 jensen_set_hae(0);137137 *(vuip)((addr << 7) + EISA_IO + 0x00) = b * 0x01010101;
+43
arch/alpha/include/asm/setup.h
···11+/* SPDX-License-Identifier: GPL-2.0-only */22+#ifndef __ALPHA_SETUP_H33+#define __ALPHA_SETUP_H44+55+#include <uapi/asm/setup.h>66+77+/*88+ * We leave one page for the initial stack page, and one page for99+ * the initial process structure. Also, the console eats 3 MB for1010+ * the initial bootloader (one of which we can reclaim later).1111+ */1212+#define BOOT_PCB 0x200000001313+#define BOOT_ADDR 0x200000001414+/* Remove when official MILO sources have ELF support: */1515+#define BOOT_SIZE (16*1024)1616+1717+#ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS1818+#define KERNEL_START_PHYS 0x300000 /* Old bootloaders hardcoded this. */1919+#else2020+#define KERNEL_START_PHYS 0x1000000 /* required: Wildfire/Titan/Marvel */2121+#endif2222+2323+#define KERNEL_START (PAGE_OFFSET+KERNEL_START_PHYS)2424+#define SWAPPER_PGD KERNEL_START2525+#define INIT_STACK (PAGE_OFFSET+KERNEL_START_PHYS+0x02000)2626+#define EMPTY_PGT (PAGE_OFFSET+KERNEL_START_PHYS+0x04000)2727+#define EMPTY_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x08000)2828+#define ZERO_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x0A000)2929+3030+#define START_ADDR (PAGE_OFFSET+KERNEL_START_PHYS+0x10000)3131+3232+/*3333+ * This is setup by the secondary bootstrap loader. Because3434+ * the zero page is zeroed out as soon as the vm system is3535+ * initialized, we need to copy things out into a more permanent3636+ * place.3737+ */3838+#define PARAM ZERO_PGE3939+#define COMMAND_LINE ((char *)(absolute_pointer(PARAM + 0x0000)))4040+#define INITRD_START (*(unsigned long *) (PARAM+0x100))4141+#define INITRD_SIZE (*(unsigned long *) (PARAM+0x108))4242+4343+#endif
+3-39
arch/alpha/include/uapi/asm/setup.h
···11/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */22-#ifndef __ALPHA_SETUP_H33-#define __ALPHA_SETUP_H22+#ifndef _UAPI__ALPHA_SETUP_H33+#define _UAPI__ALPHA_SETUP_H4455#define COMMAND_LINE_SIZE 2566677-/*88- * We leave one page for the initial stack page, and one page for99- * the initial process structure. Also, the console eats 3 MB for1010- * the initial bootloader (one of which we can reclaim later).1111- */1212-#define BOOT_PCB 0x200000001313-#define BOOT_ADDR 0x200000001414-/* Remove when official MILO sources have ELF support: */1515-#define BOOT_SIZE (16*1024)1616-1717-#ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS1818-#define KERNEL_START_PHYS 0x300000 /* Old bootloaders hardcoded this. */1919-#else2020-#define KERNEL_START_PHYS 0x1000000 /* required: Wildfire/Titan/Marvel */2121-#endif2222-2323-#define KERNEL_START (PAGE_OFFSET+KERNEL_START_PHYS)2424-#define SWAPPER_PGD KERNEL_START2525-#define INIT_STACK (PAGE_OFFSET+KERNEL_START_PHYS+0x02000)2626-#define EMPTY_PGT (PAGE_OFFSET+KERNEL_START_PHYS+0x04000)2727-#define EMPTY_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x08000)2828-#define ZERO_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x0A000)2929-3030-#define START_ADDR (PAGE_OFFSET+KERNEL_START_PHYS+0x10000)3131-3232-/*3333- * This is setup by the secondary bootstrap loader. Because3434- * the zero page is zeroed out as soon as the vm system is3535- * initialized, we need to copy things out into a more permanent3636- * place.3737- */3838-#define PARAM ZERO_PGE3939-#define COMMAND_LINE ((char*)(PARAM + 0x0000))4040-#define INITRD_START (*(unsigned long *) (PARAM+0x100))4141-#define INITRD_SIZE (*(unsigned long *) (PARAM+0x108))4242-4343-#endif77+#endif /* _UAPI__ALPHA_SETUP_H */
···2525 # along with GCC; see the file COPYING. If not, write to the 2626 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,2727 # MA 02111-1307, USA.2828+#include <asm/export.h>28292930 .set noreorder3031 .set noat···162161 ret $31,($26),1163162164163 .end __udiv_qrnnd164164+EXPORT_SYMBOL(__udiv_qrnnd)
+1-1
arch/arm64/Kconfig
···8686 select ARCH_SUPPORTS_LTO_CLANG_THIN8787 select ARCH_SUPPORTS_CFI_CLANG8888 select ARCH_SUPPORTS_ATOMIC_RMW8989- select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && (GCC_VERSION >= 50000 || CC_IS_CLANG)8989+ select ARCH_SUPPORTS_INT128 if CC_HAS_INT1289090 select ARCH_SUPPORTS_NUMA_BALANCING9191 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT9292 select ARCH_WANT_DEFAULT_BPF_JIT
···171171172172int mvme147_hwclk(int op, struct rtc_time *t)173173{174174-#warning check me!175174 if (!op) {176175 m147_rtc->ctrl = RTC_READ;177176 t->tm_year = bcd2int (m147_rtc->bcd_year);···182183 m147_rtc->ctrl = 0;183184 if (t->tm_year < 70)184185 t->tm_year += 100;186186+ } else {187187+ /* FIXME Setting the time is not yet supported */188188+ return -EOPNOTSUPP;185189 }186190 return 0;187191}
+3-1
arch/m68k/mvme16x/config.c
···436436437437int mvme16x_hwclk(int op, struct rtc_time *t)438438{439439-#warning check me!440439 if (!op) {441440 rtc->ctrl = RTC_READ;442441 t->tm_year = bcd2int (rtc->bcd_year);···447448 rtc->ctrl = 0;448449 if (t->tm_year < 70)449450 t->tm_year += 100;451451+ } else {452452+ /* FIXME Setting the time is not yet supported */453453+ return -EOPNOTSUPP;450454 }451455 return 0;452456}
+1-1
arch/parisc/include/asm/page.h
···184184#include <asm-generic/getorder.h>185185#include <asm/pdc.h>186186187187-#define PAGE0 ((struct zeropage *)__PAGE_OFFSET)187187+#define PAGE0 ((struct zeropage *)absolute_pointer(__PAGE_OFFSET))188188189189/* DEFINITION OF THE ZERO-PAGE (PAG0) */190190/* based on work by Jason Eckhardt (jason@equator.com) */
···1818#include <asm/switch_to.h>1919#include <asm/syscall.h>2020#include <asm/time.h>2121+#include <asm/tm.h>2122#include <asm/unistd.h>22232324#if defined(CONFIG_PPC_ADV_DEBUG_REGS) && defined(CONFIG_PPC32)···136135 * returns to user with IRQS_ENABLED, this store could be avoided!137136 */138137 irq_soft_mask_regs_set_state(regs, IRQS_ENABLED);138138+139139+ /*140140+ * If system call is called with TM active, set _TIF_RESTOREALL to141141+ * prevent RFSCV being used to return to userspace, because POWER9142142+ * TM implementation has problems with this instruction returning to143143+ * transactional state. Final register values are not relevant because144144+ * the transaction will be aborted upon return anyway. Or in the case145145+ * of unsupported_scv SIGILL fault, the return state does not much146146+ * matter because it's an edge case.147147+ */148148+ if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&149149+ unlikely(MSR_TM_TRANSACTIONAL(regs->msr)))150150+ current_thread_info()->flags |= _TIF_RESTOREALL;151151+152152+ /*153153+ * If the system call was made with a transaction active, doom it and154154+ * return without performing the system call. Unless it was an155155+ * unsupported scv vector, in which case it's treated like an illegal156156+ * instruction.157157+ */158158+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM159159+ if (unlikely(MSR_TM_TRANSACTIONAL(regs->msr)) &&160160+ !trap_is_unsupported_scv(regs)) {161161+ /* Enable TM in the kernel, and disable EE (for scv) */162162+ hard_irq_disable();163163+ mtmsr(mfmsr() | MSR_TM);164164+165165+ /* tabort, this dooms the transaction, nothing else */166166+ asm volatile(".long 0x7c00071d | ((%0) << 16)"167167+ :: "r"(TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT));168168+169169+ /*170170+ * Userspace will never see the return value. Execution will171171+ * resume after the tbegin. of the aborted transaction with the172172+ * checkpointed register state. A context switch could occur173173+ * or signal delivered to the process before resuming the174174+ * doomed transaction context, but that should all be handled175175+ * as expected.176176+ */177177+ return -ENOSYS;178178+ }179179+#endif // CONFIG_PPC_TRANSACTIONAL_MEM139180140181 local_irq_enable();141182
-41
arch/powerpc/kernel/interrupt_64.S
···1212#include <asm/mmu.h>1313#include <asm/ppc_asm.h>1414#include <asm/ptrace.h>1515-#include <asm/tm.h>16151716 .section ".toc","aw"1817SYS_CALL_TABLE:···5455 .globl system_call_vectored_\name5556system_call_vectored_\name:5657_ASM_NOKPROBE_SYMBOL(system_call_vectored_\name)5757-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM5858-BEGIN_FTR_SECTION5959- extrdi. r10, r12, 1, (63-MSR_TS_T_LG) /* transaction active? */6060- bne tabort_syscall6161-END_FTR_SECTION_IFSET(CPU_FTR_TM)6262-#endif6358 SCV_INTERRUPT_TO_KERNEL6459 mr r10,r16560 ld r1,PACAKSAVE(r13)···240247 .globl system_call_common241248system_call_common:242249_ASM_NOKPROBE_SYMBOL(system_call_common)243243-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM244244-BEGIN_FTR_SECTION245245- extrdi. r10, r12, 1, (63-MSR_TS_T_LG) /* transaction active? */246246- bne tabort_syscall247247-END_FTR_SECTION_IFSET(CPU_FTR_TM)248248-#endif249250 mr r10,r1250251 ld r1,PACAKSAVE(r13)251252 std r10,0(r1)···410423411424SOFT_MASK_TABLE(.Lsyscall_rst_start, 1b)412425RESTART_TABLE(.Lsyscall_rst_start, .Lsyscall_rst_end, syscall_restart)413413-#endif414414-415415-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM416416-tabort_syscall:417417-_ASM_NOKPROBE_SYMBOL(tabort_syscall)418418- /* Firstly we need to enable TM in the kernel */419419- mfmsr r10420420- li r9, 1421421- rldimi r10, r9, MSR_TM_LG, 63-MSR_TM_LG422422- mtmsrd r10, 0423423-424424- /* tabort, this dooms the transaction, nothing else */425425- li r9, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT)426426- TABORT(R9)427427-428428- /*429429- * Return directly to userspace. We have corrupted user register state,430430- * but userspace will never see that register state. Execution will431431- * resume after the tbegin of the aborted transaction with the432432- * checkpointed register state.433433- */434434- li r9, MSR_RI435435- andc r10, r10, r9436436- mtmsrd r10, 1437437- mtspr SPRN_SRR0, r11438438- mtspr SPRN_SRR1, r12439439- RFI_TO_USER440440- b . /* prevent speculative execution */441426#endif442427443428 /*
+15-2
arch/powerpc/kernel/mce.c
···249249{250250 int index;251251 struct machine_check_event evt;252252+ unsigned long msr;252253253254 if (!get_mce_event(&evt, MCE_EVENT_RELEASE))254255 return;···263262 memcpy(&local_paca->mce_info->mce_event_queue[index],264263 &evt, sizeof(evt));265264266266- /* Queue irq work to process this event later. */267267- irq_work_queue(&mce_event_process_work);265265+ /*266266+ * Queue irq work to process this event later. Before267267+ * queuing the work enable translation for non radix LPAR,268268+ * as irq_work_queue may try to access memory outside RMO269269+ * region.270270+ */271271+ if (!radix_enabled() && firmware_has_feature(FW_FEATURE_LPAR)) {272272+ msr = mfmsr();273273+ mtmsr(msr | MSR_IR | MSR_DR);274274+ irq_work_queue(&mce_event_process_work);275275+ mtmsr(msr);276276+ } else {277277+ irq_work_queue(&mce_event_process_work);278278+ }268279}269280270281void mce_common_process_ue(struct pt_regs *regs,
+34-2
arch/powerpc/kvm/book3s_hv_rmhandlers.S
···25362536 /* The following code handles the fake_suspend = 1 case */25372537 mflr r025382538 std r0, PPC_LR_STKOFF(r1)25392539- stdu r1, -PPC_MIN_STKFRM(r1)25392539+ stdu r1, -TM_FRAME_SIZE(r1)2540254025412541 /* Turn on TM. */25422542 mfmsr r8···25512551END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG)25522552 nop2553255325542554+ /*25552555+ * It's possible that treclaim. may modify registers, if we have lost25562556+ * track of fake-suspend state in the guest due to it using rfscv.25572557+ * Save and restore registers in case this occurs.25582558+ */25592559+ mfspr r3, SPRN_DSCR25602560+ mfspr r4, SPRN_XER25612561+ mfspr r5, SPRN_AMR25622562+ /* SPRN_TAR would need to be saved here if the kernel ever used it */25632563+ mfcr r1225642564+ SAVE_NVGPRS(r1)25652565+ SAVE_GPR(2, r1)25662566+ SAVE_GPR(3, r1)25672567+ SAVE_GPR(4, r1)25682568+ SAVE_GPR(5, r1)25692569+ stw r12, 8(r1)25702570+ std r1, HSTATE_HOST_R1(r13)25712571+25542572 /* We have to treclaim here because that's the only way to do S->N */25552573 li r3, TM_CAUSE_KVM_RESCHED25562574 TRECLAIM(R3)25752575+25762576+ GET_PACA(r13)25772577+ ld r1, HSTATE_HOST_R1(r13)25782578+ REST_GPR(2, r1)25792579+ REST_GPR(3, r1)25802580+ REST_GPR(4, r1)25812581+ REST_GPR(5, r1)25822582+ lwz r12, 8(r1)25832583+ REST_NVGPRS(r1)25842584+ mtspr SPRN_DSCR, r325852585+ mtspr SPRN_XER, r425862586+ mtspr SPRN_AMR, r525872587+ mtcr r1225882588+ HMT_MEDIUM2557258925582590 /*25592591 * We were in fake suspend, so we are not going to save the···26142582 std r5, VCPU_TFHAR(r9)26152583 std r6, VCPU_TFIAR(r9)2616258426172617- addi r1, r1, PPC_MIN_STKFRM25852585+ addi r1, r1, TM_FRAME_SIZE26182586 ld r0, PPC_LR_STKOFF(r1)26192587 mtlr r026202588 blr
+2-2
arch/powerpc/sysdev/xics/xics-common.c
···348348 if (xics_ics->check(xics_ics, hwirq))349349 return -EINVAL;350350351351- /* No chip data for the XICS domain */351351+ /* Let the ICS be the chip data for the XICS domain. For ICS native */352352 irq_domain_set_info(domain, virq, hwirq, xics_ics->chip,353353- NULL, handle_fasteoi_irq, NULL, NULL);353353+ xics_ics, handle_fasteoi_irq, NULL, NULL);354354355355 return 0;356356}
+1-1
arch/riscv/Kconfig
···236236config ARCH_RV64I237237 bool "RV64I"238238 select 64BIT239239- select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000239239+ select ARCH_SUPPORTS_INT128 if CC_HAS_INT128240240 select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8)241241 select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE242242 select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
-10
arch/s390/Kconfig
···685685 The minimum size for the stack guard should be 256 for 31 bit and686686 512 for 64 bit.687687688688-config WARN_DYNAMIC_STACK689689- def_bool n690690- prompt "Emit compiler warnings for function with dynamic stack usage"691691- help692692- This option enables the compiler option -mwarn-dynamicstack. If the693693- compiler supports this options generates warnings for functions694694- that dynamically allocate stack space using alloca.695695-696696- Say N if you are unsure.697697-698688endmenu699689700690menu "I/O subsystem"
···1010CONFIG_BPF_JIT_ALWAYS_ON=y1111CONFIG_BPF_LSM=y1212CONFIG_PREEMPT=y1313+CONFIG_SCHED_CORE=y1314CONFIG_BSD_PROCESS_ACCT=y1415CONFIG_BSD_PROCESS_ACCT_V3=y1516CONFIG_TASKSTATS=y···504503# CONFIG_NET_VENDOR_HUAWEI is not set505504# CONFIG_NET_VENDOR_INTEL is not set506505# CONFIG_NET_VENDOR_MICROSOFT is not set506506+# CONFIG_NET_VENDOR_LITEX is not set507507# CONFIG_NET_VENDOR_MARVELL is not set508508CONFIG_MLX4_EN=m509509CONFIG_MLX5_CORE=m···663661CONFIG_NFSD_V4=y664662CONFIG_NFSD_V4_SECURITY_LABEL=y665663CONFIG_CIFS=m666666-CONFIG_CIFS_WEAK_PW_HASH=y667664CONFIG_CIFS_UPCALL=y668665CONFIG_CIFS_XATTR=y669666CONFIG_CIFS_POSIX=y···721720CONFIG_CRYPTO_VMAC=m722721CONFIG_CRYPTO_CRC32=m723722CONFIG_CRYPTO_BLAKE2S=m723723+CONFIG_CRYPTO_MD4=m724724+CONFIG_CRYPTO_MD5=y724725CONFIG_CRYPTO_MICHAEL_MIC=m725726CONFIG_CRYPTO_RMD160=m726727CONFIG_CRYPTO_SHA3=m···777774CONFIG_DMA_CMA=y778775CONFIG_CMA_SIZE_MBYTES=0779776CONFIG_DMA_API_DEBUG=y780780-CONFIG_STRING_SELFTEST=y781777CONFIG_PRINTK_TIME=y782778CONFIG_DYNAMIC_DEBUG=y783779CONFIG_DEBUG_INFO=y···855853CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y856854CONFIG_LKDTM=m857855CONFIG_TEST_MIN_HEAP=y858858-CONFIG_TEST_SORT=y859856CONFIG_KPROBES_SANITY_TEST=y860857CONFIG_RBTREE_TEST=y861858CONFIG_INTERVAL_TREE_TEST=m862859CONFIG_PERCPU_TEST=m863860CONFIG_ATOMIC64_SELFTEST=y861861+CONFIG_STRING_SELFTEST=y864862CONFIG_TEST_BITOPS=m865863CONFIG_TEST_BPF=m866864CONFIG_TEST_LIVEPATCH=m
+4-1
arch/s390/configs/defconfig
···88CONFIG_BPF_JIT=y99CONFIG_BPF_JIT_ALWAYS_ON=y1010CONFIG_BPF_LSM=y1111+CONFIG_SCHED_CORE=y1112CONFIG_BSD_PROCESS_ACCT=y1213CONFIG_BSD_PROCESS_ACCT_V3=y1314CONFIG_TASKSTATS=y···495494# CONFIG_NET_VENDOR_HUAWEI is not set496495# CONFIG_NET_VENDOR_INTEL is not set497496# CONFIG_NET_VENDOR_MICROSOFT is not set497497+# CONFIG_NET_VENDOR_LITEX is not set498498# CONFIG_NET_VENDOR_MARVELL is not set499499CONFIG_MLX4_EN=m500500CONFIG_MLX5_CORE=m···650648CONFIG_NFSD_V4=y651649CONFIG_NFSD_V4_SECURITY_LABEL=y652650CONFIG_CIFS=m653653-CONFIG_CIFS_WEAK_PW_HASH=y654651CONFIG_CIFS_UPCALL=y655652CONFIG_CIFS_XATTR=y656653CONFIG_CIFS_POSIX=y···709708CONFIG_CRYPTO_VMAC=m710709CONFIG_CRYPTO_CRC32=m711710CONFIG_CRYPTO_BLAKE2S=m711711+CONFIG_CRYPTO_MD4=m712712+CONFIG_CRYPTO_MD5=y712713CONFIG_CRYPTO_MICHAEL_MIC=m713714CONFIG_CRYPTO_RMD160=m714715CONFIG_CRYPTO_SHA3=m
+2-2
arch/s390/pci/pci_mmio.c
···159159160160 mmap_read_lock(current->mm);161161 ret = -EINVAL;162162- vma = find_vma(current->mm, mmio_addr);162162+ vma = vma_lookup(current->mm, mmio_addr);163163 if (!vma)164164 goto out_unlock_mmap;165165 if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))···298298299299 mmap_read_lock(current->mm);300300 ret = -EINVAL;301301- vma = find_vma(current->mm, mmio_addr);301301+ vma = vma_lookup(current->mm, mmio_addr);302302 if (!vma)303303 goto out_unlock_mmap;304304 if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
···1253125312541254static void kill_me_now(struct callback_head *ch)12551255{12561256+ struct task_struct *p = container_of(ch, struct task_struct, mce_kill_me);12571257+12581258+ p->mce_count = 0;12561259 force_sig(SIGBUS);12571260}12581261···12651262 int flags = MF_ACTION_REQUIRED;12661263 int ret;1267126412651265+ p->mce_count = 0;12681266 pr_err("Uncorrected hardware memory error in user-access at %llx", p->mce_addr);1269126712701268 if (!p->mce_ripv)···12941290 }12951291}1296129212971297-static void queue_task_work(struct mce *m, int kill_current_task)12931293+static void queue_task_work(struct mce *m, char *msg, int kill_current_task)12981294{12991299- current->mce_addr = m->addr;13001300- current->mce_kflags = m->kflags;13011301- current->mce_ripv = !!(m->mcgstatus & MCG_STATUS_RIPV);13021302- current->mce_whole_page = whole_page(m);12951295+ int count = ++current->mce_count;1303129613041304- if (kill_current_task)13051305- current->mce_kill_me.func = kill_me_now;13061306- else13071307- current->mce_kill_me.func = kill_me_maybe;12971297+ /* First call, save all the details */12981298+ if (count == 1) {12991299+ current->mce_addr = m->addr;13001300+ current->mce_kflags = m->kflags;13011301+ current->mce_ripv = !!(m->mcgstatus & MCG_STATUS_RIPV);13021302+ current->mce_whole_page = whole_page(m);13031303+13041304+ if (kill_current_task)13051305+ current->mce_kill_me.func = kill_me_now;13061306+ else13071307+ current->mce_kill_me.func = kill_me_maybe;13081308+ }13091309+13101310+ /* Ten is likely overkill. Don't expect more than two faults before task_work() */13111311+ if (count > 10)13121312+ mce_panic("Too many consecutive machine checks while accessing user data", m, msg);13131313+13141314+ /* Second or later call, make sure page address matches the one from first call */13151315+ if (count > 1 && (current->mce_addr >> PAGE_SHIFT) != (m->addr >> PAGE_SHIFT))13161316+ mce_panic("Consecutive machine checks to different user pages", m, msg);13171317+13181318+ /* Do not call task_work_add() more than once */13191319+ if (count > 1)13201320+ return;1308132113091322 task_work_add(current, ¤t->mce_kill_me, TWA_RESUME);13101323}···14591438 /* If this triggers there is no way to recover. Die hard. */14601439 BUG_ON(!on_thread_stack() || !user_mode(regs));1461144014621462- queue_task_work(&m, kill_current_task);14411441+ queue_task_work(&m, msg, kill_current_task);1463144214641443 } else {14651444 /*···14771456 }1478145714791458 if (m.kflags & MCE_IN_KERNEL_COPYIN)14801480- queue_task_work(&m, kill_current_task);14591459+ queue_task_work(&m, msg, kill_current_task);14811460 }14821461out:14831462 mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);
+1-1
arch/x86/kernel/setup_percpu.c
···135135136136static void __init pcpu_fc_free(void *ptr, size_t size)137137{138138- memblock_free(__pa(ptr), size);138138+ memblock_free_ptr(ptr, size);139139}140140141141static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
···4949 p = early_alloc(PMD_SIZE, nid, false);5050 if (p && pmd_set_huge(pmd, __pa(p), PAGE_KERNEL))5151 return;5252- else if (p)5353- memblock_free(__pa(p), PMD_SIZE);5252+ memblock_free_ptr(p, PMD_SIZE);5453 }55545655 p = early_alloc(PAGE_SIZE, nid, true);···8586 p = early_alloc(PUD_SIZE, nid, false);8687 if (p && pud_set_huge(pud, __pa(p), PAGE_KERNEL))8788 return;8888- else if (p)8989- memblock_free(__pa(p), PUD_SIZE);8989+ memblock_free_ptr(p, PUD_SIZE);9090 }91919292 p = early_alloc(PAGE_SIZE, nid, true);
+1-1
arch/x86/mm/numa.c
···355355356356 /* numa_distance could be 1LU marking allocation failure, test cnt */357357 if (numa_distance_cnt)358358- memblock_free(__pa(numa_distance), size);358358+ memblock_free_ptr(numa_distance, size);359359 numa_distance_cnt = 0;360360 numa_distance = NULL; /* enable table creation */361361}
+1-2
arch/x86/mm/numa_emulation.c
···517517 }518518519519 /* free the copied physical distance table */520520- if (phys_dist)521521- memblock_free(__pa(phys_dist), phys_size);520520+ memblock_free_ptr(phys_dist, phys_size);522521 return;523522524523no_emu:
+6-1
arch/x86/mm/pat/memtype.c
···583583 int err = 0;584584585585 start = sanitize_phys(start);586586- end = sanitize_phys(end);586586+587587+ /*588588+ * The end address passed into this function is exclusive, but589589+ * sanitize_phys() expects an inclusive address.590590+ */591591+ end = sanitize_phys(end - 1) + 1;587592 if (start >= end) {588593 WARN(1, "%s failed: [mem %#010Lx-%#010Lx], req %s\n", __func__,589594 start, end - 1, cattr_name(req_type));
+7
arch/x86/xen/enlighten_pv.c
···12141214 x86_platform.legacy.rtc = 1;12151215}1216121612171217+static void __init xen_domu_set_legacy_features(void)12181218+{12191219+ x86_platform.legacy.rtc = 0;12201220+}12211221+12171222/* First C function to be called on Xen boot */12181223asmlinkage __visible void __init xen_start_kernel(void)12191224{···13641359 add_preferred_console("xenboot", 0, NULL);13651360 if (pci_xen)13661361 x86_init.pci.arch_init = pci_xen_init;13621362+ x86_platform.set_legacy_features =13631363+ xen_domu_set_legacy_features;13671364 } else {13681365 const struct dom0_vga_console_info *info =13691366 (void *)((char *)xen_start_info +
+5-2
arch/x86/xen/mmu_pv.c
···15181518 if (pinned) {15191519 struct page *page = pfn_to_page(pfn);1520152015211521- if (static_branch_likely(&xen_struct_pages_ready))15211521+ pinned = false;15221522+ if (static_branch_likely(&xen_struct_pages_ready)) {15231523+ pinned = PagePinned(page);15221524 SetPagePinned(page);15251525+ }1523152615241527 xen_mc_batch();1525152815261529 __set_pfn_prot(pfn, PAGE_KERNEL_RO);1527153015281528- if (level == PT_PTE && USE_SPLIT_PTE_PTLOCKS)15311531+ if (level == PT_PTE && USE_SPLIT_PTE_PTLOCKS && !pinned)15291532 __pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn);1530153315311534 xen_mc_issue(PARAVIRT_LAZY_MMU);
+14-4
block/blk-cgroup.c
···11821182 if (preloaded)11831183 radix_tree_preload_end();1184118411851185- ret = blk_iolatency_init(q);11861186- if (ret)11871187- goto err_destroy_all;11881188-11891185 ret = blk_ioprio_init(q);11901186 if (ret)11911187 goto err_destroy_all;···11891193 ret = blk_throtl_init(q);11901194 if (ret)11911195 goto err_destroy_all;11961196+11971197+ ret = blk_iolatency_init(q);11981198+ if (ret) {11991199+ blk_throtl_exit(q);12001200+ goto err_destroy_all;12011201+ }1192120211931203 return 0;11941204···13661364 /* alloc failed, nothing's initialized yet, free everything */13671365 spin_lock_irq(&q->queue_lock);13681366 list_for_each_entry(blkg, &q->blkg_list, q_node) {13671367+ struct blkcg *blkcg = blkg->blkcg;13681368+13691369+ spin_lock(&blkcg->lock);13691370 if (blkg->pd[pol->plid]) {13701371 pol->pd_free_fn(blkg->pd[pol->plid]);13711372 blkg->pd[pol->plid] = NULL;13721373 }13741374+ spin_unlock(&blkcg->lock);13731375 }13741376 spin_unlock_irq(&q->queue_lock);13751377 ret = -ENOMEM;···14051399 __clear_bit(pol->plid, q->blkcg_pols);1406140014071401 list_for_each_entry(blkg, &q->blkg_list, q_node) {14021402+ struct blkcg *blkcg = blkg->blkcg;14031403+14041404+ spin_lock(&blkcg->lock);14081405 if (blkg->pd[pol->plid]) {14091406 if (pol->pd_offline_fn)14101407 pol->pd_offline_fn(blkg->pd[pol->plid]);14111408 pol->pd_free_fn(blkg->pd[pol->plid]);14121409 blkg->pd[pol->plid] = NULL;14131410 }14111411+ spin_unlock(&blkcg->lock);14141412 }1415141314161414 spin_unlock_irq(&q->queue_lock);
+8-1
block/blk-integrity.c
···426426 */427427void blk_integrity_unregister(struct gendisk *disk)428428{429429+ struct blk_integrity *bi = &disk->queue->integrity;430430+431431+ if (!bi->profile)432432+ return;433433+434434+ /* ensure all bios are off the integrity workqueue */435435+ blk_flush_integrity();429436 blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue);430430- memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity));437437+ memset(bi, 0, sizeof(*bi));431438}432439EXPORT_SYMBOL(blk_integrity_unregister);433440
···1313#include <linux/export.h>1414#include <linux/rtc.h>1515#include <linux/suspend.h>1616+#include <linux/init.h>16171718#include <linux/mc146818rtc.h>1819···166165 const char *file = *(const char **)(tracedata + 2);167166 unsigned int user_hash_value, file_hash_value;168167168168+ if (!x86_platform.legacy.rtc)169169+ return;170170+169171 user_hash_value = user % USERHASH;170172 file_hash_value = hash_string(lineno, file, FILEHASH);171173 set_magic_time(user_hash_value, file_hash_value, dev_hash_value);···271267272268static int __init early_resume_init(void)273269{270270+ if (!x86_platform.legacy.rtc)271271+ return 0;272272+274273 hash_value_early_read = read_magic_time();275274 register_pm_notifier(&pm_trace_nb);276275 return 0;···283276{284277 unsigned int val = hash_value_early_read;285278 unsigned int user, file, dev;279279+280280+ if (!x86_platform.legacy.rtc)281281+ return 0;286282287283 user = val % USERHASH;288284 val = val / USERHASH;
+1-1
drivers/cpufreq/cpufreq_governor_attr_set.c
···7474 if (count)7575 return count;76767777- kobject_put(&attr_set->kobj);7877 mutex_destroy(&attr_set->update_lock);7878+ kobject_put(&attr_set->kobj);7979 return 0;8080}8181EXPORT_SYMBOL_GPL(gov_attr_set_put);
+14-8
drivers/cpufreq/intel_pstate.c
···32053205 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)32063206 return -ENODEV;3207320732083208- if (no_load)32093209- return -ENODEV;32103210-32113208 id = x86_match_cpu(hwp_support_ids);32123209 if (id) {32103210+ bool hwp_forced = intel_pstate_hwp_is_enabled();32113211+32123212+ if (hwp_forced)32133213+ pr_info("HWP enabled by BIOS\n");32143214+ else if (no_load)32153215+ return -ENODEV;32163216+32133217 copy_cpu_funcs(&core_funcs);32143218 /*32153219 * Avoid enabling HWP for processors without EPP support,···32233219 * If HWP is enabled already, though, there is no choice but to32243220 * deal with it.32253221 */32263226- if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||32273227- intel_pstate_hwp_is_enabled()) {32223222+ if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {32283223 hwp_active++;32293224 hwp_mode_bdw = id->driver_data;32303225 intel_pstate.attr = hwp_cpufreq_attrs;···3238323532393236 goto hwp_cpu_matched;32403237 }32383238+ pr_info("HWP not enabled\n");32413239 } else {32403240+ if (no_load)32413241+ return -ENODEV;32423242+32423243 id = x86_match_cpu(intel_pstate_cpu_ids);32433244 if (!id) {32443245 pr_info("CPU model not supported\n");···33213314 else if (!strcmp(str, "passive"))33223315 default_driver = &intel_cpufreq;3323331633243324- if (!strcmp(str, "no_hwp")) {33253325- pr_info("HWP disabled\n");33173317+ if (!strcmp(str, "no_hwp"))33263318 no_hwp = 1;33273327- }33193319+33283320 if (!strcmp(str, "force"))33293321 force_load = 1;33303322 if (!strcmp(str, "hwp_only"))
-1
drivers/cpufreq/vexpress-spc-cpufreq.c
···451451static int ve_spc_cpufreq_exit(struct cpufreq_policy *policy)452452{453453 struct device *cpu_dev;454454- int cur_cluster = cpu_to_cluster(policy->cpu);455454456455 cpu_dev = get_cpu_device(policy->cpu);457456 if (!cpu_dev) {
···192192 kgd2kfd_suspend(adev->kfd.dev, run_pm);193193}194194195195+int amdgpu_amdkfd_resume_iommu(struct amdgpu_device *adev)196196+{197197+ int r = 0;198198+199199+ if (adev->kfd.dev)200200+ r = kgd2kfd_resume_iommu(adev->kfd.dev);201201+202202+ return r;203203+}204204+195205int amdgpu_amdkfd_resume(struct amdgpu_device *adev, bool run_pm)196206{197207 int r = 0;
···15441544 struct dentry *ent;15451545 int r, i;1546154615471547-15481548-15491547 ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,15501548 &fops_ib_preempt);15511551- if (!ent) {15491549+ if (IS_ERR(ent)) {15521550 DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");15531553- return -EIO;15511551+ return PTR_ERR(ent);15541552 }1555155315561554 ent = debugfs_create_file("amdgpu_force_sclk", 0200, root, adev,15571555 &fops_sclk_set);15581558- if (!ent) {15561556+ if (IS_ERR(ent)) {15591557 DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");15601560- return -EIO;15581558+ return PTR_ERR(ent);15611559 }1562156015631561 /* Register debugfs entries for amdgpu_ttm */
+12
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
···23942394 if (r)23952395 goto init_failed;2396239623972397+ r = amdgpu_amdkfd_resume_iommu(adev);23982398+ if (r)23992399+ goto init_failed;24002400+23972401 r = amdgpu_device_ip_hw_init_phase1(adev);23982402 if (r)23992403 goto init_failed;···31513147static int amdgpu_device_ip_resume(struct amdgpu_device *adev)31523148{31533149 int r;31503150+31513151+ r = amdgpu_amdkfd_resume_iommu(adev);31523152+ if (r)31533153+ return r;3154315431553155 r = amdgpu_device_ip_resume_phase1(adev);31563156 if (r)···46094601 dev_warn(tmp_adev->dev, "asic atom init failed!");46104602 } else {46114603 dev_info(tmp_adev->dev, "GPU reset succeeded, trying to resume\n");46044604+ r = amdgpu_amdkfd_resume_iommu(tmp_adev);46054605+ if (r)46064606+ goto out;46074607+46124608 r = amdgpu_device_ip_resume_phase1(tmp_adev);46134609 if (r)46144610 goto out;
+1-1
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
···598598 break;599599 default:600600 adev->gmc.tmz_enabled = false;601601- dev_warn(adev->dev,601601+ dev_info(adev->dev,602602 "Trusted Memory Zone (TMZ) feature not supported\n");603603 break;604604 }
···428428 ent = debugfs_create_file(name,429429 S_IFREG | S_IRUGO, root,430430 ring, &amdgpu_debugfs_ring_fops);431431- if (!ent)432432- return -ENOMEM;431431+ if (IS_ERR(ent))432432+ return PTR_ERR(ent);433433434434 i_size_write(ent->d_inode, ring->ring_size + 12);435435 ring->ent = ent;
+9-9
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
···515515 goto out;516516 }517517518518+ if (bo->type == ttm_bo_type_device &&519519+ new_mem->mem_type == TTM_PL_VRAM &&520520+ old_mem->mem_type != TTM_PL_VRAM) {521521+ /* amdgpu_bo_fault_reserve_notify will re-set this if the CPU522522+ * accesses the BO after it's moved.523523+ */524524+ abo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;525525+ }526526+518527 if (adev->mman.buffer_funcs_enabled) {519528 if (((old_mem->mem_type == TTM_PL_SYSTEM &&520529 new_mem->mem_type == TTM_PL_VRAM) ||···552543 r = ttm_bo_move_memcpy(bo, ctx, new_mem);553544 if (r)554545 return r;555555- }556556-557557- if (bo->type == ttm_bo_type_device &&558558- new_mem->mem_type == TTM_PL_VRAM &&559559- old_mem->mem_type != TTM_PL_VRAM) {560560- /* amdgpu_bo_fault_reserve_notify will re-set this if the CPU561561- * accesses the BO after it's moved.562562- */563563- abo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;564546 }565547566548out:
···11-/* Copyright 2015 Advanced Micro Devices, Inc. */11+/*22+ * Copyright 2015 Advanced Micro Devices, Inc.33+ *44+ * Permission is hereby granted, free of charge, to any person obtaining a55+ * copy of this software and associated documentation files (the "Software"),66+ * to deal in the Software without restriction, including without limitation77+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,88+ * and/or sell copies of the Software, and to permit persons to whom the99+ * Software is furnished to do so, subject to the following conditions:1010+ *1111+ * The above copyright notice and this permission notice shall be included in1212+ * all copies or substantial portions of the Software.1313+ *1414+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1515+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1616+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1717+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR1818+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,1919+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2020+ * OTHER DEALINGS IN THE SOFTWARE.2121+ *2222+ * Authors: AMD2323+ */224#include "dm_services.h"325#include "dc.h"426#include "dc_link_dp.h"···18621840 dp_disable_link_phy(link, signal);1863184118641842 /* Abort link training if failure due to sink being unplugged. */18651865- if (status == LINK_TRAINING_ABORT)18661866- break;18671867- else if (do_fallback) {18431843+ if (status == LINK_TRAINING_ABORT) {18441844+ enum dc_connection_type type = dc_connection_none;18451845+18461846+ dc_link_detect_sink(link, &type);18471847+ if (type == dc_connection_none)18481848+ break;18491849+ } else if (do_fallback) {18681850 decide_fallback_link_setting(*link_setting, ¤t_setting, status);18691851 /* Fail link training if reduced link bandwidth no longer meets18701852 * stream requirements.
···4444#undef pr_info4545#undef pr_debug46464747+/* unit: MHz */4848+#define CYAN_SKILLFISH_SCLK_MIN 10004949+#define CYAN_SKILLFISH_SCLK_MAX 20005050+#define CYAN_SKILLFISH_SCLK_DEFAULT 18005151+5252+/* unit: mV */5353+#define CYAN_SKILLFISH_VDDC_MIN 7005454+#define CYAN_SKILLFISH_VDDC_MAX 11295555+#define CYAN_SKILLFISH_VDDC_MAGIC 5118 // 0x13fe5656+5757+static struct gfx_user_settings {5858+ uint32_t sclk;5959+ uint32_t vddc;6060+} cyan_skillfish_user_settings;6161+6262+#define FEATURE_MASK(feature) (1ULL << feature)6363+#define SMC_DPM_FEATURE ( \6464+ FEATURE_MASK(FEATURE_FCLK_DPM_BIT) | \6565+ FEATURE_MASK(FEATURE_SOC_DPM_BIT) | \6666+ FEATURE_MASK(FEATURE_GFX_DPM_BIT))6767+4768static struct cmn2asic_msg_mapping cyan_skillfish_message_map[SMU_MSG_MAX_COUNT] = {4869 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0),4970 MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 0),···7352 MSG_MAP(SetDriverDramAddrLow, PPSMC_MSG_SetDriverTableDramAddrLow, 0),7453 MSG_MAP(TransferTableSmu2Dram, PPSMC_MSG_TransferTableSmu2Dram, 0),7554 MSG_MAP(TransferTableDram2Smu, PPSMC_MSG_TransferTableDram2Smu, 0),5555+ MSG_MAP(GetEnabledSmuFeatures, PPSMC_MSG_GetEnabledSmuFeatures, 0),5656+ MSG_MAP(RequestGfxclk, PPSMC_MSG_RequestGfxclk, 0),5757+ MSG_MAP(ForceGfxVid, PPSMC_MSG_ForceGfxVid, 0),5858+ MSG_MAP(UnforceGfxVid, PPSMC_MSG_UnforceGfxVid, 0),7659};6060+6161+static struct cmn2asic_mapping cyan_skillfish_table_map[SMU_TABLE_COUNT] = {6262+ TAB_MAP_VALID(SMU_METRICS),6363+};6464+6565+static int cyan_skillfish_tables_init(struct smu_context *smu)6666+{6767+ struct smu_table_context *smu_table = &smu->smu_table;6868+ struct smu_table *tables = smu_table->tables;6969+7070+ SMU_TABLE_INIT(tables, SMU_TABLE_SMU_METRICS,7171+ sizeof(SmuMetrics_t),7272+ PAGE_SIZE,7373+ AMDGPU_GEM_DOMAIN_VRAM);7474+7575+ smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);7676+ if (!smu_table->metrics_table)7777+ goto err0_out;7878+7979+ smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v2_2);8080+ smu_table->gpu_metrics_table = kzalloc(smu_table->gpu_metrics_table_size, GFP_KERNEL);8181+ if (!smu_table->gpu_metrics_table)8282+ goto err1_out;8383+8484+ smu_table->metrics_time = 0;8585+8686+ return 0;8787+8888+err1_out:8989+ smu_table->gpu_metrics_table_size = 0;9090+ kfree(smu_table->metrics_table);9191+err0_out:9292+ return -ENOMEM;9393+}9494+9595+static int cyan_skillfish_init_smc_tables(struct smu_context *smu)9696+{9797+ int ret = 0;9898+9999+ ret = cyan_skillfish_tables_init(smu);100100+ if (ret)101101+ return ret;102102+103103+ return smu_v11_0_init_smc_tables(smu);104104+}105105+106106+static int cyan_skillfish_finit_smc_tables(struct smu_context *smu)107107+{108108+ struct smu_table_context *smu_table = &smu->smu_table;109109+110110+ kfree(smu_table->metrics_table);111111+ smu_table->metrics_table = NULL;112112+113113+ kfree(smu_table->gpu_metrics_table);114114+ smu_table->gpu_metrics_table = NULL;115115+ smu_table->gpu_metrics_table_size = 0;116116+117117+ smu_table->metrics_time = 0;118118+119119+ return 0;120120+}121121+122122+static int123123+cyan_skillfish_get_smu_metrics_data(struct smu_context *smu,124124+ MetricsMember_t member,125125+ uint32_t *value)126126+{127127+ struct smu_table_context *smu_table = &smu->smu_table;128128+ SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;129129+ int ret = 0;130130+131131+ mutex_lock(&smu->metrics_lock);132132+133133+ ret = smu_cmn_get_metrics_table_locked(smu, NULL, false);134134+ if (ret) {135135+ mutex_unlock(&smu->metrics_lock);136136+ return ret;137137+ }138138+139139+ switch (member) {140140+ case METRICS_CURR_GFXCLK:141141+ *value = metrics->Current.GfxclkFrequency;142142+ break;143143+ case METRICS_CURR_SOCCLK:144144+ *value = metrics->Current.SocclkFrequency;145145+ break;146146+ case METRICS_CURR_VCLK:147147+ *value = metrics->Current.VclkFrequency;148148+ break;149149+ case METRICS_CURR_DCLK:150150+ *value = metrics->Current.DclkFrequency;151151+ break;152152+ case METRICS_CURR_UCLK:153153+ *value = metrics->Current.MemclkFrequency;154154+ break;155155+ case METRICS_AVERAGE_SOCKETPOWER:156156+ *value = (metrics->Current.CurrentSocketPower << 8) /157157+ 1000;158158+ break;159159+ case METRICS_TEMPERATURE_EDGE:160160+ *value = metrics->Current.GfxTemperature / 100 *161161+ SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;162162+ break;163163+ case METRICS_TEMPERATURE_HOTSPOT:164164+ *value = metrics->Current.SocTemperature / 100 *165165+ SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;166166+ break;167167+ case METRICS_VOLTAGE_VDDSOC:168168+ *value = metrics->Current.Voltage[0];169169+ break;170170+ case METRICS_VOLTAGE_VDDGFX:171171+ *value = metrics->Current.Voltage[1];172172+ break;173173+ case METRICS_THROTTLER_STATUS:174174+ *value = metrics->Current.ThrottlerStatus;175175+ break;176176+ default:177177+ *value = UINT_MAX;178178+ break;179179+ }180180+181181+ mutex_unlock(&smu->metrics_lock);182182+183183+ return ret;184184+}185185+186186+static int cyan_skillfish_read_sensor(struct smu_context *smu,187187+ enum amd_pp_sensors sensor,188188+ void *data,189189+ uint32_t *size)190190+{191191+ int ret = 0;192192+193193+ if (!data || !size)194194+ return -EINVAL;195195+196196+ mutex_lock(&smu->sensor_lock);197197+198198+ switch (sensor) {199199+ case AMDGPU_PP_SENSOR_GFX_SCLK:200200+ ret = cyan_skillfish_get_smu_metrics_data(smu,201201+ METRICS_CURR_GFXCLK,202202+ (uint32_t *)data);203203+ *(uint32_t *)data *= 100;204204+ *size = 4;205205+ break;206206+ case AMDGPU_PP_SENSOR_GFX_MCLK:207207+ ret = cyan_skillfish_get_smu_metrics_data(smu,208208+ METRICS_CURR_UCLK,209209+ (uint32_t *)data);210210+ *(uint32_t *)data *= 100;211211+ *size = 4;212212+ break;213213+ case AMDGPU_PP_SENSOR_GPU_POWER:214214+ ret = cyan_skillfish_get_smu_metrics_data(smu,215215+ METRICS_AVERAGE_SOCKETPOWER,216216+ (uint32_t *)data);217217+ *size = 4;218218+ break;219219+ case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:220220+ ret = cyan_skillfish_get_smu_metrics_data(smu,221221+ METRICS_TEMPERATURE_HOTSPOT,222222+ (uint32_t *)data);223223+ *size = 4;224224+ break;225225+ case AMDGPU_PP_SENSOR_EDGE_TEMP:226226+ ret = cyan_skillfish_get_smu_metrics_data(smu,227227+ METRICS_TEMPERATURE_EDGE,228228+ (uint32_t *)data);229229+ *size = 4;230230+ break;231231+ case AMDGPU_PP_SENSOR_VDDNB:232232+ ret = cyan_skillfish_get_smu_metrics_data(smu,233233+ METRICS_VOLTAGE_VDDSOC,234234+ (uint32_t *)data);235235+ *size = 4;236236+ break;237237+ case AMDGPU_PP_SENSOR_VDDGFX:238238+ ret = cyan_skillfish_get_smu_metrics_data(smu,239239+ METRICS_VOLTAGE_VDDGFX,240240+ (uint32_t *)data);241241+ *size = 4;242242+ break;243243+ default:244244+ ret = -EOPNOTSUPP;245245+ break;246246+ }247247+248248+ mutex_unlock(&smu->sensor_lock);249249+250250+ return ret;251251+}252252+253253+static int cyan_skillfish_get_current_clk_freq(struct smu_context *smu,254254+ enum smu_clk_type clk_type,255255+ uint32_t *value)256256+{257257+ MetricsMember_t member_type;258258+259259+ switch (clk_type) {260260+ case SMU_GFXCLK:261261+ case SMU_SCLK:262262+ member_type = METRICS_CURR_GFXCLK;263263+ break;264264+ case SMU_FCLK:265265+ case SMU_MCLK:266266+ member_type = METRICS_CURR_UCLK;267267+ break;268268+ case SMU_SOCCLK:269269+ member_type = METRICS_CURR_SOCCLK;270270+ break;271271+ case SMU_VCLK:272272+ member_type = METRICS_CURR_VCLK;273273+ break;274274+ case SMU_DCLK:275275+ member_type = METRICS_CURR_DCLK;276276+ break;277277+ default:278278+ return -EINVAL;279279+ }280280+281281+ return cyan_skillfish_get_smu_metrics_data(smu, member_type, value);282282+}283283+284284+static int cyan_skillfish_print_clk_levels(struct smu_context *smu,285285+ enum smu_clk_type clk_type,286286+ char *buf)287287+{288288+ int ret = 0, size = 0;289289+ uint32_t cur_value = 0;290290+291291+ smu_cmn_get_sysfs_buf(&buf, &size);292292+293293+ switch (clk_type) {294294+ case SMU_OD_SCLK:295295+ ret = cyan_skillfish_get_smu_metrics_data(smu, METRICS_CURR_GFXCLK, &cur_value);296296+ if (ret)297297+ return ret;298298+ size += sysfs_emit_at(buf, size,"%s:\n", "OD_SCLK");299299+ size += sysfs_emit_at(buf, size, "0: %uMhz *\n", cur_value);300300+ break;301301+ case SMU_OD_VDDC_CURVE:302302+ ret = cyan_skillfish_get_smu_metrics_data(smu, METRICS_VOLTAGE_VDDGFX, &cur_value);303303+ if (ret)304304+ return ret;305305+ size += sysfs_emit_at(buf, size,"%s:\n", "OD_VDDC");306306+ size += sysfs_emit_at(buf, size, "0: %umV *\n", cur_value);307307+ break;308308+ case SMU_OD_RANGE:309309+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");310310+ size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n",311311+ CYAN_SKILLFISH_SCLK_MIN, CYAN_SKILLFISH_SCLK_MAX);312312+ size += sysfs_emit_at(buf, size, "VDDC: %7umV %10umV\n",313313+ CYAN_SKILLFISH_VDDC_MIN, CYAN_SKILLFISH_VDDC_MAX);314314+ break;315315+ case SMU_GFXCLK:316316+ case SMU_SCLK:317317+ case SMU_FCLK:318318+ case SMU_MCLK:319319+ case SMU_SOCCLK:320320+ case SMU_VCLK:321321+ case SMU_DCLK:322322+ ret = cyan_skillfish_get_current_clk_freq(smu, clk_type, &cur_value);323323+ if (ret)324324+ return ret;325325+ size += sysfs_emit_at(buf, size, "0: %uMhz *\n", cur_value);326326+ break;327327+ default:328328+ dev_warn(smu->adev->dev, "Unsupported clock type\n");329329+ return ret;330330+ }331331+332332+ return size;333333+}334334+335335+static bool cyan_skillfish_is_dpm_running(struct smu_context *smu)336336+{337337+ struct amdgpu_device *adev = smu->adev;338338+ int ret = 0;339339+ uint32_t feature_mask[2];340340+ uint64_t feature_enabled;341341+342342+ /* we need to re-init after suspend so return false */343343+ if (adev->in_suspend)344344+ return false;345345+346346+ ret = smu_cmn_get_enabled_32_bits_mask(smu, feature_mask, 2);347347+348348+ if (ret)349349+ return false;350350+351351+ feature_enabled = (uint64_t)feature_mask[0] |352352+ ((uint64_t)feature_mask[1] << 32);353353+354354+ return !!(feature_enabled & SMC_DPM_FEATURE);355355+}356356+357357+static ssize_t cyan_skillfish_get_gpu_metrics(struct smu_context *smu,358358+ void **table)359359+{360360+ struct smu_table_context *smu_table = &smu->smu_table;361361+ struct gpu_metrics_v2_2 *gpu_metrics =362362+ (struct gpu_metrics_v2_2 *)smu_table->gpu_metrics_table;363363+ SmuMetrics_t metrics;364364+ int i, ret = 0;365365+366366+ ret = smu_cmn_get_metrics_table(smu, &metrics, true);367367+ if (ret)368368+ return ret;369369+370370+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 2, 2);371371+372372+ gpu_metrics->temperature_gfx = metrics.Current.GfxTemperature;373373+ gpu_metrics->temperature_soc = metrics.Current.SocTemperature;374374+375375+ gpu_metrics->average_socket_power = metrics.Current.CurrentSocketPower;376376+ gpu_metrics->average_soc_power = metrics.Current.Power[0];377377+ gpu_metrics->average_gfx_power = metrics.Current.Power[1];378378+379379+ gpu_metrics->average_gfxclk_frequency = metrics.Average.GfxclkFrequency;380380+ gpu_metrics->average_socclk_frequency = metrics.Average.SocclkFrequency;381381+ gpu_metrics->average_uclk_frequency = metrics.Average.MemclkFrequency;382382+ gpu_metrics->average_fclk_frequency = metrics.Average.MemclkFrequency;383383+ gpu_metrics->average_vclk_frequency = metrics.Average.VclkFrequency;384384+ gpu_metrics->average_dclk_frequency = metrics.Average.DclkFrequency;385385+386386+ gpu_metrics->current_gfxclk = metrics.Current.GfxclkFrequency;387387+ gpu_metrics->current_socclk = metrics.Current.SocclkFrequency;388388+ gpu_metrics->current_uclk = metrics.Current.MemclkFrequency;389389+ gpu_metrics->current_fclk = metrics.Current.MemclkFrequency;390390+ gpu_metrics->current_vclk = metrics.Current.VclkFrequency;391391+ gpu_metrics->current_dclk = metrics.Current.DclkFrequency;392392+393393+ for (i = 0; i < 6; i++) {394394+ gpu_metrics->temperature_core[i] = metrics.Current.CoreTemperature[i];395395+ gpu_metrics->average_core_power[i] = metrics.Average.CorePower[i];396396+ gpu_metrics->current_coreclk[i] = metrics.Current.CoreFrequency[i];397397+ }398398+399399+ for (i = 0; i < 2; i++) {400400+ gpu_metrics->temperature_l3[i] = metrics.Current.L3Temperature[i];401401+ gpu_metrics->current_l3clk[i] = metrics.Current.L3Frequency[i];402402+ }403403+404404+ gpu_metrics->throttle_status = metrics.Current.ThrottlerStatus;405405+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();406406+407407+ *table = (void *)gpu_metrics;408408+409409+ return sizeof(struct gpu_metrics_v2_2);410410+}411411+412412+static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,413413+ enum PP_OD_DPM_TABLE_COMMAND type,414414+ long input[], uint32_t size)415415+{416416+ int ret = 0;417417+ uint32_t vid;418418+419419+ switch (type) {420420+ case PP_OD_EDIT_VDDC_CURVE:421421+ if (size != 3 || input[0] != 0) {422422+ dev_err(smu->adev->dev, "Invalid parameter!\n");423423+ return -EINVAL;424424+ }425425+426426+ if (input[1] <= CYAN_SKILLFISH_SCLK_MIN ||427427+ input[1] > CYAN_SKILLFISH_SCLK_MAX) {428428+ dev_err(smu->adev->dev, "Invalid sclk! Valid sclk range: %uMHz - %uMhz\n",429429+ CYAN_SKILLFISH_SCLK_MIN, CYAN_SKILLFISH_SCLK_MAX);430430+ return -EINVAL;431431+ }432432+433433+ if (input[2] <= CYAN_SKILLFISH_VDDC_MIN ||434434+ input[2] > CYAN_SKILLFISH_VDDC_MAX) {435435+ dev_err(smu->adev->dev, "Invalid vddc! Valid vddc range: %umV - %umV\n",436436+ CYAN_SKILLFISH_VDDC_MIN, CYAN_SKILLFISH_VDDC_MAX);437437+ return -EINVAL;438438+ }439439+440440+ cyan_skillfish_user_settings.sclk = input[1];441441+ cyan_skillfish_user_settings.vddc = input[2];442442+443443+ break;444444+ case PP_OD_RESTORE_DEFAULT_TABLE:445445+ if (size != 0) {446446+ dev_err(smu->adev->dev, "Invalid parameter!\n");447447+ return -EINVAL;448448+ }449449+450450+ cyan_skillfish_user_settings.sclk = CYAN_SKILLFISH_SCLK_DEFAULT;451451+ cyan_skillfish_user_settings.vddc = CYAN_SKILLFISH_VDDC_MAGIC;452452+453453+ break;454454+ case PP_OD_COMMIT_DPM_TABLE:455455+ if (size != 0) {456456+ dev_err(smu->adev->dev, "Invalid parameter!\n");457457+ return -EINVAL;458458+ }459459+460460+ if (cyan_skillfish_user_settings.sclk < CYAN_SKILLFISH_SCLK_MIN ||461461+ cyan_skillfish_user_settings.sclk > CYAN_SKILLFISH_SCLK_MAX) {462462+ dev_err(smu->adev->dev, "Invalid sclk! Valid sclk range: %uMHz - %uMhz\n",463463+ CYAN_SKILLFISH_SCLK_MIN, CYAN_SKILLFISH_SCLK_MAX);464464+ return -EINVAL;465465+ }466466+467467+ if ((cyan_skillfish_user_settings.vddc != CYAN_SKILLFISH_VDDC_MAGIC) &&468468+ (cyan_skillfish_user_settings.vddc < CYAN_SKILLFISH_VDDC_MIN ||469469+ cyan_skillfish_user_settings.vddc > CYAN_SKILLFISH_VDDC_MAX)) {470470+ dev_err(smu->adev->dev, "Invalid vddc! Valid vddc range: %umV - %umV\n",471471+ CYAN_SKILLFISH_VDDC_MIN, CYAN_SKILLFISH_VDDC_MAX);472472+ return -EINVAL;473473+ }474474+475475+ ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_RequestGfxclk,476476+ cyan_skillfish_user_settings.sclk, NULL);477477+ if (ret) {478478+ dev_err(smu->adev->dev, "Set sclk failed!\n");479479+ return ret;480480+ }481481+482482+ if (cyan_skillfish_user_settings.vddc == CYAN_SKILLFISH_VDDC_MAGIC) {483483+ ret = smu_cmn_send_smc_msg(smu, SMU_MSG_UnforceGfxVid, NULL);484484+ if (ret) {485485+ dev_err(smu->adev->dev, "Unforce vddc failed!\n");486486+ return ret;487487+ }488488+ } else {489489+ /*490490+ * PMFW accepts SVI2 VID code, convert voltage to VID:491491+ * vid = (uint32_t)((1.55 - voltage) * 160.0 + 0.00001)492492+ */493493+ vid = (1550 - cyan_skillfish_user_settings.vddc) * 160 / 1000;494494+ ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ForceGfxVid, vid, NULL);495495+ if (ret) {496496+ dev_err(smu->adev->dev, "Force vddc failed!\n");497497+ return ret;498498+ }499499+ }500500+501501+ break;502502+ default:503503+ return -EOPNOTSUPP;504504+ }505505+506506+ return ret;507507+}7750878509static const struct pptable_funcs cyan_skillfish_ppt_funcs = {79510···53360 .check_fw_version = smu_v11_0_check_fw_version,53461 .init_power = smu_v11_0_init_power,53562 .fini_power = smu_v11_0_fini_power,6363+ .init_smc_tables = cyan_skillfish_init_smc_tables,6464+ .fini_smc_tables = cyan_skillfish_finit_smc_tables,6565+ .read_sensor = cyan_skillfish_read_sensor,6666+ .print_clk_levels = cyan_skillfish_print_clk_levels,6767+ .is_dpm_running = cyan_skillfish_is_dpm_running,6868+ .get_gpu_metrics = cyan_skillfish_get_gpu_metrics,6969+ .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table,53670 .register_irq_handler = smu_v11_0_register_irq_handler,53771 .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location,53872 .send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,···55272{55373 smu->ppt_funcs = &cyan_skillfish_ppt_funcs;55474 smu->message_map = cyan_skillfish_message_map;7575+ smu->table_map = cyan_skillfish_table_map;55576 smu->is_apu = true;55677}
+25-3
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
···12791279 struct smu_11_0_overdrive_table *od_settings = smu->od_settings;12801280 uint32_t min_value, max_value;1281128112821282+ smu_cmn_get_sysfs_buf(&buf, &size);12831283+12821284 switch (clk_type) {12831285 case SMU_GFXCLK:12841286 case SMU_SCLK:···13941392 case SMU_OD_RANGE:13951393 if (!smu->od_enabled || !od_table || !od_settings)13961394 break;13971397- size = sysfs_emit(buf, "%s:\n", "OD_RANGE");13951395+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");1398139613991397 if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) {14001398 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMIN,···22742272{22752273 struct amdgpu_device *adev = smu->adev;2276227422772277- if (adev->in_runpm)22752275+ /*22762276+ * This aims the case below:22772277+ * amdgpu driver loaded -> runpm suspend kicked -> sound driver loaded22782278+ *22792279+ * For NAVI10 and later ASICs, we rely on PMFW to handle the runpm. To22802280+ * make that possible, PMFW needs to acknowledge the dstate transition22812281+ * process for both gfx(function 0) and audio(function 1) function of22822282+ * the ASIC.22832283+ *22842284+ * The PCI device's initial runpm status is RUNPM_SUSPENDED. So as the22852285+ * device representing the audio function of the ASIC. And that means22862286+ * even if the sound driver(snd_hda_intel) was not loaded yet, it's still22872287+ * possible runpm suspend kicked on the ASIC. However without the dstate22882288+ * transition notification from audio function, pmfw cannot handle the22892289+ * BACO in/exit correctly. And that will cause driver hang on runpm22902290+ * resuming.22912291+ *22922292+ * To address this, we revert to legacy message way(driver masters the22932293+ * timing for BACO in/exit) on sound driver missing.22942294+ */22952295+ if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))22782296 return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);22792297 else22802298 return smu_v11_0_baco_enter(smu);···23042282{23052283 struct amdgpu_device *adev = smu->adev;2306228423072307- if (adev->in_runpm) {22852285+ if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {23082286 /* Wait for PMFW handling for the Dstate change */23092287 msleep(10);23102288 return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
···1053105310541054 return ret;10551055}10561056+10571057+bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev)10581058+{10591059+ struct pci_dev *p = NULL;10601060+ bool snd_driver_loaded;10611061+10621062+ /*10631063+ * If the ASIC comes with no audio function, we always assume10641064+ * it is "enabled".10651065+ */10661066+ p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),10671067+ adev->pdev->bus->number, 1);10681068+ if (!p)10691069+ return true;10701070+10711071+ snd_driver_loaded = pci_is_enabled(p) ? true : false;10721072+10731073+ pci_dev_put(p);10741074+10751075+ return snd_driver_loaded;10761076+}
+15
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
···110110int smu_cmn_set_mp1_state(struct smu_context *smu,111111 enum pp_mp1_state mp1_state);112112113113+/*114114+ * Helper function to make sysfs_emit_at() happy. Align buf to115115+ * the current page boundary and record the offset.116116+ */117117+static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)118118+{119119+ if (!*buf || !offset)120120+ return;121121+122122+ *offset = offset_in_page(*buf);123123+ *buf -= *offset;124124+}125125+126126+bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev);127127+113128#endif114129#endif
···9292 struct etnaviv_iommuv1_context *v1_context = to_v1_context(context);9393 u32 pgtable;94949595+ if (gpu->mmu_context)9696+ etnaviv_iommu_context_put(gpu->mmu_context);9797+ gpu->mmu_context = etnaviv_iommu_context_get(context);9898+9599 /* set base addresses */96100 gpu_write(gpu, VIVS_MC_MEMORY_BASE_ADDR_RA, context->global->memory_base);97101 gpu_write(gpu, VIVS_MC_MEMORY_BASE_ADDR_FE, context->global->memory_base);
+8
drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
···172172 if (gpu_read(gpu, VIVS_MMUv2_CONTROL) & VIVS_MMUv2_CONTROL_ENABLE)173173 return;174174175175+ if (gpu->mmu_context)176176+ etnaviv_iommu_context_put(gpu->mmu_context);177177+ gpu->mmu_context = etnaviv_iommu_context_get(context);178178+175179 prefetch = etnaviv_buffer_config_mmuv2(gpu,176180 (u32)v2_context->mtlb_dma,177181 (u32)context->global->bad_page_dma);···195191 /* If the MMU is already enabled the state is still there. */196192 if (gpu_read(gpu, VIVS_MMUv2_SEC_CONTROL) & VIVS_MMUv2_SEC_CONTROL_ENABLE)197193 return;194194+195195+ if (gpu->mmu_context)196196+ etnaviv_iommu_context_put(gpu->mmu_context);197197+ gpu->mmu_context = etnaviv_iommu_context_get(context);198198199199 gpu_write(gpu, VIVS_MMUv2_PTA_ADDRESS_LOW,200200 lower_32_bits(context->global->v2.pta_dma));
···24452445 */24462446 if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_DPCD_REV,24472447 intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd)) ==24482448- sizeof(intel_dp->edp_dpcd))24482448+ sizeof(intel_dp->edp_dpcd)) {24492449 drm_dbg_kms(&dev_priv->drm, "eDP DPCD: %*ph\n",24502450 (int)sizeof(intel_dp->edp_dpcd),24512451 intel_dp->edp_dpcd);24522452+24532453+ intel_dp->use_max_params = intel_dp->edp_dpcd[0] < DP_EDP_14;24542454+ }2452245524532456 /*24542457 * This has to be called after intel_dp->edp_dpcd is filled, PSR checks
···848848 }849849850850 if (ret)851851- intel_dp_link_train_phy(intel_dp, crtc_state, DP_PHY_DPRX);851851+ ret = intel_dp_link_train_phy(intel_dp, crtc_state, DP_PHY_DPRX);852852853853 if (intel_dp->set_idle_link_train)854854 intel_dp->set_idle_link_train(intel_dp, crtc_state);
+3-3
drivers/gpu/drm/i915/gem/i915_gem_context.c
···986986 trace_i915_context_free(ctx);987987 GEM_BUG_ON(!i915_gem_context_is_closed(ctx));988988989989+ if (ctx->syncobj)990990+ drm_syncobj_put(ctx->syncobj);991991+989992 mutex_destroy(&ctx->engines_mutex);990993 mutex_destroy(&ctx->lut_mutex);991994···12071204 vm = i915_gem_context_vm(ctx);12081205 if (vm)12091206 i915_vm_close(vm);12101210-12111211- if (ctx->syncobj)12121212- drm_syncobj_put(ctx->syncobj);1213120712141208 ctx->file_priv = ERR_PTR(-EBADF);12151209
···172172 __uc_free_load_err_log(uc);173173}174174175175-static inline bool guc_communication_enabled(struct intel_guc *guc)176176-{177177- return intel_guc_ct_enabled(&guc->ct);178178-}179179-180175/*181176 * Events triggered while CT buffers are disabled are logged in the SCRATCH_15182177 * register using the same bits used in the CT message payload. Since our···205210static void guc_handle_mmio_msg(struct intel_guc *guc)206211{207212 /* we need communication to be enabled to reply to GuC */208208- GEM_BUG_ON(!guc_communication_enabled(guc));213213+ GEM_BUG_ON(!intel_guc_ct_enabled(&guc->ct));209214210215 spin_lock_irq(&guc->irq_lock);211216 if (guc->mmio_msg) {···221226 struct drm_i915_private *i915 = gt->i915;222227 int ret;223228224224- GEM_BUG_ON(guc_communication_enabled(guc));229229+ GEM_BUG_ON(intel_guc_ct_enabled(&guc->ct));225230226231 ret = i915_inject_probe_error(i915, -ENXIO);227232 if (ret)···657662 return 0;658663659664 /* Make sure we enable communication if and only if it's disabled */660660- GEM_BUG_ON(enable_communication == guc_communication_enabled(guc));665665+ GEM_BUG_ON(enable_communication == intel_guc_ct_enabled(&guc->ct));661666662667 if (enable_communication)663668 guc_enable_communication(guc);
+1-1
drivers/gpu/drm/radeon/radeon_kms.c
···119119#endif120120121121 if (pci_find_capability(pdev, PCI_CAP_ID_AGP))122122- rdev->agp = radeon_agp_head_init(rdev->ddev);122122+ rdev->agp = radeon_agp_head_init(dev);123123 if (rdev->agp) {124124 rdev->agp->agp_mtrr = arch_phys_wc_add(125125 rdev->agp->agp_info.aper_base,
+1-1
drivers/gpu/drm/rockchip/cdn-dp-core.c
···11231123 return ret;11241124}1125112511261126-static int cdn_dp_resume(struct device *dev)11261126+static __maybe_unused int cdn_dp_resume(struct device *dev)11271127{11281128 struct cdn_dp_device *dp = dev_get_drvdata(dev);11291129
···1885188518861886 reset_control_assert(gphy_fw->reset);1887188718881888+ /* The vendor BSP uses a 200ms delay after asserting the reset line.18891889+ * Without this some users are observing that the PHY is not coming up18901890+ * on the MDIO bus.18911891+ */18921892+ msleep(200);18931893+18881894 ret = request_firmware(&fw, gphy_fw->fw_name, dev);18891895 if (ret) {18901896 dev_err(dev, "failed to load firmware: %s, error: %i\n",
+22-8
drivers/net/dsa/qca8k.c
···643643}644644645645static int646646-qca8k_mdio_write(struct mii_bus *salve_bus, int phy, int regnum, u16 data)646646+qca8k_mdio_write(struct mii_bus *bus, int phy, int regnum, u16 data)647647{648648- struct qca8k_priv *priv = salve_bus->priv;649649- struct mii_bus *bus = priv->bus;650648 u16 r1, r2, page;651649 u32 val;652650 int ret;···680682}681683682684static int683683-qca8k_mdio_read(struct mii_bus *salve_bus, int phy, int regnum)685685+qca8k_mdio_read(struct mii_bus *bus, int phy, int regnum)684686{685685- struct qca8k_priv *priv = salve_bus->priv;686686- struct mii_bus *bus = priv->bus;687687 u16 r1, r2, page;688688 u32 val;689689 int ret;···720724 ret = val & QCA8K_MDIO_MASTER_DATA_MASK;721725722726 return ret;727727+}728728+729729+static int730730+qca8k_internal_mdio_write(struct mii_bus *slave_bus, int phy, int regnum, u16 data)731731+{732732+ struct qca8k_priv *priv = slave_bus->priv;733733+ struct mii_bus *bus = priv->bus;734734+735735+ return qca8k_mdio_write(bus, phy, regnum, data);736736+}737737+738738+static int739739+qca8k_internal_mdio_read(struct mii_bus *slave_bus, int phy, int regnum)740740+{741741+ struct qca8k_priv *priv = slave_bus->priv;742742+ struct mii_bus *bus = priv->bus;743743+744744+ return qca8k_mdio_read(bus, phy, regnum);723745}724746725747static int···789775790776 bus->priv = (void *)priv;791777 bus->name = "qca8k slave mii";792792- bus->read = qca8k_mdio_read;793793- bus->write = qca8k_mdio_write;778778+ bus->read = qca8k_internal_mdio_read;779779+ bus->write = qca8k_internal_mdio_write;794780 snprintf(bus->id, MII_BUS_ID_SIZE, "qca8k-%d",795781 ds->index);796782
+1-1
drivers/net/ethernet/3com/3c515.c
···10501050#ifdef VORTEX_BUS_MASTER10511051 if (vp->bus_master) {10521052 /* Set the bus-master controller to transfer the packet. */10531053- outl((int) (skb->data), ioaddr + Wn7_MasterAddr);10531053+ outl(isa_virt_to_bus(skb->data), ioaddr + Wn7_MasterAddr);10541054 outw((skb->len + 3) & ~3, ioaddr + Wn7_MasterLen);10551055 vp->tx_skb = skb;10561056 outw(StartDMADown, ioaddr + EL3_CMD);
+7-15
drivers/net/ethernet/8390/ne.c
···922922 }923923}924924925925-#ifdef MODULE926925static int __init ne_init(void)927926{928927 int retval;929929- ne_add_devices();928928+929929+ if (IS_MODULE(CONFIG_NE2000))930930+ ne_add_devices();931931+930932 retval = platform_driver_probe(&ne_driver, ne_drv_probe);931931- if (retval) {933933+934934+ if (IS_MODULE(CONFIG_NE2000) && retval) {932935 if (io[0] == 0)933936 pr_notice("ne.c: You must supply \"io=0xNNN\""934937 " value(s) for ISA cards.\n");···944941 return retval;945942}946943module_init(ne_init);947947-#else /* MODULE */948948-static int __init ne_init(void)949949-{950950- int retval = platform_driver_probe(&ne_driver, ne_drv_probe);951944952952- /* Unregister unused platform_devices. */953953- ne_loop_rm_unreg(0);954954- return retval;955955-}956956-module_init(ne_init);957957-958958-#ifdef CONFIG_NETDEV_LEGACY_INIT945945+#if !defined(MODULE) && defined(CONFIG_NETDEV_LEGACY_INIT)959946struct net_device * __init ne_probe(int unit)960947{961948 int this_dev;···987994 return ERR_PTR(-ENODEV);988995}989996#endif990990-#endif /* MODULE */991997992998static void __exit ne_exit(void)993999{
···22132213 DIV_ROUND_UP(fw_health->polling_dsecs * HZ,22142214 bp->current_interval * 10);22152215 fw_health->tmr_counter = fw_health->tmr_multiplier;22162216- if (!fw_health->enabled) {22162216+ if (!fw_health->enabled)22172217 fw_health->last_fw_heartbeat =22182218 bnxt_fw_health_readl(bp, BNXT_FW_HEARTBEAT_REG);22192219- fw_health->last_fw_reset_cnt =22202220- bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);22212221- }22192219+ fw_health->last_fw_reset_cnt =22202220+ bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);22222221 netif_info(bp, drv, bp->dev,22232222 "Error recovery info: error recovery[1], master[%d], reset count[%u], health status: 0x%x\n",22242223 fw_health->master, fw_health->last_fw_reset_cnt,···27292730 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];27302731 int j;2731273227332733+ if (!txr->tx_buf_ring)27342734+ continue;27352735+27322736 for (j = 0; j < max_idx;) {27332737 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j];27342738 struct sk_buff *skb;···28162814 }2817281528182816skip_rx_tpa_free:28172817+ if (!rxr->rx_buf_ring)28182818+ goto skip_rx_buf_free;28192819+28192820 for (i = 0; i < max_idx; i++) {28202821 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i];28212822 dma_addr_t mapping = rx_buf->mapping;···28412836 kfree(data);28422837 }28432838 }28392839+28402840+skip_rx_buf_free:28412841+ if (!rxr->rx_agg_ring)28422842+ goto skip_rx_agg_free;28432843+28442844 for (i = 0; i < max_agg_idx; i++) {28452845 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i];28462846 struct page *page = rx_agg_buf->page;···2862285228632853 __free_page(page);28642854 }28552855+28562856+skip_rx_agg_free:28652857 if (rxr->rx_page) {28662858 __free_page(rxr->rx_page);28672859 rxr->rx_page = NULL;···29122900 struct pci_dev *pdev = bp->pdev;29132901 int i;2914290229032903+ if (!rmem->pg_arr)29042904+ goto skip_pages;29052905+29152906 for (i = 0; i < rmem->nr_pages; i++) {29162907 if (!rmem->pg_arr[i])29172908 continue;···2924290929252910 rmem->pg_arr[i] = NULL;29262911 }29122912+skip_pages:29272913 if (rmem->pg_tbl) {29282914 size_t pg_tbl_size = rmem->nr_pages * 8;29292915···3244322832453229static void bnxt_free_cp_arrays(struct bnxt_cp_ring_info *cpr)32463230{32313231+ struct bnxt_ring_struct *ring = &cpr->cp_ring_struct;32323232+32473233 kfree(cpr->cp_desc_ring);32483234 cpr->cp_desc_ring = NULL;32353235+ ring->ring_mem.pg_arr = NULL;32493236 kfree(cpr->cp_desc_mapping);32503237 cpr->cp_desc_mapping = NULL;32383238+ ring->ring_mem.dma_arr = NULL;32513239}3252324032533241static int bnxt_alloc_cp_arrays(struct bnxt_cp_ring_info *cpr, int n)···1222712207 return;1222812208 }12229122091221012210+ if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) &&1221112211+ bp->fw_health->enabled) {1221212212+ bp->fw_health->last_fw_reset_cnt =1221312213+ bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);1221412214+ }1223012215 bp->fw_reset_state = 0;1223112216 /* Make sure fw_reset_state is 0 before clearing the flag */1223212217 smp_mb__before_atomic();
-3
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
···18841884{18851885 struct bnxt_flower_indr_block_cb_priv *cb_priv;1886188618871887- /* All callback list access should be protected by RTNL. */18881888- ASSERT_RTNL();18891889-18901887 list_for_each_entry(cb_priv, &bp->tc_indr_block_list, list)18911888 if (cb_priv->tunnel_netdev == netdev)18921889 return cb_priv;
···6161module_param(tx_sgl, uint, 0600);6262MODULE_PARM_DESC(tx_sgl, "Minimum number of frags when using dma_map_sg() to optimize the IOMMU mapping");63636464+static bool page_pool_enabled = true;6565+module_param(page_pool_enabled, bool, 0400);6666+6467#define HNS3_SGL_SIZE(nfrag) (sizeof(struct scatterlist) * (nfrag) + \6568 sizeof(struct sg_table))6669#define HNS3_MAX_SGL_SIZE ALIGN(HNS3_SGL_SIZE(HNS3_MAX_TSO_BD_NUM), \···7673#define HNS3_OUTER_VLAN_TAG 277747875#define HNS3_MIN_TX_LEN 33U7676+#define HNS3_MIN_TUN_PKT_LEN 65U79778078/* hns3_pci_tbl - PCI Device ID Table8179 *···14281424 l4.tcp->doff);14291425 break;14301426 case IPPROTO_UDP:14311431- if (hns3_tunnel_csum_bug(skb))14321432- return skb_checksum_help(skb);14271427+ if (hns3_tunnel_csum_bug(skb)) {14281428+ int ret = skb_put_padto(skb, HNS3_MIN_TUN_PKT_LEN);14291429+14301430+ return ret ? ret : skb_checksum_help(skb);14311431+ }1433143214341433 hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);14351434 hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4T_S,···47604753 goto out_with_desc_cb;4761475447624755 if (!HNAE3_IS_TX_RING(ring)) {47634763- hns3_alloc_page_pool(ring);47564756+ if (page_pool_enabled)47574757+ hns3_alloc_page_pool(ring);4764475847654759 ret = hns3_alloc_ring_buffers(ring);47664760 if (ret)
···15281528static int hclge_configure(struct hclge_dev *hdev)15291529{15301530 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);15311531+ const struct cpumask *cpumask = cpu_online_mask;15311532 struct hclge_cfg cfg;15321533 unsigned int i;15331533- int ret;15341534+ int node, ret;1534153515351536 ret = hclge_get_cfg(hdev, &cfg);15361537 if (ret)···1596159515971596 hclge_init_kdump_kernel_config(hdev);1598159715991599- /* Set the init affinity based on pci func number */16001600- i = cpumask_weight(cpumask_of_node(dev_to_node(&hdev->pdev->dev)));16011601- i = i ? PCI_FUNC(hdev->pdev->devfn) % i : 0;16021602- cpumask_set_cpu(cpumask_local_spread(i, dev_to_node(&hdev->pdev->dev)),16031603- &hdev->affinity_mask);15981598+ /* Set the affinity based on numa node */15991599+ node = dev_to_node(&hdev->pdev->dev);16001600+ if (node != NUMA_NO_NODE)16011601+ cpumask = cpumask_of_node(node);16021602+16031603+ cpumask_copy(&hdev->affinity_mask, cpumask);1604160416051605 return ret;16061606}···81278125 hclge_clear_arfs_rules(hdev);81288126 spin_unlock_bh(&hdev->fd_rule_lock);8129812781308130- /* If it is not PF reset, the firmware will disable the MAC,81288128+ /* If it is not PF reset or FLR, the firmware will disable the MAC,81318129 * so it only need to stop phy here.81328130 */81338131 if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) &&81348134- hdev->reset_type != HNAE3_FUNC_RESET) {81328132+ hdev->reset_type != HNAE3_FUNC_RESET &&81338133+ hdev->reset_type != HNAE3_FLR_RESET) {81358134 hclge_mac_stop_phy(hdev);81368135 hclge_update_link_status(hdev);81378136 return;
···271271 struct auxiliary_device *adev;272272 int ret;273273274274+ /* if this PF doesn't support a technology that requires auxiliary275275+ * devices, then gracefully exit276276+ */277277+ if (!ice_is_aux_ena(pf))278278+ return 0;279279+274280 iadev = kzalloc(sizeof(*iadev), GFP_KERNEL);275281 if (!iadev)276282 return -ENOMEM;
···300300{301301 struct mlx5e_rep_indr_block_priv *cb_priv;302302303303- /* All callback list access should be protected by RTNL. */304304- ASSERT_RTNL();305305-306303 list_for_each_entry(cb_priv,307304 &rpriv->uplink_priv.tc_indr_block_priv_list,308305 list)
···142142 err = mlxbf_gige_clean_port(priv);143143 if (err)144144 goto free_irqs;145145+146146+ /* Clear driver's valid_polarity to match hardware,147147+ * since the above call to clean_port() resets the148148+ * receive polarity used by hardware.149149+ */150150+ priv->valid_polarity = 0;151151+145152 err = mlxbf_gige_rx_init(priv);146153 if (err)147154 goto free_irqs;
···17671767 struct nfp_flower_indr_block_cb_priv *cb_priv;17681768 struct nfp_flower_priv *priv = app->priv;1769176917701770- /* All callback list access should be protected by RTNL. */17711771- ASSERT_RTNL();17721772-17731770 list_for_each_entry(cb_priv, &priv->indr_block_cb_priv, list)17741771 if (cb_priv->netdev == netdev)17751772 return cb_priv;
+5-1
drivers/net/ethernet/qlogic/qed/qed_mcp.c
···33673367 struct qed_nvm_image_att *p_image_att)33683368{33693369 enum nvm_image_type type;33703370+ int rc;33703371 u32 i;3371337233723373 /* Translate image_id into MFW definitions */···33963395 return -EINVAL;33973396 }3398339733993399- qed_mcp_nvm_info_populate(p_hwfn);33983398+ rc = qed_mcp_nvm_info_populate(p_hwfn);33993399+ if (rc)34003400+ return rc;34013401+34003402 for (i = 0; i < p_hwfn->nvm_info.num_images; i++)34013403 if (type == p_hwfn->nvm_info.image_att[i].image_type)34023404 break;
···166166 * We need a channel per event queue, plus a VI per tx queue.167167 * This may be more pessimistic than it needs to be.168168 */169169- if (n_channels + n_xdp_ev > max_channels) {170170- netif_err(efx, drv, efx->net_dev,171171- "Insufficient resources for %d XDP event queues (%d other channels, max %d)\n",172172- n_xdp_ev, n_channels, max_channels);173173- netif_err(efx, drv, efx->net_dev,174174- "XDP_TX and XDP_REDIRECT will not work on this interface");175175- efx->n_xdp_channels = 0;176176- efx->xdp_tx_per_channel = 0;177177- efx->xdp_tx_queue_count = 0;169169+ if (n_channels >= max_channels) {170170+ efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;171171+ netif_warn(efx, drv, efx->net_dev,172172+ "Insufficient resources for %d XDP event queues (%d other channels, max %d)\n",173173+ n_xdp_ev, n_channels, max_channels);174174+ netif_warn(efx, drv, efx->net_dev,175175+ "XDP_TX and XDP_REDIRECT might decrease device's performance\n");178176 } else if (n_channels + n_xdp_tx > efx->max_vis) {179179- netif_err(efx, drv, efx->net_dev,180180- "Insufficient resources for %d XDP TX queues (%d other channels, max VIs %d)\n",181181- n_xdp_tx, n_channels, efx->max_vis);182182- netif_err(efx, drv, efx->net_dev,183183- "XDP_TX and XDP_REDIRECT will not work on this interface");184184- efx->n_xdp_channels = 0;185185- efx->xdp_tx_per_channel = 0;186186- efx->xdp_tx_queue_count = 0;177177+ efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;178178+ netif_warn(efx, drv, efx->net_dev,179179+ "Insufficient resources for %d XDP TX queues (%d other channels, max VIs %d)\n",180180+ n_xdp_tx, n_channels, efx->max_vis);181181+ netif_warn(efx, drv, efx->net_dev,182182+ "XDP_TX and XDP_REDIRECT might decrease device's performance\n");183183+ } else if (n_channels + n_xdp_ev > max_channels) {184184+ efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_SHARED;185185+ netif_warn(efx, drv, efx->net_dev,186186+ "Insufficient resources for %d XDP event queues (%d other channels, max %d)\n",187187+ n_xdp_ev, n_channels, max_channels);188188+189189+ n_xdp_ev = max_channels - n_channels;190190+ netif_warn(efx, drv, efx->net_dev,191191+ "XDP_TX and XDP_REDIRECT will work with reduced performance (%d cpus/tx_queue)\n",192192+ DIV_ROUND_UP(n_xdp_tx, tx_per_ev * n_xdp_ev));187193 } else {194194+ efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_DEDICATED;195195+ }196196+197197+ if (efx->xdp_txq_queues_mode != EFX_XDP_TX_QUEUES_BORROWED) {188198 efx->n_xdp_channels = n_xdp_ev;189199 efx->xdp_tx_per_channel = tx_per_ev;190200 efx->xdp_tx_queue_count = n_xdp_tx;191201 n_channels += n_xdp_ev;192202 netif_dbg(efx, drv, efx->net_dev,193203 "Allocating %d TX and %d event queues for XDP\n",194194- n_xdp_tx, n_xdp_ev);204204+ n_xdp_ev * tx_per_ev, n_xdp_ev);205205+ } else {206206+ efx->n_xdp_channels = 0;207207+ efx->xdp_tx_per_channel = 0;208208+ efx->xdp_tx_queue_count = n_xdp_tx;195209 }196210197211 if (vec_count < n_channels) {···872858 goto out;873859}874860861861+static inline int862862+efx_set_xdp_tx_queue(struct efx_nic *efx, int xdp_queue_number,863863+ struct efx_tx_queue *tx_queue)864864+{865865+ if (xdp_queue_number >= efx->xdp_tx_queue_count)866866+ return -EINVAL;867867+868868+ netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n",869869+ tx_queue->channel->channel, tx_queue->label,870870+ xdp_queue_number, tx_queue->queue);871871+ efx->xdp_tx_queues[xdp_queue_number] = tx_queue;872872+ return 0;873873+}874874+875875int efx_set_channels(struct efx_nic *efx)876876{877877 struct efx_tx_queue *tx_queue;···924896 if (efx_channel_is_xdp_tx(channel)) {925897 efx_for_each_channel_tx_queue(tx_queue, channel) {926898 tx_queue->queue = next_queue++;927927-928928- /* We may have a few left-over XDP TX929929- * queues owing to xdp_tx_queue_count930930- * not dividing evenly by EFX_MAX_TXQ_PER_CHANNEL.931931- * We still allocate and probe those932932- * TXQs, but never use them.933933- */934934- if (xdp_queue_number < efx->xdp_tx_queue_count) {935935- netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n",936936- channel->channel, tx_queue->label,937937- xdp_queue_number, tx_queue->queue);938938- efx->xdp_tx_queues[xdp_queue_number] = tx_queue;899899+ rc = efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue);900900+ if (rc == 0)939901 xdp_queue_number++;940940- }941902 }942903 } else {943904 efx_for_each_channel_tx_queue(tx_queue, channel) {···935918 channel->channel, tx_queue->label,936919 tx_queue->queue);937920 }921921+922922+ /* If XDP is borrowing queues from net stack, it must use the queue923923+ * with no csum offload, which is the first one of the channel924924+ * (note: channel->tx_queue_by_type is not initialized yet)925925+ */926926+ if (efx->xdp_txq_queues_mode == EFX_XDP_TX_QUEUES_BORROWED) {927927+ tx_queue = &channel->tx_queue[0];928928+ rc = efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue);929929+ if (rc == 0)930930+ xdp_queue_number++;931931+ }938932 }939933 }940934 }941941- WARN_ON(xdp_queue_number != efx->xdp_tx_queue_count);935935+ WARN_ON(efx->xdp_txq_queues_mode == EFX_XDP_TX_QUEUES_DEDICATED &&936936+ xdp_queue_number != efx->xdp_tx_queue_count);937937+ WARN_ON(efx->xdp_txq_queues_mode != EFX_XDP_TX_QUEUES_DEDICATED &&938938+ xdp_queue_number > efx->xdp_tx_queue_count);939939+940940+ /* If we have more CPUs than assigned XDP TX queues, assign the already941941+ * existing queues to the exceeding CPUs942942+ */943943+ next_queue = 0;944944+ while (xdp_queue_number < efx->xdp_tx_queue_count) {945945+ tx_queue = efx->xdp_tx_queues[next_queue++];946946+ rc = efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue);947947+ if (rc == 0)948948+ xdp_queue_number++;949949+ }942950943951 rc = netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels);944952 if (rc)
+8
drivers/net/ethernet/sfc/net_driver.h
···782782#define EFX_RPS_MAX_IN_FLIGHT 8783783#endif /* CONFIG_RFS_ACCEL */784784785785+enum efx_xdp_tx_queues_mode {786786+ EFX_XDP_TX_QUEUES_DEDICATED, /* one queue per core, locking not needed */787787+ EFX_XDP_TX_QUEUES_SHARED, /* each queue used by more than 1 core */788788+ EFX_XDP_TX_QUEUES_BORROWED /* queues borrowed from net stack */789789+};790790+785791/**786792 * struct efx_nic - an Efx NIC787793 * @name: Device name (net device name or bus id before net device registered)···826820 * should be allocated for this NIC827821 * @xdp_tx_queue_count: Number of entries in %xdp_tx_queues.828822 * @xdp_tx_queues: Array of pointers to tx queues used for XDP transmit.823823+ * @xdp_txq_queues_mode: XDP TX queues sharing strategy.829824 * @rxq_entries: Size of receive queues requested by user.830825 * @txq_entries: Size of transmit queues requested by user.831826 * @txq_stop_thresh: TX queue fill level at or above which we stop it.···986979987980 unsigned int xdp_tx_queue_count;988981 struct efx_tx_queue **xdp_tx_queues;982982+ enum efx_xdp_tx_queues_mode xdp_txq_queues_mode;989983990984 unsigned rxq_entries;991985 unsigned txq_entries;
+21-8
drivers/net/ethernet/sfc/tx.c
···428428 unsigned int len;429429 int space;430430 int cpu;431431- int i;431431+ int i = 0;432432+433433+ if (unlikely(n && !xdpfs))434434+ return -EINVAL;435435+ if (unlikely(!n))436436+ return 0;432437433438 cpu = raw_smp_processor_id();434434-435435- if (!efx->xdp_tx_queue_count ||436436- unlikely(cpu >= efx->xdp_tx_queue_count))439439+ if (unlikely(cpu >= efx->xdp_tx_queue_count))437440 return -EINVAL;438441439442 tx_queue = efx->xdp_tx_queues[cpu];440443 if (unlikely(!tx_queue))441444 return -EINVAL;442445443443- if (unlikely(n && !xdpfs))444444- return -EINVAL;446446+ if (efx->xdp_txq_queues_mode != EFX_XDP_TX_QUEUES_DEDICATED)447447+ HARD_TX_LOCK(efx->net_dev, tx_queue->core_txq, cpu);445448446446- if (!n)447447- return 0;449449+ /* If we're borrowing net stack queues we have to handle stop-restart450450+ * or we might block the queue and it will be considered as frozen451451+ */452452+ if (efx->xdp_txq_queues_mode == EFX_XDP_TX_QUEUES_BORROWED) {453453+ if (netif_tx_queue_stopped(tx_queue->core_txq))454454+ goto unlock;455455+ efx_tx_maybe_stop_queue(tx_queue);456456+ }448457449458 /* Check for available space. We should never need multiple450459 * descriptors per frame.···492483 /* Pass mapped frames to hardware. */493484 if (flush && i > 0)494485 efx_nic_push_buffers(tx_queue);486486+487487+unlock:488488+ if (efx->xdp_txq_queues_mode != EFX_XDP_TX_QUEUES_DEDICATED)489489+ HARD_TX_UNLOCK(efx->net_dev, tx_queue->core_txq);495490496491 return i == 0 ? -EIO : i;497492}
+1-15
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
···309309 priv->clk_csr = STMMAC_CSR_100_150M;310310 else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M))311311 priv->clk_csr = STMMAC_CSR_150_250M;312312- else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M))312312+ else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M))313313 priv->clk_csr = STMMAC_CSR_250_300M;314314 }315315···71187118 struct net_device *ndev = dev_get_drvdata(dev);71197119 struct stmmac_priv *priv = netdev_priv(ndev);71207120 u32 chan;71217121- int ret;7122712171237122 if (!ndev || !netif_running(ndev))71247123 return 0;···71497150 } else {71507151 stmmac_mac_set(priv, priv->ioaddr, false);71517152 pinctrl_pm_select_sleep_state(priv->device);71527152- /* Disable clock in case of PWM is off */71537153- clk_disable_unprepare(priv->plat->clk_ptp_ref);71547154- ret = pm_runtime_force_suspend(dev);71557155- if (ret) {71567156- mutex_unlock(&priv->lock);71577157- return ret;71587158- }71597153 }7160715471617155 mutex_unlock(&priv->lock);···72347242 priv->irq_wake = 0;72357243 } else {72367244 pinctrl_pm_select_default_state(priv->device);72377237- /* enable the clk previously disabled */72387238- ret = pm_runtime_force_resume(dev);72397239- if (ret)72407240- return ret;72417241- if (priv->plat->clk_ptp_ref)72427242- clk_prepare_enable(priv->plat->clk_ptp_ref);72437245 /* reset the phy so that it's ready */72447246 if (priv->mii)72457247 stmmac_mdio_reset(priv->mii);
···99*******************************************************************************/10101111#include <linux/platform_device.h>1212+#include <linux/pm_runtime.h>1213#include <linux/module.h>1314#include <linux/io.h>1415#include <linux/of.h>···772771 return stmmac_bus_clks_config(priv, true);773772}774773774774+static int __maybe_unused stmmac_pltfr_noirq_suspend(struct device *dev)775775+{776776+ struct net_device *ndev = dev_get_drvdata(dev);777777+ struct stmmac_priv *priv = netdev_priv(ndev);778778+ int ret;779779+780780+ if (!netif_running(ndev))781781+ return 0;782782+783783+ if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {784784+ /* Disable clock in case of PWM is off */785785+ clk_disable_unprepare(priv->plat->clk_ptp_ref);786786+787787+ ret = pm_runtime_force_suspend(dev);788788+ if (ret)789789+ return ret;790790+ }791791+792792+ return 0;793793+}794794+795795+static int __maybe_unused stmmac_pltfr_noirq_resume(struct device *dev)796796+{797797+ struct net_device *ndev = dev_get_drvdata(dev);798798+ struct stmmac_priv *priv = netdev_priv(ndev);799799+ int ret;800800+801801+ if (!netif_running(ndev))802802+ return 0;803803+804804+ if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {805805+ /* enable the clk previously disabled */806806+ ret = pm_runtime_force_resume(dev);807807+ if (ret)808808+ return ret;809809+810810+ clk_prepare_enable(priv->plat->clk_ptp_ref);811811+ }812812+813813+ return 0;814814+}815815+775816const struct dev_pm_ops stmmac_pltfr_pm_ops = {776817 SET_SYSTEM_SLEEP_PM_OPS(stmmac_pltfr_suspend, stmmac_pltfr_resume)777818 SET_RUNTIME_PM_OPS(stmmac_runtime_suspend, stmmac_runtime_resume, NULL)819819+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(stmmac_pltfr_noirq_suspend, stmmac_pltfr_noirq_resume)778820};779821EXPORT_SYMBOL_GPL(stmmac_pltfr_pm_ops);780822
+2-2
drivers/net/hamradio/6pack.c
···6868#define SIXP_DAMA_OFF 069697070/* default level 2 parameters */7171-#define SIXP_TXDELAY (HZ/4) /* in 1 s */7171+#define SIXP_TXDELAY 25 /* 250 ms */7272#define SIXP_PERSIST 50 /* in 256ths */7373-#define SIXP_SLOTTIME (HZ/10) /* in 1 s */7373+#define SIXP_SLOTTIME 10 /* 100 ms */7474#define SIXP_INIT_RESYNC_TIMEOUT (3*HZ/2) /* in 1 s */7575#define SIXP_RESYNC_TIMEOUT 5*HZ /* in 1 s */7676
···430430 * table region determines the number of entries it has.431431 */432432 if (filter) {433433- count = hweight32(ipa->filter_map);433433+ /* Include one extra "slot" to hold the filter map itself */434434+ count = 1 + hweight32(ipa->filter_map);434435 hash_count = hash_mem->size ? count : 0;435436 } else {436437 count = mem->size / sizeof(__le64);
···233233234234static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)235235{236236+ struct device_driver *drv = phydev->mdio.dev.driver;237237+ struct phy_driver *phydrv = to_phy_driver(drv);236238 struct net_device *netdev = phydev->attached_dev;237239238238- if (!phydev->drv->suspend)240240+ if (!drv || !phydrv->suspend)239241 return false;240242241243 /* PHY not attached? May suspend if the PHY has not already been
+29-1
drivers/net/phy/phylink.c
···16071607 if (config.an_enabled && phylink_is_empty_linkmode(config.advertising))16081608 return -EINVAL;1609160916101610+ /* If this link is with an SFP, ensure that changes to advertised modes16111611+ * also cause the associated interface to be selected such that the16121612+ * link can be configured correctly.16131613+ */16141614+ if (pl->sfp_port && pl->sfp_bus) {16151615+ config.interface = sfp_select_interface(pl->sfp_bus,16161616+ config.advertising);16171617+ if (config.interface == PHY_INTERFACE_MODE_NA) {16181618+ phylink_err(pl,16191619+ "selection of interface failed, advertisement %*pb\n",16201620+ __ETHTOOL_LINK_MODE_MASK_NBITS,16211621+ config.advertising);16221622+ return -EINVAL;16231623+ }16241624+16251625+ /* Revalidate with the selected interface */16261626+ linkmode_copy(support, pl->supported);16271627+ if (phylink_validate(pl, support, &config)) {16281628+ phylink_err(pl, "validation of %s/%s with support %*pb failed\n",16291629+ phylink_an_mode_str(pl->cur_link_an_mode),16301630+ phy_modes(config.interface),16311631+ __ETHTOOL_LINK_MODE_MASK_NBITS, support);16321632+ return -EINVAL;16331633+ }16341634+ }16351635+16101636 mutex_lock(&pl->state_mutex);16111637 pl->link_config.speed = config.speed;16121638 pl->link_config.duplex = config.duplex;···22122186 if (phy_interface_mode_is_8023z(iface) && pl->phydev)22132187 return -EINVAL;2214218822152215- changed = !linkmode_equal(pl->supported, support);21892189+ changed = !linkmode_equal(pl->supported, support) ||21902190+ !linkmode_equal(pl->link_config.advertising,21912191+ config.advertising);22162192 if (changed) {22172193 linkmode_copy(pl->supported, support);22182194 linkmode_copy(pl->link_config.advertising, config.advertising);
···8585 break;8686 }87878888- if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i))8888+ /*8989+ * Attempt to initialize a restricted-dma-pool region if one was found.9090+ * Note that count can hold a negative error code.9191+ */9292+ if (i < count && of_reserved_mem_device_init_by_idx(dev, of_node, i))8993 dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n");9094}9195
···937937938938void pci_set_acpi_fwnode(struct pci_dev *dev)939939{940940- if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))940940+ if (!dev_fwnode(&dev->dev) && !pci_dev_is_added(dev))941941 ACPI_COMPANION_SET(&dev->dev,942942 acpi_pci_find_companion(&dev->dev));943943}
+7-2
drivers/pci/quirks.c
···54355435 PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda);5436543654375437/*54385438- * Create device link for NVIDIA GPU with integrated USB xHCI Host54385438+ * Create device link for GPUs with integrated USB xHCI Host54395439 * controller to VGA.54405440 */54415441static void quirk_gpu_usb(struct pci_dev *usb)···54445444}54455445DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,54465446 PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb);54475447+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID,54485448+ PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb);5447544954485450/*54495449- * Create device link for NVIDIA GPU with integrated Type-C UCSI controller54515451+ * Create device link for GPUs with integrated Type-C UCSI controller54505452 * to VGA. Currently there is no class code defined for UCSI device over PCI54515453 * so using UNKNOWN class for now and it will be updated when UCSI54525454 * over PCI gets a class code.···54595457 pci_create_device_link(ucsi, 3, 0, PCI_BASE_CLASS_DISPLAY, 16);54605458}54615459DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,54605460+ PCI_CLASS_SERIAL_UNKNOWN, 8,54615461+ quirk_gpu_usb_typec_ucsi);54625462+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID,54625463 PCI_CLASS_SERIAL_UNKNOWN, 8,54635464 quirk_gpu_usb_typec_ucsi);54645465
+26-10
drivers/pci/vpd.c
···9999 return off ?: PCI_VPD_SZ_INVALID;100100}101101102102+static bool pci_vpd_available(struct pci_dev *dev)103103+{104104+ struct pci_vpd *vpd = &dev->vpd;105105+106106+ if (!vpd->cap)107107+ return false;108108+109109+ if (vpd->len == 0) {110110+ vpd->len = pci_vpd_size(dev);111111+ if (vpd->len == PCI_VPD_SZ_INVALID) {112112+ vpd->cap = 0;113113+ return false;114114+ }115115+ }116116+117117+ return true;118118+}119119+102120/*103121 * Wait for last operation to complete.104122 * This code has to spin since there is no other notification from the PCI···163145 loff_t end = pos + count;164146 u8 *buf = arg;165147166166- if (!vpd->cap)148148+ if (!pci_vpd_available(dev))167149 return -ENODEV;168150169151 if (pos < 0)···224206 loff_t end = pos + count;225207 int ret = 0;226208227227- if (!vpd->cap)209209+ if (!pci_vpd_available(dev))228210 return -ENODEV;229211230212 if (pos < 0 || (pos & 3) || (count & 3))···260242261243void pci_vpd_init(struct pci_dev *dev)262244{245245+ if (dev->vpd.len == PCI_VPD_SZ_INVALID)246246+ return;247247+263248 dev->vpd.cap = pci_find_capability(dev, PCI_CAP_ID_VPD);264249 mutex_init(&dev->vpd.lock);265265-266266- if (!dev->vpd.len)267267- dev->vpd.len = pci_vpd_size(dev);268268-269269- if (dev->vpd.len == PCI_VPD_SZ_INVALID)270270- dev->vpd.cap = 0;271250}272251273252static ssize_t vpd_read(struct file *filp, struct kobject *kobj,···309294310295void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size)311296{312312- unsigned int len = dev->vpd.len;297297+ unsigned int len;313298 void *buf;314299 int cnt;315300316316- if (!dev->vpd.cap)301301+ if (!pci_vpd_available(dev))317302 return ERR_PTR(-ENODEV);318303304304+ len = dev->vpd.len;319305 buf = kmalloc(len, GFP_KERNEL);320306 if (!buf)321307 return ERR_PTR(-ENOMEM);
···213213 * ap_init_qci_info(): Allocate and query qci config info.214214 * Does also update the static variables ap_max_domain_id215215 * and ap_max_adapter_id if this info is available.216216-217216 */218217static void __init ap_init_qci_info(void)219218{···438439/**439440 * ap_interrupt_handler() - Schedule ap_tasklet on interrupt440441 * @airq: pointer to adapter interrupt descriptor442442+ * @floating: ignored441443 */442444static void ap_interrupt_handler(struct airq_struct *airq, bool floating)443445{···17861786/**17871787 * ap_scan_bus(): Scan the AP bus for new devices17881788 * Runs periodically, workqueue timer (ap_config_time)17891789+ * @unused: Unused pointer.17891790 */17901791static void ap_scan_bus(struct work_struct *unused)17911792{
+2-2
drivers/s390/crypto/ap_queue.c
···20202121/**2222 * ap_queue_enable_irq(): Enable interrupt support on this AP queue.2323- * @qid: The AP queue number2323+ * @aq: The AP queue2424 * @ind: the notification indicator byte2525 *2626 * Enables interruption on AP queue via ap_aqic(). Based on the return···311311312312/**313313 * ap_sm_reset(): Reset an AP queue.314314- * @qid: The AP queue number314314+ * @aq: The AP queue315315 *316316 * Submit the Reset command to an AP queue.317317 */
···467467 .num = nvq->batched_xdp,468468 .ptr = nvq->xdp,469469 };470470- int err;470470+ int i, err;471471472472 if (nvq->batched_xdp == 0)473473 goto signal_used;···476476 err = sock->ops->sendmsg(sock, msghdr, 0);477477 if (unlikely(err < 0)) {478478 vq_err(&nvq->vq, "Fail to batch sending packets\n");479479+480480+ /* free pages owned by XDP; since this is an unlikely error path,481481+ * keep it simple and avoid more complex bulk update for the482482+ * used pages483483+ */484484+ for (i = 0; i < nvq->batched_xdp; ++i)485485+ put_page(virt_to_head_page(nvq->xdp[i].data));486486+ nvq->batched_xdp = 0;487487+ nvq->done_idx = 0;479488 return;480489 }481490
+3-1
drivers/video/fbdev/Kconfig
···582582583583config FB_TGA584584 tristate "TGA/SFB+ framebuffer support"585585- depends on FB && (ALPHA || TC)585585+ depends on FB586586+ depends on PCI || TC587587+ depends on ALPHA || TC586588 select FB_CFB_FILLRECT587589 select FB_CFB_COPYAREA588590 select FB_CFB_IMAGEBLIT
···4343#include <linux/sched.h>4444#include <linux/cred.h>4545#include <linux/errno.h>4646+#include <linux/freezer.h>4747+#include <linux/kthread.h>4648#include <linux/mm.h>4749#include <linux/memblock.h>4850#include <linux/pagemap.h>···117115#define EXTENT_ORDER (fls(XEN_PFN_PER_PAGE) - 1)118116119117/*120120- * balloon_process() state:118118+ * balloon_thread() state:121119 *122120 * BP_DONE: done or nothing to do,123121 * BP_WAIT: wait to be rescheduled,···132130 BP_ECANCELED133131};134132133133+/* Main waiting point for xen-balloon thread. */134134+static DECLARE_WAIT_QUEUE_HEAD(balloon_thread_wq);135135136136static DEFINE_MUTEX(balloon_mutex);137137···147143/* List of ballooned pages, threaded through the mem_map array. */148144static LIST_HEAD(ballooned_pages);149145static DECLARE_WAIT_QUEUE_HEAD(balloon_wq);150150-151151-/* Main work function, always executed in process context. */152152-static void balloon_process(struct work_struct *work);153153-static DECLARE_DELAYED_WORK(balloon_worker, balloon_process);154146155147/* When ballooning out (allocating memory to return to Xen) we don't really156148 want the kernel to try too hard since that can trigger the oom killer. */···366366static int xen_memory_notifier(struct notifier_block *nb, unsigned long val, void *v)367367{368368 if (val == MEM_ONLINE)369369- schedule_delayed_work(&balloon_worker, 0);369369+ wake_up(&balloon_thread_wq);370370371371 return NOTIFY_OK;372372}···491491}492492493493/*494494- * As this is a work item it is guaranteed to run as a single instance only.494494+ * Stop waiting if either state is not BP_EAGAIN and ballooning action is495495+ * needed, or if the credit has changed while state is BP_EAGAIN.496496+ */497497+static bool balloon_thread_cond(enum bp_state state, long credit)498498+{499499+ if (state != BP_EAGAIN)500500+ credit = 0;501501+502502+ return current_credit() != credit || kthread_should_stop();503503+}504504+505505+/*506506+ * As this is a kthread it is guaranteed to run as a single instance only.495507 * We may of course race updates of the target counts (which are protected496508 * by the balloon lock), or with changes to the Xen hard limit, but we will497509 * recover from these in time.498510 */499499-static void balloon_process(struct work_struct *work)511511+static int balloon_thread(void *unused)500512{501513 enum bp_state state = BP_DONE;502514 long credit;515515+ unsigned long timeout;503516517517+ set_freezable();518518+ for (;;) {519519+ if (state == BP_EAGAIN)520520+ timeout = balloon_stats.schedule_delay * HZ;521521+ else522522+ timeout = 3600 * HZ;523523+ credit = current_credit();504524505505- do {525525+ wait_event_interruptible_timeout(balloon_thread_wq,526526+ balloon_thread_cond(state, credit), timeout);527527+528528+ if (kthread_should_stop())529529+ return 0;530530+506531 mutex_lock(&balloon_mutex);507532508533 credit = current_credit();···554529 mutex_unlock(&balloon_mutex);555530556531 cond_resched();557557-558558- } while (credit && state == BP_DONE);559559-560560- /* Schedule more work if there is some still to be done. */561561- if (state == BP_EAGAIN)562562- schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ);532532+ }563533}564534565535/* Resets the Xen limit, sets new target, and kicks off processing. */···562542{563543 /* No need for lock. Not read-modify-write updates. */564544 balloon_stats.target_pages = target;565565- schedule_delayed_work(&balloon_worker, 0);545545+ wake_up(&balloon_thread_wq);566546}567547EXPORT_SYMBOL_GPL(balloon_set_new_target);568548···667647668648 /* The balloon may be too large now. Shrink it if needed. */669649 if (current_credit())670670- schedule_delayed_work(&balloon_worker, 0);650650+ wake_up(&balloon_thread_wq);671651672652 mutex_unlock(&balloon_mutex);673653}···699679700680static int __init balloon_init(void)701681{682682+ struct task_struct *task;683683+702684 if (!xen_domain())703685 return -ENODEV;704686···743721 xen_extra_mem[i].n_pfns);744722 }745723#endif724724+725725+ task = kthread_run(balloon_thread, NULL, "xen-balloon");726726+ if (IS_ERR(task)) {727727+ pr_err("xen-balloon thread could not be started, ballooning will not work!\n");728728+ return PTR_ERR(task);729729+ }746730747731 /* Init the xen-balloon driver. */748732 xen_balloon_init();
+17-20
drivers/xen/swiotlb-xen.c
···106106107107static int xen_swiotlb_fixup(void *buf, unsigned long nslabs)108108{109109- int i, rc;110110- int dma_bits;109109+ int rc;110110+ unsigned int order = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT);111111+ unsigned int i, dma_bits = order + PAGE_SHIFT;111112 dma_addr_t dma_handle;112113 phys_addr_t p = virt_to_phys(buf);113114114114- dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;115115+ BUILD_BUG_ON(IO_TLB_SEGSIZE & (IO_TLB_SEGSIZE - 1));116116+ BUG_ON(nslabs % IO_TLB_SEGSIZE);115117116118 i = 0;117119 do {118118- int slabs = min(nslabs - i, (unsigned long)IO_TLB_SEGSIZE);119119-120120 do {121121 rc = xen_create_contiguous_region(122122- p + (i << IO_TLB_SHIFT),123123- get_order(slabs << IO_TLB_SHIFT),122122+ p + (i << IO_TLB_SHIFT), order,124123 dma_bits, &dma_handle);125124 } while (rc && dma_bits++ < MAX_DMA_BITS);126125 if (rc)127126 return rc;128127129129- i += slabs;128128+ i += IO_TLB_SEGSIZE;130129 } while (i < nslabs);131130 return 0;132131}···152153 return "";153154}154155155155-#define DEFAULT_NSLABS ALIGN(SZ_64M >> IO_TLB_SHIFT, IO_TLB_SEGSIZE)156156-157157-int __ref xen_swiotlb_init(void)156156+int xen_swiotlb_init(void)158157{159158 enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN;160159 unsigned long bytes = swiotlb_size_or_default();···182185 order--;183186 }184187 if (!start)185185- goto error;188188+ goto exit;186189 if (order != get_order(bytes)) {187190 pr_warn("Warning: only able to allocate %ld MB for software IO TLB\n",188191 (PAGE_SIZE << order) >> 20);···205208 swiotlb_set_max_segment(PAGE_SIZE);206209 return 0;207210error:208208- if (repeat--) {211211+ if (nslabs > 1024 && repeat--) {209212 /* Min is 2MB */210210- nslabs = max(1024UL, (nslabs >> 1));211211- pr_info("Lowering to %luMB\n",212212- (nslabs << IO_TLB_SHIFT) >> 20);213213+ nslabs = max(1024UL, ALIGN(nslabs >> 1, IO_TLB_SEGSIZE));214214+ bytes = nslabs << IO_TLB_SHIFT;215215+ pr_info("Lowering to %luMB\n", bytes >> 20);213216 goto retry;214217 }218218+exit:215219 pr_err("%s (rc:%d)\n", xen_swiotlb_error(m_ret), rc);216216- free_pages((unsigned long)start, order);217220 return rc;218221}219222···241244 rc = xen_swiotlb_fixup(start, nslabs);242245 if (rc) {243246 memblock_free(__pa(start), PAGE_ALIGN(bytes));244244- if (repeat--) {247247+ if (nslabs > 1024 && repeat--) {245248 /* Min is 2MB */246246- nslabs = max(1024UL, (nslabs >> 1));249249+ nslabs = max(1024UL, ALIGN(nslabs >> 1, IO_TLB_SEGSIZE));247250 bytes = nslabs << IO_TLB_SHIFT;248251 pr_info("Lowering to %luMB\n", bytes >> 20);249252 goto retry;···251254 panic("%s (rc:%d)", xen_swiotlb_error(XEN_SWIOTLB_EFIXUP), rc);252255 }253256254254- if (swiotlb_init_with_tbl(start, nslabs, false))257257+ if (swiotlb_init_with_tbl(start, nslabs, true))255258 panic("Cannot allocate SWIOTLB buffer");256259 swiotlb_set_max_segment(PAGE_SIZE);257260}
+13-14
fs/io-wq.c
···1414#include <linux/rculist_nulls.h>1515#include <linux/cpu.h>1616#include <linux/tracehook.h>1717+#include <uapi/linux/io_uring.h>17181819#include "io-wq.h"1920···177176static void io_worker_exit(struct io_worker *worker)178177{179178 struct io_wqe *wqe = worker->wqe;180180- struct io_wqe_acct *acct = io_wqe_get_acct(worker);181179182180 if (refcount_dec_and_test(&worker->ref))183181 complete(&worker->ref_done);···186186 if (worker->flags & IO_WORKER_F_FREE)187187 hlist_nulls_del_rcu(&worker->nulls_node);188188 list_del_rcu(&worker->all_list);189189- acct->nr_workers--;190189 preempt_disable();191190 io_wqe_dec_running(worker);192191 worker->flags = 0;···245246 */246247static bool io_wqe_create_worker(struct io_wqe *wqe, struct io_wqe_acct *acct)247248{248248- bool do_create = false;249249-250249 /*251250 * Most likely an attempt to queue unbounded work on an io_wq that252251 * wasn't setup with any unbounded workers.···253256 pr_warn_once("io-wq is not configured for unbound workers");254257255258 raw_spin_lock(&wqe->lock);256256- if (acct->nr_workers < acct->max_workers) {257257- acct->nr_workers++;258258- do_create = true;259259+ if (acct->nr_workers == acct->max_workers) {260260+ raw_spin_unlock(&wqe->lock);261261+ return true;259262 }263263+ acct->nr_workers++;260264 raw_spin_unlock(&wqe->lock);261261- if (do_create) {262262- atomic_inc(&acct->nr_running);263263- atomic_inc(&wqe->wq->worker_refs);264264- return create_io_worker(wqe->wq, wqe, acct->index);265265- }266266-267267- return true;265265+ atomic_inc(&acct->nr_running);266266+ atomic_inc(&wqe->wq->worker_refs);267267+ return create_io_worker(wqe->wq, wqe, acct->index);268268}269269270270static void io_wqe_inc_running(struct io_worker *worker)···568574 }569575 /* timed out, exit unless we're the last worker */570576 if (last_timeout && acct->nr_workers > 1) {577577+ acct->nr_workers--;571578 raw_spin_unlock(&wqe->lock);572579 __set_current_state(TASK_RUNNING);573580 break;···12811286int io_wq_max_workers(struct io_wq *wq, int *new_count)12821287{12831288 int i, node, prev = 0;12891289+12901290+ BUILD_BUG_ON((int) IO_WQ_ACCT_BOUND != (int) IO_WQ_BOUND);12911291+ BUILD_BUG_ON((int) IO_WQ_ACCT_UNBOUND != (int) IO_WQ_UNBOUND);12921292+ BUILD_BUG_ON((int) IO_WQ_ACCT_NR != 2);1284129312851294 for (i = 0; i < 2; i++) {12861295 if (new_count[i] > task_rlimit(current, RLIMIT_NPROC))
+144-77
fs/io_uring.c
···712712 struct iovec fast_iov[UIO_FASTIOV];713713 const struct iovec *free_iovec;714714 struct iov_iter iter;715715+ struct iov_iter_state iter_state;715716 size_t bytes_done;716717 struct wait_page_queue wpq;717718};···736735 REQ_F_BUFFER_SELECTED_BIT,737736 REQ_F_COMPLETE_INLINE_BIT,738737 REQ_F_REISSUE_BIT,739739- REQ_F_DONT_REISSUE_BIT,740738 REQ_F_CREDS_BIT,741739 REQ_F_REFCOUNT_BIT,742740 REQ_F_ARM_LTIMEOUT_BIT,···782782 REQ_F_COMPLETE_INLINE = BIT(REQ_F_COMPLETE_INLINE_BIT),783783 /* caller should reissue async */784784 REQ_F_REISSUE = BIT(REQ_F_REISSUE_BIT),785785- /* don't attempt request reissue, see io_rw_reissue() */786786- REQ_F_DONT_REISSUE = BIT(REQ_F_DONT_REISSUE_BIT),787785 /* supports async reads */788786 REQ_F_NOWAIT_READ = BIT(REQ_F_NOWAIT_READ_BIT),789787 /* supports async writes */···24422444 req = list_first_entry(done, struct io_kiocb, inflight_entry);24432445 list_del(&req->inflight_entry);2444244624452445- if (READ_ONCE(req->result) == -EAGAIN &&24462446- !(req->flags & REQ_F_DONT_REISSUE)) {24472447- req->iopoll_completed = 0;24482448- io_req_task_queue_reissue(req);24492449- continue;24502450- }24512451-24522447 __io_cqring_fill_event(ctx, req->user_data, req->result,24532448 io_put_rw_kbuf(req));24542449 (*nr_events)++;···2604261326052614 if (!rw)26062615 return !io_req_prep_async(req);26072607- /* may have left rw->iter inconsistent on -EIOCBQUEUED */26082608- iov_iter_revert(&rw->iter, req->result - iov_iter_count(&rw->iter));26162616+ iov_iter_restore(&rw->iter, &rw->iter_state);26092617 return true;26102618}26112619···27042714 if (kiocb->ki_flags & IOCB_WRITE)27052715 kiocb_end_write(req);27062716 if (unlikely(res != req->result)) {27072707- if (!(res == -EAGAIN && io_rw_should_reissue(req) &&27082708- io_resubmit_prep(req))) {27092709- req_set_fail(req);27102710- req->flags |= REQ_F_DONT_REISSUE;27172717+ if (res == -EAGAIN && io_rw_should_reissue(req)) {27182718+ req->flags |= REQ_F_REISSUE;27192719+ return;27112720 }27122721 }27132722···28322843 return __io_file_supports_nowait(req->file, rw);28332844}2834284528352835-static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe)28462846+static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,28472847+ int rw)28362848{28372849 struct io_ring_ctx *ctx = req->ctx;28382850 struct kiocb *kiocb = &req->rw.kiocb;···28552865 if (unlikely(ret))28562866 return ret;2857286728582858- /* don't allow async punt for O_NONBLOCK or RWF_NOWAIT */28592859- if ((kiocb->ki_flags & IOCB_NOWAIT) || (file->f_flags & O_NONBLOCK))28682868+ /*28692869+ * If the file is marked O_NONBLOCK, still allow retry for it if it28702870+ * supports async. Otherwise it's impossible to use O_NONBLOCK files28712871+ * reliably. If not, or it IOCB_NOWAIT is set, don't retry.28722872+ */28732873+ if ((kiocb->ki_flags & IOCB_NOWAIT) ||28742874+ ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req, rw)))28602875 req->flags |= REQ_F_NOWAIT;2861287628622877 ioprio = READ_ONCE(sqe->ioprio);···29262931{29272932 struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);29282933 struct io_async_rw *io = req->async_data;29292929- bool check_reissue = kiocb->ki_complete == io_complete_rw;2930293429312935 /* add previously done IO, if any */29322936 if (io && io->bytes_done > 0) {···2937294329382944 if (req->flags & REQ_F_CUR_POS)29392945 req->file->f_pos = kiocb->ki_pos;29402940- if (ret >= 0 && check_reissue)29462946+ if (ret >= 0 && (kiocb->ki_complete == io_complete_rw))29412947 __io_complete_rw(req, ret, 0, issue_flags);29422948 else29432949 io_rw_done(kiocb, ret);2944295029452945- if (check_reissue && (req->flags & REQ_F_REISSUE)) {29512951+ if (req->flags & REQ_F_REISSUE) {29462952 req->flags &= ~REQ_F_REISSUE;29472953 if (io_resubmit_prep(req)) {29482954 io_req_task_queue_reissue(req);29492955 } else {29562956+ unsigned int cflags = io_put_rw_kbuf(req);29572957+ struct io_ring_ctx *ctx = req->ctx;29582958+29502959 req_set_fail(req);29512951- __io_req_complete(req, issue_flags, ret,29522952- io_put_rw_kbuf(req));29602960+ if (issue_flags & IO_URING_F_NONBLOCK) {29612961+ mutex_lock(&ctx->uring_lock);29622962+ __io_req_complete(req, issue_flags, ret, cflags);29632963+ mutex_unlock(&ctx->uring_lock);29642964+ } else {29652965+ __io_req_complete(req, issue_flags, ret, cflags);29662966+ }29532967 }29542968 }29552969}···32653263 ret = nr;32663264 break;32673265 }32663266+ if (!iov_iter_is_bvec(iter)) {32673267+ iov_iter_advance(iter, nr);32683268+ } else {32693269+ req->rw.len -= nr;32703270+ req->rw.addr += nr;32713271+ }32683272 ret += nr;32693273 if (nr != iovec.iov_len)32703274 break;32713271- req->rw.len -= nr;32723272- req->rw.addr += nr;32733273- iov_iter_advance(iter, nr);32743275 }3275327632763277 return ret;···33203315 if (!force && !io_op_defs[req->opcode].needs_async_setup)33213316 return 0;33223317 if (!req->async_data) {33183318+ struct io_async_rw *iorw;33193319+33233320 if (io_alloc_async_data(req)) {33243321 kfree(iovec);33253322 return -ENOMEM;33263323 }3327332433283325 io_req_map_rw(req, iovec, fast_iov, iter);33263326+ iorw = req->async_data;33273327+ /* we've copied and mapped the iter, ensure state is saved */33283328+ iov_iter_save_state(&iorw->iter, &iorw->iter_state);33293329 }33303330 return 0;33313331}···33493339 iorw->free_iovec = iov;33503340 if (iov)33513341 req->flags |= REQ_F_NEED_CLEANUP;33423342+ iov_iter_save_state(&iorw->iter, &iorw->iter_state);33523343 return 0;33533344}33543345···33573346{33583347 if (unlikely(!(req->file->f_mode & FMODE_READ)))33593348 return -EBADF;33603360- return io_prep_rw(req, sqe);33493349+ return io_prep_rw(req, sqe, READ);33613350}3362335133633352/*···34533442 struct kiocb *kiocb = &req->rw.kiocb;34543443 struct iov_iter __iter, *iter = &__iter;34553444 struct io_async_rw *rw = req->async_data;34563456- ssize_t io_size, ret, ret2;34573445 bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;34463446+ struct iov_iter_state __state, *state;34473447+ ssize_t ret, ret2;3458344834593449 if (rw) {34603450 iter = &rw->iter;34513451+ state = &rw->iter_state;34523452+ /*34533453+ * We come here from an earlier attempt, restore our state to34543454+ * match in case it doesn't. It's cheap enough that we don't34553455+ * need to make this conditional.34563456+ */34573457+ iov_iter_restore(iter, state);34613458 iovec = NULL;34623459 } else {34633460 ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock);34643461 if (ret < 0)34653462 return ret;34633463+ state = &__state;34643464+ iov_iter_save_state(iter, state);34663465 }34673467- io_size = iov_iter_count(iter);34683468- req->result = io_size;34663466+ req->result = iov_iter_count(iter);3469346734703468 /* Ensure we clear previously set non-block flag */34713469 if (!force_nonblock)···34883468 return ret ?: -EAGAIN;34893469 }3490347034913491- ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size);34713471+ ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), req->result);34923472 if (unlikely(ret)) {34933473 kfree(iovec);34943474 return ret;···35043484 /* no retry on NONBLOCK nor RWF_NOWAIT */35053485 if (req->flags & REQ_F_NOWAIT)35063486 goto done;35073507- /* some cases will consume bytes even on error returns */35083508- iov_iter_reexpand(iter, iter->count + iter->truncated);35093509- iov_iter_revert(iter, io_size - iov_iter_count(iter));35103487 ret = 0;35113488 } else if (ret == -EIOCBQUEUED) {35123489 goto out_free;35133513- } else if (ret <= 0 || ret == io_size || !force_nonblock ||34903490+ } else if (ret <= 0 || ret == req->result || !force_nonblock ||35143491 (req->flags & REQ_F_NOWAIT) || !need_read_all(req)) {35153492 /* read all, failed, already did sync or don't want to retry */35163493 goto done;35173494 }34953495+34963496+ /*34973497+ * Don't depend on the iter state matching what was consumed, or being34983498+ * untouched in case of error. Restore it and we'll advance it34993499+ * manually if we need to.35003500+ */35013501+ iov_iter_restore(iter, state);3518350235193503 ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true);35203504 if (ret2)···3526350235273503 iovec = NULL;35283504 rw = req->async_data;35293529- /* now use our persistent iterator, if we aren't already */35303530- iter = &rw->iter;35053505+ /*35063506+ * Now use our persistent iterator and state, if we aren't already.35073507+ * We've restored and mapped the iter to match.35083508+ */35093509+ if (iter != &rw->iter) {35103510+ iter = &rw->iter;35113511+ state = &rw->iter_state;35123512+ }3531351335323514 do {35333533- io_size -= ret;35153515+ /*35163516+ * We end up here because of a partial read, either from35173517+ * above or inside this loop. Advance the iter by the bytes35183518+ * that were consumed.35193519+ */35203520+ iov_iter_advance(iter, ret);35213521+ if (!iov_iter_count(iter))35223522+ break;35343523 rw->bytes_done += ret;35243524+ iov_iter_save_state(iter, state);35253525+35353526 /* if we can retry, do so with the callbacks armed */35363527 if (!io_rw_should_retry(req)) {35373528 kiocb->ki_flags &= ~IOCB_WAITQ;···35643525 return 0;35653526 /* we got some bytes, but not all. retry. */35663527 kiocb->ki_flags &= ~IOCB_WAITQ;35673567- } while (ret > 0 && ret < io_size);35283528+ iov_iter_restore(iter, state);35293529+ } while (ret > 0);35683530done:35693531 kiocb_done(kiocb, ret, issue_flags);35703532out_free:···35793539{35803540 if (unlikely(!(req->file->f_mode & FMODE_WRITE)))35813541 return -EBADF;35823582- return io_prep_rw(req, sqe);35423542+ return io_prep_rw(req, sqe, WRITE);35833543}3584354435853545static int io_write(struct io_kiocb *req, unsigned int issue_flags)···35883548 struct kiocb *kiocb = &req->rw.kiocb;35893549 struct iov_iter __iter, *iter = &__iter;35903550 struct io_async_rw *rw = req->async_data;35913591- ssize_t ret, ret2, io_size;35923551 bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;35523552+ struct iov_iter_state __state, *state;35533553+ ssize_t ret, ret2;3593355435943555 if (rw) {35953556 iter = &rw->iter;35573557+ state = &rw->iter_state;35583558+ iov_iter_restore(iter, state);35963559 iovec = NULL;35973560 } else {35983561 ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);35993562 if (ret < 0)36003563 return ret;35643564+ state = &__state;35653565+ iov_iter_save_state(iter, state);36013566 }36023602- io_size = iov_iter_count(iter);36033603- req->result = io_size;35673567+ req->result = iov_iter_count(iter);35683568+ ret2 = 0;3604356936053570 /* Ensure we clear previously set non-block flag */36063571 if (!force_nonblock)···36223577 (req->flags & REQ_F_ISREG))36233578 goto copy_iov;3624357936253625- ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), io_size);35803580+ ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), req->result);36263581 if (unlikely(ret))36273582 goto out_free;36283583···36693624 kiocb_done(kiocb, ret2, issue_flags);36703625 } else {36713626copy_iov:36723672- /* some cases will consume bytes even on error returns */36733673- iov_iter_reexpand(iter, iter->count + iter->truncated);36743674- iov_iter_revert(iter, io_size - iov_iter_count(iter));36273627+ iov_iter_restore(iter, state);36283628+ if (ret2 > 0)36293629+ iov_iter_advance(iter, ret2);36753630 ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);36763631 return ret ?: -EAGAIN;36773632 }···75607515 break;75617516 } while (1);7562751775187518+ if (uts) {75197519+ struct timespec64 ts;75207520+75217521+ if (get_timespec64(&ts, uts))75227522+ return -EFAULT;75237523+ timeout = timespec64_to_jiffies(&ts);75247524+ }75257525+75637526 if (sig) {75647527#ifdef CONFIG_COMPAT75657528 if (in_compat_syscall())···7579752675807527 if (ret)75817528 return ret;75827582- }75837583-75847584- if (uts) {75857585- struct timespec64 ts;75867586-75877587- if (get_timespec64(&ts, uts))75887588- return -EFAULT;75897589- timeout = timespec64_to_jiffies(&ts);75907529 }7591753075927531 init_waitqueue_func_entry(&iowq.wq, io_wake_function);···83298284#endif83308285}8331828682878287+static int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,82888288+ struct io_rsrc_node *node, void *rsrc)82898289+{82908290+ struct io_rsrc_put *prsrc;82918291+82928292+ prsrc = kzalloc(sizeof(*prsrc), GFP_KERNEL);82938293+ if (!prsrc)82948294+ return -ENOMEM;82958295+82968296+ prsrc->tag = *io_get_tag_slot(data, idx);82978297+ prsrc->rsrc = rsrc;82988298+ list_add(&prsrc->list, &node->rsrc_list);82998299+ return 0;83008300+}83018301+83328302static int io_install_fixed_file(struct io_kiocb *req, struct file *file,83338303 unsigned int issue_flags, u32 slot_index)83348304{83358305 struct io_ring_ctx *ctx = req->ctx;83368306 bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;83078307+ bool needs_switch = false;83378308 struct io_fixed_file *file_slot;83388309 int ret = -EBADF;83398310···8365830483668305 slot_index = array_index_nospec(slot_index, ctx->nr_user_files);83678306 file_slot = io_fixed_file_slot(&ctx->file_table, slot_index);83688368- ret = -EBADF;83698369- if (file_slot->file_ptr)83708370- goto err;83078307+83088308+ if (file_slot->file_ptr) {83098309+ struct file *old_file;83108310+83118311+ ret = io_rsrc_node_switch_start(ctx);83128312+ if (ret)83138313+ goto err;83148314+83158315+ old_file = (struct file *)(file_slot->file_ptr & FFS_MASK);83168316+ ret = io_queue_rsrc_removal(ctx->file_data, slot_index,83178317+ ctx->rsrc_node, old_file);83188318+ if (ret)83198319+ goto err;83208320+ file_slot->file_ptr = 0;83218321+ needs_switch = true;83228322+ }8371832383728324 *io_get_tag_slot(ctx->file_data, slot_index) = 0;83738325 io_fixed_file_set(file_slot, file);···8392831883938319 ret = 0;83948320err:83218321+ if (needs_switch)83228322+ io_rsrc_node_switch(ctx, ctx->file_data);83958323 io_ring_submit_unlock(ctx, !force_nonblock);83968324 if (ret)83978325 fput(file);83988326 return ret;83998399-}84008400-84018401-static int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,84028402- struct io_rsrc_node *node, void *rsrc)84038403-{84048404- struct io_rsrc_put *prsrc;84058405-84068406- prsrc = kzalloc(sizeof(*prsrc), GFP_KERNEL);84078407- if (!prsrc)84088408- return -ENOMEM;84098409-84108410- prsrc->tag = *io_get_tag_slot(data, idx);84118411- prsrc->rsrc = rsrc;84128412- list_add(&prsrc->list, &node->rsrc_list);84138413- return 0;84148327}8415832884168329static int __io_sqe_files_update(struct io_ring_ctx *ctx,···1062110560 * ordering. Fine to drop uring_lock here, we hold1062210561 * a ref to the ctx.1062310562 */1056310563+ refcount_inc(&sqd->refs);1062410564 mutex_unlock(&ctx->uring_lock);1062510565 mutex_lock(&sqd->lock);1062610566 mutex_lock(&ctx->uring_lock);1062710627- tctx = sqd->thread->io_uring;1056710567+ if (sqd->thread)1056810568+ tctx = sqd->thread->io_uring;1062810569 }1062910570 } else {1063010571 tctx = current->io_uring;···1064010577 if (ret)1064110578 goto err;10642105791064310643- if (sqd)1058010580+ if (sqd) {1064410581 mutex_unlock(&sqd->lock);1058210582+ io_put_sq_data(sqd);1058310583+ }10645105841064610585 if (copy_to_user(arg, new_count, sizeof(new_count)))1064710586 return -EFAULT;10648105871064910588 return 0;1065010589err:1065110651- if (sqd)1059010590+ if (sqd) {1065210591 mutex_unlock(&sqd->lock);1059210592+ io_put_sq_data(sqd);1059310593+ }1065310594 return ret;1065410595}1065510596
+34-17
fs/qnx4/dir.c
···1515#include <linux/buffer_head.h>1616#include "qnx4.h"17171818+/*1919+ * A qnx4 directory entry is an inode entry or link info2020+ * depending on the status field in the last byte. The2121+ * first byte is where the name start either way, and a2222+ * zero means it's empty.2323+ */2424+union qnx4_directory_entry {2525+ struct {2626+ char de_name;2727+ char de_pad[62];2828+ char de_status;2929+ };3030+ struct qnx4_inode_entry inode;3131+ struct qnx4_link_info link;3232+};3333+1834static int qnx4_readdir(struct file *file, struct dir_context *ctx)1935{2036 struct inode *inode = file_inode(file);2137 unsigned int offset;2238 struct buffer_head *bh;2323- struct qnx4_inode_entry *de;2424- struct qnx4_link_info *le;2539 unsigned long blknum;2640 int ix, ino;2741 int size;···5238 }5339 ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;5440 for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) {4141+ union qnx4_directory_entry *de;4242+ const char *name;4343+5544 offset = ix * QNX4_DIR_ENTRY_SIZE;5656- de = (struct qnx4_inode_entry *) (bh->b_data + offset);5757- if (!de->di_fname[0])4545+ de = (union qnx4_directory_entry *) (bh->b_data + offset);4646+4747+ if (!de->de_name)5848 continue;5959- if (!(de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK)))4949+ if (!(de->de_status & (QNX4_FILE_USED|QNX4_FILE_LINK)))6050 continue;6161- if (!(de->di_status & QNX4_FILE_LINK))6262- size = QNX4_SHORT_NAME_MAX;6363- else6464- size = QNX4_NAME_MAX;6565- size = strnlen(de->di_fname, size);6666- QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, de->di_fname));6767- if (!(de->di_status & QNX4_FILE_LINK))5151+ if (!(de->de_status & QNX4_FILE_LINK)) {5252+ size = sizeof(de->inode.di_fname);5353+ name = de->inode.di_fname;6854 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;6969- else {7070- le = (struct qnx4_link_info*)de;7171- ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) *5555+ } else {5656+ size = sizeof(de->link.dl_fname);5757+ name = de->link.dl_fname;5858+ ino = ( le32_to_cpu(de->link.dl_inode_blk) - 1 ) *7259 QNX4_INODES_PER_BLOCK +7373- le->dl_inode_ndx;6060+ de->link.dl_inode_ndx;7461 }7575- if (!dir_emit(ctx, de->di_fname, size, ino, DT_UNKNOWN)) {6262+ size = strnlen(name, size);6363+ QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, name));6464+ if (!dir_emit(ctx, name, size, ino, DT_UNKNOWN)) {7665 brelse(bh);7766 return 0;7867 }
···110110}111111#endif112112113113-#ifdef CONFIG_PCI114114-/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */115115-struct pci_dev;116116-extern void pci_iounmap(struct pci_dev *dev, void __iomem *);117117-#elif defined(CONFIG_GENERIC_IOMAP)118118-struct pci_dev;119119-static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)120120-{ }121121-#endif122122-123113#include <asm-generic/pci_iomap.h>124114125115#endif
+19-2
include/asm-generic/mshyperv.h
···197197 return hv_vp_index[cpu_number];198198}199199200200-static inline int cpumask_to_vpset(struct hv_vpset *vpset,201201- const struct cpumask *cpus)200200+static inline int __cpumask_to_vpset(struct hv_vpset *vpset,201201+ const struct cpumask *cpus,202202+ bool exclude_self)202203{203204 int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;205205+ int this_cpu = smp_processor_id();204206205207 /* valid_bank_mask can represent up to 64 banks */206208 if (hv_max_vp_index / 64 >= 64)···220218 * Some banks may end up being empty but this is acceptable.221219 */222220 for_each_cpu(cpu, cpus) {221221+ if (exclude_self && cpu == this_cpu)222222+ continue;223223 vcpu = hv_cpu_number_to_vp_number(cpu);224224 if (vcpu == VP_INVAL)225225 return -1;···234230 }235231 vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0);236232 return nr_bank;233233+}234234+235235+static inline int cpumask_to_vpset(struct hv_vpset *vpset,236236+ const struct cpumask *cpus)237237+{238238+ return __cpumask_to_vpset(vpset, cpus, false);239239+}240240+241241+static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset,242242+ const struct cpumask *cpus)243243+{244244+ WARN_ON_ONCE(preemptible());245245+ return __cpumask_to_vpset(vpset, cpus, true);237246}238247239248void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
+3
include/asm-generic/pci_iomap.h
···1818extern void __iomem *pci_iomap_wc_range(struct pci_dev *dev, int bar,1919 unsigned long offset,2020 unsigned long maxlen);2121+extern void pci_iounmap(struct pci_dev *dev, void __iomem *);2122/* Create a virtual mapping cookie for a port on a given PCI device.2223 * Do not call this directly, it exists to make it easier for architectures2324 * to override */···5150{5251 return NULL;5352}5353+static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)5454+{ }5455#endif55565657#endif /* __ASM_GENERIC_PCI_IOMAP_H */
-4
include/asm-generic/vmlinux.lds.h
···116116 * GCC 4.5 and later have a 32 bytes section alignment for structures.117117 * Except GCC 4.9, that feels the need to align on 64 bytes.118118 */119119-#if __GNUC__ == 4 && __GNUC_MINOR__ == 9120120-#define STRUCT_ALIGNMENT 64121121-#else122119#define STRUCT_ALIGNMENT 32123123-#endif124120#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)125121126122/*
+27-80
include/linux/cgroup-defs.h
···752752 * sock_cgroup_data is embedded at sock->sk_cgrp_data and contains753753 * per-socket cgroup information except for memcg association.754754 *755755- * On legacy hierarchies, net_prio and net_cls controllers directly set756756- * attributes on each sock which can then be tested by the network layer.757757- * On the default hierarchy, each sock is associated with the cgroup it was758758- * created in and the networking layer can match the cgroup directly.759759- *760760- * To avoid carrying all three cgroup related fields separately in sock,761761- * sock_cgroup_data overloads (prioidx, classid) and the cgroup pointer.762762- * On boot, sock_cgroup_data records the cgroup that the sock was created763763- * in so that cgroup2 matches can be made; however, once either net_prio or764764- * net_cls starts being used, the area is overridden to carry prioidx and/or765765- * classid. The two modes are distinguished by whether the lowest bit is766766- * set. Clear bit indicates cgroup pointer while set bit prioidx and767767- * classid.768768- *769769- * While userland may start using net_prio or net_cls at any time, once770770- * either is used, cgroup2 matching no longer works. There is no reason to771771- * mix the two and this is in line with how legacy and v2 compatibility is772772- * handled. On mode switch, cgroup references which are already being773773- * pointed to by socks may be leaked. While this can be remedied by adding774774- * synchronization around sock_cgroup_data, given that the number of leaked775775- * cgroups is bound and highly unlikely to be high, this seems to be the776776- * better trade-off.755755+ * On legacy hierarchies, net_prio and net_cls controllers directly756756+ * set attributes on each sock which can then be tested by the network757757+ * layer. On the default hierarchy, each sock is associated with the758758+ * cgroup it was created in and the networking layer can match the759759+ * cgroup directly.777760 */778761struct sock_cgroup_data {779779- union {780780-#ifdef __LITTLE_ENDIAN781781- struct {782782- u8 is_data : 1;783783- u8 no_refcnt : 1;784784- u8 unused : 6;785785- u8 padding;786786- u16 prioidx;787787- u32 classid;788788- } __packed;789789-#else790790- struct {791791- u32 classid;792792- u16 prioidx;793793- u8 padding;794794- u8 unused : 6;795795- u8 no_refcnt : 1;796796- u8 is_data : 1;797797- } __packed;762762+ struct cgroup *cgroup; /* v2 */763763+#ifdef CONFIG_CGROUP_NET_CLASSID764764+ u32 classid; /* v1 */798765#endif799799- u64 val;800800- };766766+#ifdef CONFIG_CGROUP_NET_PRIO767767+ u16 prioidx; /* v1 */768768+#endif801769};802770803803-/*804804- * There's a theoretical window where the following accessors race with805805- * updaters and return part of the previous pointer as the prioidx or806806- * classid. Such races are short-lived and the result isn't critical.807807- */808771static inline u16 sock_cgroup_prioidx(const struct sock_cgroup_data *skcd)809772{810810- /* fallback to 1 which is always the ID of the root cgroup */811811- return (skcd->is_data & 1) ? skcd->prioidx : 1;773773+#ifdef CONFIG_CGROUP_NET_PRIO774774+ return READ_ONCE(skcd->prioidx);775775+#else776776+ return 1;777777+#endif812778}813779814780static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd)815781{816816- /* fallback to 0 which is the unconfigured default classid */817817- return (skcd->is_data & 1) ? skcd->classid : 0;782782+#ifdef CONFIG_CGROUP_NET_CLASSID783783+ return READ_ONCE(skcd->classid);784784+#else785785+ return 0;786786+#endif818787}819788820820-/*821821- * If invoked concurrently, the updaters may clobber each other. The822822- * caller is responsible for synchronization.823823- */824789static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd,825790 u16 prioidx)826791{827827- struct sock_cgroup_data skcd_buf = {{ .val = READ_ONCE(skcd->val) }};828828-829829- if (sock_cgroup_prioidx(&skcd_buf) == prioidx)830830- return;831831-832832- if (!(skcd_buf.is_data & 1)) {833833- skcd_buf.val = 0;834834- skcd_buf.is_data = 1;835835- }836836-837837- skcd_buf.prioidx = prioidx;838838- WRITE_ONCE(skcd->val, skcd_buf.val); /* see sock_cgroup_ptr() */792792+#ifdef CONFIG_CGROUP_NET_PRIO793793+ WRITE_ONCE(skcd->prioidx, prioidx);794794+#endif839795}840796841797static inline void sock_cgroup_set_classid(struct sock_cgroup_data *skcd,842798 u32 classid)843799{844844- struct sock_cgroup_data skcd_buf = {{ .val = READ_ONCE(skcd->val) }};845845-846846- if (sock_cgroup_classid(&skcd_buf) == classid)847847- return;848848-849849- if (!(skcd_buf.is_data & 1)) {850850- skcd_buf.val = 0;851851- skcd_buf.is_data = 1;852852- }853853-854854- skcd_buf.classid = classid;855855- WRITE_ONCE(skcd->val, skcd_buf.val); /* see sock_cgroup_ptr() */800800+#ifdef CONFIG_CGROUP_NET_CLASSID801801+ WRITE_ONCE(skcd->classid, classid);802802+#endif856803}857804858805#else /* CONFIG_SOCK_CGROUP_DATA */
+1-21
include/linux/cgroup.h
···829829 */830830#ifdef CONFIG_SOCK_CGROUP_DATA831831832832-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)833833-extern spinlock_t cgroup_sk_update_lock;834834-#endif835835-836836-void cgroup_sk_alloc_disable(void);837832void cgroup_sk_alloc(struct sock_cgroup_data *skcd);838833void cgroup_sk_clone(struct sock_cgroup_data *skcd);839834void cgroup_sk_free(struct sock_cgroup_data *skcd);840835841836static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)842837{843843-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)844844- unsigned long v;845845-846846- /*847847- * @skcd->val is 64bit but the following is safe on 32bit too as we848848- * just need the lower ulong to be written and read atomically.849849- */850850- v = READ_ONCE(skcd->val);851851-852852- if (v & 3)853853- return &cgrp_dfl_root.cgrp;854854-855855- return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;856856-#else857857- return (struct cgroup *)(unsigned long)skcd->val;858858-#endif838838+ return skcd->cgroup;859839}860840861841#else /* CONFIG_CGROUP_DATA */
-13
include/linux/compiler-clang.h
···6262#define __no_sanitize_coverage6363#endif64646565-/*6666- * Not all versions of clang implement the type-generic versions6767- * of the builtin overflow checkers. Fortunately, clang implements6868- * __has_builtin allowing us to avoid awkward version6969- * checks. Unfortunately, we don't know which version of gcc clang7070- * pretends to be, so the macro may or may not be defined.7171- */7272-#if __has_builtin(__builtin_mul_overflow) && \7373- __has_builtin(__builtin_add_overflow) && \7474- __has_builtin(__builtin_sub_overflow)7575-#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 17676-#endif7777-7865#if __has_feature(shadow_call_stack)7966# define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))8067#endif
···188188 (typeof(ptr)) (__ptr + (off)); })189189#endif190190191191+#define absolute_pointer(val) RELOC_HIDE((void *)(val), 0)192192+191193#ifndef OPTIMIZER_HIDE_VAR192194/* Make the optimizer believe the variable can be manipulated arbitrarily. */193195#define OPTIMIZER_HIDE_VAR(var) \
-24
include/linux/compiler_attributes.h
···2121 */22222323/*2424- * __has_attribute is supported on gcc >= 5, clang >= 2.9 and icc >= 17.2525- * In the meantime, to support gcc < 5, we implement __has_attribute2626- * by hand.2727- */2828-#ifndef __has_attribute2929-# define __has_attribute(x) __GCC4_has_attribute_##x3030-# define __GCC4_has_attribute___assume_aligned__ 13131-# define __GCC4_has_attribute___copy__ 03232-# define __GCC4_has_attribute___designated_init__ 03333-# define __GCC4_has_attribute___error__ 13434-# define __GCC4_has_attribute___externally_visible__ 13535-# define __GCC4_has_attribute___no_caller_saved_registers__ 03636-# define __GCC4_has_attribute___noclone__ 13737-# define __GCC4_has_attribute___no_profile_instrument_function__ 03838-# define __GCC4_has_attribute___nonstring__ 03939-# define __GCC4_has_attribute___no_sanitize_address__ 14040-# define __GCC4_has_attribute___no_sanitize_undefined__ 14141-# define __GCC4_has_attribute___no_sanitize_coverage__ 04242-# define __GCC4_has_attribute___fallthrough__ 04343-# define __GCC4_has_attribute___warning__ 14444-#endif4545-4646-/*4724 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute4825 */4926#define __alias(symbol) __attribute__((__alias__(#symbol)))···5477 * compiler should see some alignment anyway, when the return value is5578 * massaged by 'flags = ptr & 3; ptr &= ~3;').5679 *5757- * Optional: only supported since gcc >= 4.95880 * Optional: not supported by icc5981 *6082 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-assume_005faligned-function-attribute
···66#include <linux/limits.h>7788/*99- * In the fallback code below, we need to compute the minimum and1010- * maximum values representable in a given type. These macros may also1111- * be useful elsewhere, so we provide them outside the1212- * COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW block.1313- *1414- * It would seem more obvious to do something like99+ * We need to compute the minimum and maximum values representable in a given1010+ * type. These macros may also be useful elsewhere. It would seem more obvious1111+ * to do something like:1512 *1613 * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0)1714 * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0)···5154 return unlikely(overflow);5255}53565454-#ifdef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW5557/*5658 * For simplicity and code hygiene, the fallback code below insists on5759 * a, b and *d having the same type (similar to the min() and max()···8589 (void) (&__a == __d); \8690 __builtin_mul_overflow(__a, __b, __d); \8791}))8888-8989-#else9090-9191-9292-/* Checking for unsigned overflow is relatively easy without causing UB. */9393-#define __unsigned_add_overflow(a, b, d) ({ \9494- typeof(a) __a = (a); \9595- typeof(b) __b = (b); \9696- typeof(d) __d = (d); \9797- (void) (&__a == &__b); \9898- (void) (&__a == __d); \9999- *__d = __a + __b; \100100- *__d < __a; \101101-})102102-#define __unsigned_sub_overflow(a, b, d) ({ \103103- typeof(a) __a = (a); \104104- typeof(b) __b = (b); \105105- typeof(d) __d = (d); \106106- (void) (&__a == &__b); \107107- (void) (&__a == __d); \108108- *__d = __a - __b; \109109- __a < __b; \110110-})111111-/*112112- * If one of a or b is a compile-time constant, this avoids a division.113113- */114114-#define __unsigned_mul_overflow(a, b, d) ({ \115115- typeof(a) __a = (a); \116116- typeof(b) __b = (b); \117117- typeof(d) __d = (d); \118118- (void) (&__a == &__b); \119119- (void) (&__a == __d); \120120- *__d = __a * __b; \121121- __builtin_constant_p(__b) ? \122122- __b > 0 && __a > type_max(typeof(__a)) / __b : \123123- __a > 0 && __b > type_max(typeof(__b)) / __a; \124124-})125125-126126-/*127127- * For signed types, detecting overflow is much harder, especially if128128- * we want to avoid UB. But the interface of these macros is such that129129- * we must provide a result in *d, and in fact we must produce the130130- * result promised by gcc's builtins, which is simply the possibly131131- * wrapped-around value. Fortunately, we can just formally do the132132- * operations in the widest relevant unsigned type (u64) and then133133- * truncate the result - gcc is smart enough to generate the same code134134- * with and without the (u64) casts.135135- */136136-137137-/*138138- * Adding two signed integers can overflow only if they have the same139139- * sign, and overflow has happened iff the result has the opposite140140- * sign.141141- */142142-#define __signed_add_overflow(a, b, d) ({ \143143- typeof(a) __a = (a); \144144- typeof(b) __b = (b); \145145- typeof(d) __d = (d); \146146- (void) (&__a == &__b); \147147- (void) (&__a == __d); \148148- *__d = (u64)__a + (u64)__b; \149149- (((~(__a ^ __b)) & (*__d ^ __a)) \150150- & type_min(typeof(__a))) != 0; \151151-})152152-153153-/*154154- * Subtraction is similar, except that overflow can now happen only155155- * when the signs are opposite. In this case, overflow has happened if156156- * the result has the opposite sign of a.157157- */158158-#define __signed_sub_overflow(a, b, d) ({ \159159- typeof(a) __a = (a); \160160- typeof(b) __b = (b); \161161- typeof(d) __d = (d); \162162- (void) (&__a == &__b); \163163- (void) (&__a == __d); \164164- *__d = (u64)__a - (u64)__b; \165165- ((((__a ^ __b)) & (*__d ^ __a)) \166166- & type_min(typeof(__a))) != 0; \167167-})168168-169169-/*170170- * Signed multiplication is rather hard. gcc always follows C99, so171171- * division is truncated towards 0. This means that we can write the172172- * overflow check like this:173173- *174174- * (a > 0 && (b > MAX/a || b < MIN/a)) ||175175- * (a < -1 && (b > MIN/a || b < MAX/a) ||176176- * (a == -1 && b == MIN)177177- *178178- * The redundant casts of -1 are to silence an annoying -Wtype-limits179179- * (included in -Wextra) warning: When the type is u8 or u16, the180180- * __b_c_e in check_mul_overflow obviously selects181181- * __unsigned_mul_overflow, but unfortunately gcc still parses this182182- * code and warns about the limited range of __b.183183- */184184-185185-#define __signed_mul_overflow(a, b, d) ({ \186186- typeof(a) __a = (a); \187187- typeof(b) __b = (b); \188188- typeof(d) __d = (d); \189189- typeof(a) __tmax = type_max(typeof(a)); \190190- typeof(a) __tmin = type_min(typeof(a)); \191191- (void) (&__a == &__b); \192192- (void) (&__a == __d); \193193- *__d = (u64)__a * (u64)__b; \194194- (__b > 0 && (__a > __tmax/__b || __a < __tmin/__b)) || \195195- (__b < (typeof(__b))-1 && (__a > __tmin/__b || __a < __tmax/__b)) || \196196- (__b == (typeof(__b))-1 && __a == __tmin); \197197-})198198-199199-200200-#define check_add_overflow(a, b, d) __must_check_overflow( \201201- __builtin_choose_expr(is_signed_type(typeof(a)), \202202- __signed_add_overflow(a, b, d), \203203- __unsigned_add_overflow(a, b, d)))204204-205205-#define check_sub_overflow(a, b, d) __must_check_overflow( \206206- __builtin_choose_expr(is_signed_type(typeof(a)), \207207- __signed_sub_overflow(a, b, d), \208208- __unsigned_sub_overflow(a, b, d)))209209-210210-#define check_mul_overflow(a, b, d) __must_check_overflow( \211211- __builtin_choose_expr(is_signed_type(typeof(a)), \212212- __signed_mul_overflow(a, b, d), \213213- __unsigned_mul_overflow(a, b, d)))214214-215215-#endif /* COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW */2169221793/** check_shl_overflow() - Calculate a left-shifted value and check overflow21894 *
···317317 IORING_REGISTER_IOWQ_AFF = 17,318318 IORING_UNREGISTER_IOWQ_AFF = 18,319319320320- /* set/get max number of workers */320320+ /* set/get max number of io-wq workers */321321 IORING_REGISTER_IOWQ_MAX_WORKERS = 19,322322323323 /* this goes last */324324 IORING_REGISTER_LAST325325+};326326+327327+/* io-wq worker categories */328328+enum {329329+ IO_WQ_BOUND,330330+ IO_WQ_UNBOUND,325331};326332327333/* deprecated, see struct io_uring_rsrc_update */
···179179 * with build_id.180180 */181181 if (!user || !current || !current->mm || irq_work_busy ||182182- !mmap_read_trylock_non_owner(current->mm)) {182182+ !mmap_read_trylock(current->mm)) {183183 /* cannot access current->mm, fall back to ips */184184 for (i = 0; i < trace_nr; i++) {185185 id_offs[i].status = BPF_STACK_BUILD_ID_IP;···204204 }205205206206 if (!work) {207207- mmap_read_unlock_non_owner(current->mm);207207+ mmap_read_unlock(current->mm);208208 } else {209209 work->mm = current->mm;210210+211211+ /* The lock will be released once we're out of interrupt212212+ * context. Tell lockdep that we've released it now so213213+ * it doesn't complain that we forgot to release it.214214+ */215215+ rwsem_release(¤t->mm->mmap_lock.dep_map, _RET_IP_);210216 irq_work_queue(&work->irq_work);211217 }212218}
+2
kernel/bpf/verifier.c
···99129912 nr_linfo = attr->line_info_cnt;99139913 if (!nr_linfo)99149914 return 0;99159915+ if (nr_linfo > INT_MAX / sizeof(struct bpf_line_info))99169916+ return -EINVAL;9915991799169918 rec_size = attr->line_info_rec_size;99179919 if (rec_size < MIN_BPF_LINEINFO_SIZE ||
+10-40
kernel/cgroup/cgroup.c
···65726572 */65736573#ifdef CONFIG_SOCK_CGROUP_DATA6574657465756575-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)65766576-65776577-DEFINE_SPINLOCK(cgroup_sk_update_lock);65786578-static bool cgroup_sk_alloc_disabled __read_mostly;65796579-65806580-void cgroup_sk_alloc_disable(void)65816581-{65826582- if (cgroup_sk_alloc_disabled)65836583- return;65846584- pr_info("cgroup: disabling cgroup2 socket matching due to net_prio or net_cls activation\n");65856585- cgroup_sk_alloc_disabled = true;65866586-}65876587-65886588-#else65896589-65906590-#define cgroup_sk_alloc_disabled false65916591-65926592-#endif65936593-65946575void cgroup_sk_alloc(struct sock_cgroup_data *skcd)65956576{65966596- if (cgroup_sk_alloc_disabled) {65976597- skcd->no_refcnt = 1;65986598- return;65996599- }66006600-66016577 /* Don't associate the sock with unrelated interrupted task's cgroup. */66026578 if (in_interrupt())66036579 return;6604658066056581 rcu_read_lock();66066606-66076582 while (true) {66086583 struct css_set *cset;6609658466106585 cset = task_css_set(current);66116586 if (likely(cgroup_tryget(cset->dfl_cgrp))) {66126612- skcd->val = (unsigned long)cset->dfl_cgrp;65876587+ skcd->cgroup = cset->dfl_cgrp;66136588 cgroup_bpf_get(cset->dfl_cgrp);66146589 break;66156590 }66166591 cpu_relax();66176592 }66186618-66196593 rcu_read_unlock();66206594}6621659566226596void cgroup_sk_clone(struct sock_cgroup_data *skcd)66236597{66246624- if (skcd->val) {66256625- if (skcd->no_refcnt)66266626- return;66276627- /*66286628- * We might be cloning a socket which is left in an empty66296629- * cgroup and the cgroup might have already been rmdir'd.66306630- * Don't use cgroup_get_live().66316631- */66326632- cgroup_get(sock_cgroup_ptr(skcd));66336633- cgroup_bpf_get(sock_cgroup_ptr(skcd));66346634- }65986598+ struct cgroup *cgrp = sock_cgroup_ptr(skcd);65996599+66006600+ /*66016601+ * We might be cloning a socket which is left in an empty66026602+ * cgroup and the cgroup might have already been rmdir'd.66036603+ * Don't use cgroup_get_live().66046604+ */66056605+ cgroup_get(cgrp);66066606+ cgroup_bpf_get(cgrp);66356607}6636660866376609void cgroup_sk_free(struct sock_cgroup_data *skcd)66386610{66396611 struct cgroup *cgrp = sock_cgroup_ptr(skcd);6640661266416641- if (skcd->no_refcnt)66426642- return;66436613 cgroup_bpf_put(cgrp);66446614 cgroup_put(cgrp);66456615}
···206206/**207207 * dma_map_sg_attrs - Map the given buffer for DMA208208 * @dev: The device for which to perform the DMA operation209209- * @sg: The sg_table object describing the buffer209209+ * @sg: The sg_table object describing the buffer210210+ * @nents: Number of entries to map210211 * @dir: DMA direction211212 * @attrs: Optional DMA attributes for the map operation212213 *
···4141 * The risk of writer starvation is there, but the pathological use cases4242 * which trigger it are not necessarily the typical RT workloads.4343 *4444+ * Fast-path orderings:4545+ * The lock/unlock of readers can run in fast paths: lock and unlock are only4646+ * atomic ops, and there is no inner lock to provide ACQUIRE and RELEASE4747+ * semantics of rwbase_rt. Atomic ops should thus provide _acquire()4848+ * and _release() (or stronger).4949+ *4450 * Common code shared between RT rw_semaphore and rwlock4551 */4652···5953 * set.6054 */6155 for (r = atomic_read(&rwb->readers); r < 0;) {5656+ /* Fully-ordered if cmpxchg() succeeds, provides ACQUIRE */6257 if (likely(atomic_try_cmpxchg(&rwb->readers, &r, r + 1)))6358 return 1;6459 }···169162 /*170163 * rwb->readers can only hit 0 when a writer is waiting for the171164 * active readers to leave the critical section.165165+ *166166+ * dec_and_test() is fully ordered, provides RELEASE.172167 */173168 if (unlikely(atomic_dec_and_test(&rwb->readers)))174169 __rwbase_read_unlock(rwb, state);···181172{182173 struct rt_mutex_base *rtm = &rwb->rtmutex;183174184184- atomic_add(READER_BIAS - bias, &rwb->readers);175175+ /*176176+ * _release() is needed in case that reader is in fast path, pairing177177+ * with atomic_try_cmpxchg() in rwbase_read_trylock(), provides RELEASE178178+ */179179+ (void)atomic_add_return_release(READER_BIAS - bias, &rwb->readers);185180 raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);186181 rwbase_rtmutex_unlock(rtm);187182}···209196 __rwbase_write_unlock(rwb, WRITER_BIAS - 1, flags);210197}211198199199+static inline bool __rwbase_write_trylock(struct rwbase_rt *rwb)200200+{201201+ /* Can do without CAS because we're serialized by wait_lock. */202202+ lockdep_assert_held(&rwb->rtmutex.wait_lock);203203+204204+ /*205205+ * _acquire is needed in case the reader is in the fast path, pairing206206+ * with rwbase_read_unlock(), provides ACQUIRE.207207+ */208208+ if (!atomic_read_acquire(&rwb->readers)) {209209+ atomic_set(&rwb->readers, WRITER_BIAS);210210+ return 1;211211+ }212212+213213+ return 0;214214+}215215+212216static int __sched rwbase_write_lock(struct rwbase_rt *rwb,213217 unsigned int state)214218{···240210 atomic_sub(READER_BIAS, &rwb->readers);241211242212 raw_spin_lock_irqsave(&rtm->wait_lock, flags);243243- /*244244- * set_current_state() for rw_semaphore245245- * current_save_and_set_rtlock_wait_state() for rwlock246246- */247247- rwbase_set_and_save_current_state(state);213213+ if (__rwbase_write_trylock(rwb))214214+ goto out_unlock;248215249249- /* Block until all readers have left the critical section. */250250- for (; atomic_read(&rwb->readers);) {216216+ rwbase_set_and_save_current_state(state);217217+ for (;;) {251218 /* Optimized out for rwlocks */252219 if (rwbase_signal_pending_state(state, current)) {253253- __set_current_state(TASK_RUNNING);220220+ rwbase_restore_current_state();254221 __rwbase_write_unlock(rwb, 0, flags);255222 return -EINTR;256223 }224224+225225+ if (__rwbase_write_trylock(rwb))226226+ break;227227+257228 raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);258258-259259- /*260260- * Schedule and wait for the readers to leave the critical261261- * section. The last reader leaving it wakes the waiter.262262- */263263- if (atomic_read(&rwb->readers) != 0)264264- rwbase_schedule();265265- set_current_state(state);229229+ rwbase_schedule();266230 raw_spin_lock_irqsave(&rtm->wait_lock, flags);267267- }268231269269- atomic_set(&rwb->readers, WRITER_BIAS);232232+ set_current_state(state);233233+ }270234 rwbase_restore_current_state();235235+236236+out_unlock:271237 raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);272238 return 0;273239}···279253 atomic_sub(READER_BIAS, &rwb->readers);280254281255 raw_spin_lock_irqsave(&rtm->wait_lock, flags);282282- if (!atomic_read(&rwb->readers)) {283283- atomic_set(&rwb->readers, WRITER_BIAS);256256+ if (__rwbase_write_trylock(rwb)) {284257 raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);285258 return 1;286259 }
···19721972 return 0;19731973}19741974EXPORT_SYMBOL(import_single_range);19751975+19761976+/**19771977+ * iov_iter_restore() - Restore a &struct iov_iter to the same state as when19781978+ * iov_iter_save_state() was called.19791979+ *19801980+ * @i: &struct iov_iter to restore19811981+ * @state: state to restore from19821982+ *19831983+ * Used after iov_iter_save_state() to bring restore @i, if operations may19841984+ * have advanced it.19851985+ *19861986+ * Note: only works on ITER_IOVEC, ITER_BVEC, and ITER_KVEC19871987+ */19881988+void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state)19891989+{19901990+ if (WARN_ON_ONCE(!iov_iter_is_bvec(i) && !iter_is_iovec(i)) &&19911991+ !iov_iter_is_kvec(i))19921992+ return;19931993+ i->iov_offset = state->iov_offset;19941994+ i->count = state->count;19951995+ /*19961996+ * For the *vec iters, nr_segs + iov is constant - if we increment19971997+ * the vec, then we also decrement the nr_segs count. Hence we don't19981998+ * need to track both of these, just one is enough and we can deduct19991999+ * the other from that. ITER_KVEC and ITER_IOVEC are the same struct20002000+ * size, so we can just increment the iov pointer as they are unionzed.20012001+ * ITER_BVEC _may_ be the same size on some archs, but on others it is20022002+ * not. Be safe and handle it separately.20032003+ */20042004+ BUILD_BUG_ON(sizeof(struct iovec) != sizeof(struct kvec));20052005+ if (iov_iter_is_bvec(i))20062006+ i->bvec -= state->nr_segs - i->nr_segs;20072007+ else20082008+ i->iov -= state->nr_segs - i->nr_segs;20092009+ i->nr_segs = state->nr_segs;20102010+}
+43
lib/pci_iomap.c
···134134 return pci_iomap_wc_range(dev, bar, 0, maxlen);135135}136136EXPORT_SYMBOL_GPL(pci_iomap_wc);137137+138138+/*139139+ * pci_iounmap() somewhat illogically comes from lib/iomap.c for the140140+ * CONFIG_GENERIC_IOMAP case, because that's the code that knows about141141+ * the different IOMAP ranges.142142+ *143143+ * But if the architecture does not use the generic iomap code, and if144144+ * it has _not_ defined it's own private pci_iounmap function, we define145145+ * it here.146146+ *147147+ * NOTE! This default implementation assumes that if the architecture148148+ * support ioport mapping (HAS_IOPORT_MAP), the ioport mapping will149149+ * be fixed to the range [ PCI_IOBASE, PCI_IOBASE+IO_SPACE_LIMIT [,150150+ * and does not need unmapping with 'ioport_unmap()'.151151+ *152152+ * If you have different rules for your architecture, you need to153153+ * implement your own pci_iounmap() that knows the rules for where154154+ * and how IO vs MEM get mapped.155155+ *156156+ * This code is odd, and the ARCH_HAS/ARCH_WANTS #define logic comes157157+ * from legacy <asm-generic/io.h> header file behavior. In particular,158158+ * it would seem to make sense to do the iounmap(p) for the non-IO-space159159+ * case here regardless, but that's not what the old header file code160160+ * did. Probably incorrectly, but this is meant to be bug-for-bug161161+ * compatible.162162+ */163163+#if defined(ARCH_WANTS_GENERIC_PCI_IOUNMAP)164164+165165+void pci_iounmap(struct pci_dev *dev, void __iomem *p)166166+{167167+#ifdef ARCH_HAS_GENERIC_IOPORT_MAP168168+ uintptr_t start = (uintptr_t) PCI_IOBASE;169169+ uintptr_t addr = (uintptr_t) p;170170+171171+ if (addr >= start && addr < start + IO_SPACE_LIMIT)172172+ return;173173+ iounmap(p);174174+#endif175175+}176176+EXPORT_SYMBOL(pci_iounmap);177177+178178+#endif /* ARCH_WANTS_GENERIC_PCI_IOUNMAP */179179+137180#endif /* CONFIG_PCI */
-2
mm/ksm.c
···651651 * from &migrate_nodes. This will verify that future list.h changes652652 * don't break STABLE_NODE_DUP_HEAD. Only recent gcc can handle it.653653 */654654-#if defined(GCC_VERSION) && GCC_VERSION >= 40903655654 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD <= &migrate_nodes);656655 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD >= &migrate_nodes + 1);657657-#endif658656659657 if (stable_node->head == &migrate_nodes)660658 list_del(&stable_node->list);
+15-1
mm/memblock.c
···472472 kfree(old_array);473473 else if (old_array != memblock_memory_init_regions &&474474 old_array != memblock_reserved_init_regions)475475- memblock_free(__pa(old_array), old_alloc_size);475475+ memblock_free_ptr(old_array, old_alloc_size);476476477477 /*478478 * Reserve the new array if that comes from the memblock. Otherwise, we···793793 &base, &end, (void *)_RET_IP_);794794795795 return memblock_remove_range(&memblock.memory, base, size);796796+}797797+798798+/**799799+ * memblock_free_ptr - free boot memory allocation800800+ * @ptr: starting address of the boot memory allocation801801+ * @size: size of the boot memory block in bytes802802+ *803803+ * Free boot memory block previously allocated by memblock_alloc_xx() API.804804+ * The freeing memory will not be released to the buddy allocator.805805+ */806806+void __init_memblock memblock_free_ptr(void *ptr, size_t size)807807+{808808+ if (ptr)809809+ memblock_free(__pa(ptr), size);796810}797811798812/**
···18541854 * use the switch internal MDIO bus instead18551855 */18561856 ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags);18571857- if (ret) {18581858- netdev_err(slave_dev,18591859- "failed to connect to port %d: %d\n",18601860- dp->index, ret);18611861- phylink_destroy(dp->pl);18621862- return ret;18631863- }18571857+ }18581858+ if (ret) {18591859+ netdev_err(slave_dev, "failed to connect to PHY: %pe\n",18601860+ ERR_PTR(ret));18611861+ phylink_destroy(dp->pl);18641862 }1865186318661864 return ret;
···935935{936936 int err;937937938938- udp_tunnel_nic_workqueue = alloc_workqueue("udp_tunnel_nic", 0, 0);938938+ udp_tunnel_nic_workqueue = alloc_ordered_workqueue("udp_tunnel_nic", 0);939939 if (!udp_tunnel_nic_workqueue)940940 return -ENOMEM;941941
+1-2
net/ipv6/ip6_fib.c
···13781378 int err = -ENOMEM;13791379 int allow_create = 1;13801380 int replace_required = 0;13811381- int sernum = fib6_new_sernum(info->nl_net);1382138113831382 if (info->nlh) {13841383 if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))···14771478 if (!err) {14781479 if (rt->nh)14791480 list_add(&rt->nh_list, &rt->nh->f6i_list);14801480- __fib6_update_sernum_upto_root(rt, sernum);14811481+ __fib6_update_sernum_upto_root(rt, fib6_new_sernum(info->nl_net));14811482 fib6_start_gc(info->nl_net, rt);14821483 }14831484
···3073307330743074 other = unix_peer(sk);30753075 if (other && unix_peer(other) != sk &&30763076- unix_recvq_full(other) &&30763076+ unix_recvq_full_lockless(other) &&30773077 unix_dgram_peer_wake_me(sk, other))30783078 writable = 0;30793079
+5
scripts/Makefile.clang
···2929else3030CLANG_FLAGS += -fintegrated-as3131endif3232+# By default, clang only warns when it encounters an unknown warning flag or3333+# certain optimization flags it knows it has not implemented.3434+# Make it behave more like gcc by erroring when these flags are encountered3535+# so they can be implemented or wrapped in cc-option.3236CLANG_FLAGS += -Werror=unknown-warning-option3737+CLANG_FLAGS += -Werror=ignored-optimization-argument3338KBUILD_CFLAGS += $(CLANG_FLAGS)3439KBUILD_AFLAGS += $(CLANG_FLAGS)3540export CLANG_FLAGS
+1-1
scripts/Makefile.modpost
···1313# Stage 2 is handled by this file and does the following1414# 1) Find all modules listed in modules.order1515# 2) modpost is then used to1616-# 3) create one <module>.mod.c file pr. module1616+# 3) create one <module>.mod.c file per module1717# 4) create one Module.symvers file with CRC for all exported symbols18181919# Step 3 is used to place certain information in the module's ELF
+3-8
scripts/checkkconfigsymbols.py
···3434REGEX_KCONFIG_DEF = re.compile(DEF)3535REGEX_KCONFIG_EXPR = re.compile(EXPR)3636REGEX_KCONFIG_STMT = re.compile(STMT)3737-REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$")3837REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$")3938REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+")4039REGEX_QUOTES = re.compile("(\"(.*?)\")")···101102 "continue.")102103103104 if args.commit:105105+ if args.commit.startswith('HEAD'):106106+ sys.exit("The --commit option can't use the HEAD ref")107107+104108 args.find = False105109106110 if args.ignore:···434432 lines = []435433 defined = []436434 references = []437437- skip = False438435439436 if not os.path.exists(kfile):440437 return defined, references···449448 if REGEX_KCONFIG_DEF.match(line):450449 symbol_def = REGEX_KCONFIG_DEF.findall(line)451450 defined.append(symbol_def[0])452452- skip = False453453- elif REGEX_KCONFIG_HELP.match(line):454454- skip = True455455- elif skip:456456- # ignore content of help messages457457- pass458451 elif REGEX_KCONFIG_STMT.match(line):459452 line = REGEX_QUOTES.sub("", line)460453 symbols = get_symbols_in_line(line)
···1616# define __fallthrough __attribute__ ((fallthrough))1717#endif18181919-#if GCC_VERSION >= 403001919+#if __has_attribute(__error__)2020# define __compiletime_error(message) __attribute__((error(message)))2121-#endif /* GCC_VERSION >= 40300 */2121+#endif22222323/* &a[0] degrades to a pointer: a different type from an array */2424#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))···3838#endif3939#define __printf(a, b) __attribute__((format(printf, a, b)))4040#define __scanf(a, b) __attribute__((format(scanf, a, b)))4141-4242-#if GCC_VERSION >= 501004343-#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 14444-#endif
+3-137
tools/include/linux/overflow.h
···55#include <linux/compiler.h>6677/*88- * In the fallback code below, we need to compute the minimum and99- * maximum values representable in a given type. These macros may also1010- * be useful elsewhere, so we provide them outside the1111- * COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW block.1212- *1313- * It would seem more obvious to do something like88+ * We need to compute the minimum and maximum values representable in a given99+ * type. These macros may also be useful elsewhere. It would seem more obvious1010+ * to do something like:1411 *1512 * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0)1613 * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0)···3336#define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))3437#define type_min(T) ((T)((T)-type_max(T)-(T)1))35383636-3737-#ifdef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW3839/*3940 * For simplicity and code hygiene, the fallback code below insists on4041 * a, b and *d having the same type (similar to the min() and max()···6772 (void) (&__a == __d); \6873 __builtin_mul_overflow(__a, __b, __d); \6974})7070-7171-#else7272-7373-7474-/* Checking for unsigned overflow is relatively easy without causing UB. */7575-#define __unsigned_add_overflow(a, b, d) ({ \7676- typeof(a) __a = (a); \7777- typeof(b) __b = (b); \7878- typeof(d) __d = (d); \7979- (void) (&__a == &__b); \8080- (void) (&__a == __d); \8181- *__d = __a + __b; \8282- *__d < __a; \8383-})8484-#define __unsigned_sub_overflow(a, b, d) ({ \8585- typeof(a) __a = (a); \8686- typeof(b) __b = (b); \8787- typeof(d) __d = (d); \8888- (void) (&__a == &__b); \8989- (void) (&__a == __d); \9090- *__d = __a - __b; \9191- __a < __b; \9292-})9393-/*9494- * If one of a or b is a compile-time constant, this avoids a division.9595- */9696-#define __unsigned_mul_overflow(a, b, d) ({ \9797- typeof(a) __a = (a); \9898- typeof(b) __b = (b); \9999- typeof(d) __d = (d); \100100- (void) (&__a == &__b); \101101- (void) (&__a == __d); \102102- *__d = __a * __b; \103103- __builtin_constant_p(__b) ? \104104- __b > 0 && __a > type_max(typeof(__a)) / __b : \105105- __a > 0 && __b > type_max(typeof(__b)) / __a; \106106-})107107-108108-/*109109- * For signed types, detecting overflow is much harder, especially if110110- * we want to avoid UB. But the interface of these macros is such that111111- * we must provide a result in *d, and in fact we must produce the112112- * result promised by gcc's builtins, which is simply the possibly113113- * wrapped-around value. Fortunately, we can just formally do the114114- * operations in the widest relevant unsigned type (u64) and then115115- * truncate the result - gcc is smart enough to generate the same code116116- * with and without the (u64) casts.117117- */118118-119119-/*120120- * Adding two signed integers can overflow only if they have the same121121- * sign, and overflow has happened iff the result has the opposite122122- * sign.123123- */124124-#define __signed_add_overflow(a, b, d) ({ \125125- typeof(a) __a = (a); \126126- typeof(b) __b = (b); \127127- typeof(d) __d = (d); \128128- (void) (&__a == &__b); \129129- (void) (&__a == __d); \130130- *__d = (u64)__a + (u64)__b; \131131- (((~(__a ^ __b)) & (*__d ^ __a)) \132132- & type_min(typeof(__a))) != 0; \133133-})134134-135135-/*136136- * Subtraction is similar, except that overflow can now happen only137137- * when the signs are opposite. In this case, overflow has happened if138138- * the result has the opposite sign of a.139139- */140140-#define __signed_sub_overflow(a, b, d) ({ \141141- typeof(a) __a = (a); \142142- typeof(b) __b = (b); \143143- typeof(d) __d = (d); \144144- (void) (&__a == &__b); \145145- (void) (&__a == __d); \146146- *__d = (u64)__a - (u64)__b; \147147- ((((__a ^ __b)) & (*__d ^ __a)) \148148- & type_min(typeof(__a))) != 0; \149149-})150150-151151-/*152152- * Signed multiplication is rather hard. gcc always follows C99, so153153- * division is truncated towards 0. This means that we can write the154154- * overflow check like this:155155- *156156- * (a > 0 && (b > MAX/a || b < MIN/a)) ||157157- * (a < -1 && (b > MIN/a || b < MAX/a) ||158158- * (a == -1 && b == MIN)159159- *160160- * The redundant casts of -1 are to silence an annoying -Wtype-limits161161- * (included in -Wextra) warning: When the type is u8 or u16, the162162- * __b_c_e in check_mul_overflow obviously selects163163- * __unsigned_mul_overflow, but unfortunately gcc still parses this164164- * code and warns about the limited range of __b.165165- */166166-167167-#define __signed_mul_overflow(a, b, d) ({ \168168- typeof(a) __a = (a); \169169- typeof(b) __b = (b); \170170- typeof(d) __d = (d); \171171- typeof(a) __tmax = type_max(typeof(a)); \172172- typeof(a) __tmin = type_min(typeof(a)); \173173- (void) (&__a == &__b); \174174- (void) (&__a == __d); \175175- *__d = (u64)__a * (u64)__b; \176176- (__b > 0 && (__a > __tmax/__b || __a < __tmin/__b)) || \177177- (__b < (typeof(__b))-1 && (__a > __tmin/__b || __a < __tmax/__b)) || \178178- (__b == (typeof(__b))-1 && __a == __tmin); \179179-})180180-181181-182182-#define check_add_overflow(a, b, d) \183183- __builtin_choose_expr(is_signed_type(typeof(a)), \184184- __signed_add_overflow(a, b, d), \185185- __unsigned_add_overflow(a, b, d))186186-187187-#define check_sub_overflow(a, b, d) \188188- __builtin_choose_expr(is_signed_type(typeof(a)), \189189- __signed_sub_overflow(a, b, d), \190190- __unsigned_sub_overflow(a, b, d))191191-192192-#define check_mul_overflow(a, b, d) \193193- __builtin_choose_expr(is_signed_type(typeof(a)), \194194- __signed_mul_overflow(a, b, d), \195195- __unsigned_mul_overflow(a, b, d))196196-197197-198198-#endif /* COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW */1997520076/**20177 * array_size() - Calculate size of 2-dimensional array.
+41-23
tools/lib/perf/evsel.c
···4343 free(evsel);4444}45454646-#define FD(e, x, y) (*(int *) xyarray__entry(e->fd, x, y))4646+#define FD(e, x, y) ((int *) xyarray__entry(e->fd, x, y))4747#define MMAP(e, x, y) (e->mmap ? ((struct perf_mmap *) xyarray__entry(e->mmap, x, y)) : NULL)48484949int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)···5454 int cpu, thread;5555 for (cpu = 0; cpu < ncpus; cpu++) {5656 for (thread = 0; thread < nthreads; thread++) {5757- FD(evsel, cpu, thread) = -1;5757+ int *fd = FD(evsel, cpu, thread);5858+5959+ if (fd)6060+ *fd = -1;5861 }5962 }6063 }···8380static int get_group_fd(struct perf_evsel *evsel, int cpu, int thread, int *group_fd)8481{8582 struct perf_evsel *leader = evsel->leader;8686- int fd;8383+ int *fd;87848885 if (evsel == leader) {8986 *group_fd = -1;···9895 return -ENOTCONN;999610097 fd = FD(leader, cpu, thread);101101- if (fd == -1)9898+ if (fd == NULL || *fd == -1)10299 return -EBADF;103100104104- *group_fd = fd;101101+ *group_fd = *fd;105102106103 return 0;107104}···141138142139 for (cpu = 0; cpu < cpus->nr; cpu++) {143140 for (thread = 0; thread < threads->nr; thread++) {144144- int fd, group_fd;141141+ int fd, group_fd, *evsel_fd;142142+143143+ evsel_fd = FD(evsel, cpu, thread);144144+ if (evsel_fd == NULL)145145+ return -EINVAL;145146146147 err = get_group_fd(evsel, cpu, thread, &group_fd);147148 if (err < 0)···158151 if (fd < 0)159152 return -errno;160153161161- FD(evsel, cpu, thread) = fd;154154+ *evsel_fd = fd;162155 }163156 }164157···170163 int thread;171164172165 for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {173173- if (FD(evsel, cpu, thread) >= 0)174174- close(FD(evsel, cpu, thread));175175- FD(evsel, cpu, thread) = -1;166166+ int *fd = FD(evsel, cpu, thread);167167+168168+ if (fd && *fd >= 0) {169169+ close(*fd);170170+ *fd = -1;171171+ }176172 }177173}178174···219209220210 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) {221211 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {222222- int fd = FD(evsel, cpu, thread);223223- struct perf_mmap *map = MMAP(evsel, cpu, thread);212212+ int *fd = FD(evsel, cpu, thread);224213225225- if (fd < 0)214214+ if (fd == NULL || *fd < 0)226215 continue;227216228228- perf_mmap__munmap(map);217217+ perf_mmap__munmap(MMAP(evsel, cpu, thread));229218 }230219 }231220···248239249240 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) {250241 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {251251- int fd = FD(evsel, cpu, thread);252252- struct perf_mmap *map = MMAP(evsel, cpu, thread);242242+ int *fd = FD(evsel, cpu, thread);243243+ struct perf_mmap *map;253244254254- if (fd < 0)245245+ if (fd == NULL || *fd < 0)255246 continue;256247248248+ map = MMAP(evsel, cpu, thread);257249 perf_mmap__init(map, NULL, false, NULL);258250259259- ret = perf_mmap__mmap(map, &mp, fd, cpu);251251+ ret = perf_mmap__mmap(map, &mp, *fd, cpu);260252 if (ret) {261253 perf_evsel__munmap(evsel);262254 return ret;···270260271261void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu, int thread)272262{273273- if (FD(evsel, cpu, thread) < 0 || MMAP(evsel, cpu, thread) == NULL)263263+ int *fd = FD(evsel, cpu, thread);264264+265265+ if (fd == NULL || *fd < 0 || MMAP(evsel, cpu, thread) == NULL)274266 return NULL;275267276268 return MMAP(evsel, cpu, thread)->base;···307295 struct perf_counts_values *count)308296{309297 size_t size = perf_evsel__read_size(evsel);298298+ int *fd = FD(evsel, cpu, thread);310299311300 memset(count, 0, sizeof(*count));312301313313- if (FD(evsel, cpu, thread) < 0)302302+ if (fd == NULL || *fd < 0)314303 return -EINVAL;315304316305 if (MMAP(evsel, cpu, thread) &&317306 !perf_mmap__read_self(MMAP(evsel, cpu, thread), count))318307 return 0;319308320320- if (readn(FD(evsel, cpu, thread), count->values, size) <= 0)309309+ if (readn(*fd, count->values, size) <= 0)321310 return -errno;322311323312 return 0;···331318 int thread;332319333320 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {334334- int fd = FD(evsel, cpu, thread),335335- err = ioctl(fd, ioc, arg);321321+ int err;322322+ int *fd = FD(evsel, cpu, thread);323323+324324+ if (fd == NULL || *fd < 0)325325+ return -1;326326+327327+ err = ioctl(*fd, ioc, arg);336328337329 if (err)338330 return err;
+13-11
tools/perf/builtin-script.c
···368368 return OUTPUT_TYPE_OTHER;369369}370370371371-static inline unsigned int attr_type(unsigned int type)372372-{373373- switch (type) {374374- case OUTPUT_TYPE_SYNTH:375375- return PERF_TYPE_SYNTH;376376- default:377377- return type;378378- }379379-}380380-381371static bool output_set_by_user(void)382372{383373 int j;···546556 output[type].print_ip_opts |= EVSEL__PRINT_SRCLINE;547557}548558559559+static struct evsel *find_first_output_type(struct evlist *evlist,560560+ unsigned int type)561561+{562562+ struct evsel *evsel;563563+564564+ evlist__for_each_entry(evlist, evsel) {565565+ if (output_type(evsel->core.attr.type) == (int)type)566566+ return evsel;567567+ }568568+ return NULL;569569+}570570+549571/*550572 * verify all user requested events exist and the samples551573 * have the expected data···569567 struct evsel *evsel;570568571569 for (j = 0; j < OUTPUT_TYPE_MAX; ++j) {572572- evsel = perf_session__find_first_evtype(session, attr_type(j));570570+ evsel = find_first_output_type(session->evlist, j);573571574572 /*575573 * even if fields is set to 0 (ie., show nothing) event must
···1212#include <unistd.h>1313#include <ftw.h>14141515-1615#include "cgroup_helpers.h"17161817/*1918 * To avoid relying on the system setup, when setup_cgroup_env is called2020- * we create a new mount namespace, and cgroup namespace. The cgroup22121- * root is mounted at CGROUP_MOUNT_PATH1919+ * we create a new mount namespace, and cgroup namespace. The cgroupv22020+ * root is mounted at CGROUP_MOUNT_PATH. Unfortunately, most people don't2121+ * have cgroupv2 enabled at this point in time. It's easier to create our2222+ * own mount namespace and manage it ourselves. We assume /mnt exists.2223 *2323- * Unfortunately, most people don't have cgroupv2 enabled at this point in time.2424- * It's easier to create our own mount namespace and manage it ourselves.2525- *2626- * We assume /mnt exists.2424+ * Related cgroupv1 helpers are named *classid*(), since we only use the2525+ * net_cls controller for tagging net_cls.classid. We assume the default2626+ * mount under /sys/fs/cgroup/net_cls, which should be the case for the2727+ * vast majority of users.2728 */28292930#define WALK_FD_LIMIT 163131+3032#define CGROUP_MOUNT_PATH "/mnt"3333+#define CGROUP_MOUNT_DFLT "/sys/fs/cgroup"3434+#define NETCLS_MOUNT_PATH CGROUP_MOUNT_DFLT "/net_cls"3135#define CGROUP_WORK_DIR "/cgroup-test-work-dir"3636+3237#define format_cgroup_path(buf, path) \3338 snprintf(buf, sizeof(buf), "%s%s%s", CGROUP_MOUNT_PATH, \3439 CGROUP_WORK_DIR, path)4040+4141+#define format_classid_path(buf) \4242+ snprintf(buf, sizeof(buf), "%s%s", NETCLS_MOUNT_PATH, \4343+ CGROUP_WORK_DIR)35443645/**3746 * enable_all_controllers() - Enable all available cgroup v2 controllers···148139 return 0;149140}150141151151-152152-static int join_cgroup_from_top(char *cgroup_path)142142+static int join_cgroup_from_top(const char *cgroup_path)153143{154144 char cgroup_procs_path[PATH_MAX + 1];155145 pid_t pid = getpid();···320312 return -EINVAL;321313 }322314 return cg_fd;315315+}316316+317317+/**318318+ * setup_classid_environment() - Setup the cgroupv1 net_cls environment319319+ *320320+ * After calling this function, cleanup_classid_environment should be called321321+ * once testing is complete.322322+ *323323+ * This function will print an error to stderr and return 1 if it is unable324324+ * to setup the cgroup environment. If setup is successful, 0 is returned.325325+ */326326+int setup_classid_environment(void)327327+{328328+ char cgroup_workdir[PATH_MAX + 1];329329+330330+ format_classid_path(cgroup_workdir);331331+332332+ if (mount("tmpfs", CGROUP_MOUNT_DFLT, "tmpfs", 0, NULL) &&333333+ errno != EBUSY) {334334+ log_err("mount cgroup base");335335+ return 1;336336+ }337337+338338+ if (mkdir(NETCLS_MOUNT_PATH, 0777) && errno != EEXIST) {339339+ log_err("mkdir cgroup net_cls");340340+ return 1;341341+ }342342+343343+ if (mount("net_cls", NETCLS_MOUNT_PATH, "cgroup", 0, "net_cls") &&344344+ errno != EBUSY) {345345+ log_err("mount cgroup net_cls");346346+ return 1;347347+ }348348+349349+ cleanup_classid_environment();350350+351351+ if (mkdir(cgroup_workdir, 0777) && errno != EEXIST) {352352+ log_err("mkdir cgroup work dir");353353+ return 1;354354+ }355355+356356+ return 0;357357+}358358+359359+/**360360+ * set_classid() - Set a cgroupv1 net_cls classid361361+ * @id: the numeric classid362362+ *363363+ * Writes the passed classid into the cgroup work dir's net_cls.classid364364+ * file in order to later on trigger socket tagging.365365+ *366366+ * On success, it returns 0, otherwise on failure it returns 1. If there367367+ * is a failure, it prints the error to stderr.368368+ */369369+int set_classid(unsigned int id)370370+{371371+ char cgroup_workdir[PATH_MAX - 42];372372+ char cgroup_classid_path[PATH_MAX + 1];373373+ int fd, rc = 0;374374+375375+ format_classid_path(cgroup_workdir);376376+ snprintf(cgroup_classid_path, sizeof(cgroup_classid_path),377377+ "%s/net_cls.classid", cgroup_workdir);378378+379379+ fd = open(cgroup_classid_path, O_WRONLY);380380+ if (fd < 0) {381381+ log_err("Opening cgroup classid: %s", cgroup_classid_path);382382+ return 1;383383+ }384384+385385+ if (dprintf(fd, "%u\n", id) < 0) {386386+ log_err("Setting cgroup classid");387387+ rc = 1;388388+ }389389+390390+ close(fd);391391+ return rc;392392+}393393+394394+/**395395+ * join_classid() - Join a cgroupv1 net_cls classid396396+ *397397+ * This function expects the cgroup work dir to be already created, as we398398+ * join it here. This causes the process sockets to be tagged with the given399399+ * net_cls classid.400400+ *401401+ * On success, it returns 0, otherwise on failure it returns 1.402402+ */403403+int join_classid(void)404404+{405405+ char cgroup_workdir[PATH_MAX + 1];406406+407407+ format_classid_path(cgroup_workdir);408408+ return join_cgroup_from_top(cgroup_workdir);409409+}410410+411411+/**412412+ * cleanup_classid_environment() - Cleanup the cgroupv1 net_cls environment413413+ *414414+ * At call time, it moves the calling process to the root cgroup, and then415415+ * runs the deletion process.416416+ *417417+ * On failure, it will print an error to stderr, and try to continue.418418+ */419419+void cleanup_classid_environment(void)420420+{421421+ char cgroup_workdir[PATH_MAX + 1];422422+423423+ format_classid_path(cgroup_workdir);424424+ join_cgroup_from_top(NETCLS_MOUNT_PATH);425425+ nftw(cgroup_workdir, nftwfunc, WALK_FD_LIMIT, FTW_DEPTH | FTW_MOUNT);323426}
···11// SPDX-License-Identifier: GPL-2.02233-#include <linux/ptrace.h>44-#include <linux/bpf.h>33+#include "vmlinux.h"54#include <bpf/bpf_helpers.h>65#include <bpf/bpf_tracing.h>7688-struct pt_regs current_regs = {};99-struct pt_regs ctx_regs = {};77+#define PT_REGS_SIZE sizeof(struct pt_regs)88+99+/*1010+ * The kernel struct pt_regs isn't exported in its entirety to userspace.1111+ * Pass it as an array to task_pt_regs.c1212+ */1313+char current_regs[PT_REGS_SIZE] = {};1414+char ctx_regs[PT_REGS_SIZE] = {};1015int uprobe_res = 0;11161217SEC("uprobe/trigger_func")···22172318 current = bpf_get_current_task_btf();2419 regs = (struct pt_regs *) bpf_task_pt_regs(current);2525- __builtin_memcpy(¤t_regs, regs, sizeof(*regs));2626- __builtin_memcpy(&ctx_regs, ctx, sizeof(*ctx));2020+ if (bpf_probe_read_kernel(current_regs, PT_REGS_SIZE, regs))2121+ return 0;2222+ if (bpf_probe_read_kernel(ctx_regs, PT_REGS_SIZE, ctx))2323+ return 0;27242825 /* Prove that uprobe was run */2926 uprobe_res = 1;
+1-1
tools/testing/selftests/nci/nci_dev.c
···746746 const __u8 *rsp, __u32 rsp_len)747747{748748 char buf[256];749749- unsigned int len;749749+ int len;750750751751 send(nfc_sock, &cmd[3], cmd_len - 3, 0);752752 len = read(virtual_fd, buf, cmd_len);
+1-1
tools/testing/selftests/net/altnames.sh
···4545 check_err $? "Got unexpected long alternative name from link show JSON"46464747 ip link property del $DUMMY_DEV altname $SHORT_NAME4848- check_err $? "Failed to add short alternative name"4848+ check_err $? "Failed to delete short alternative name"49495050 ip -j -p link show $SHORT_NAME &>/dev/null5151 check_fail $? "Unexpected success while trying to do link show with deleted short alternative name"
···1919#include "utils.h"2020#include "tm.h"21212222+#ifndef PPC_FEATURE2_SCV2323+#define PPC_FEATURE2_SCV 0x00100000 /* scv syscall */2424+#endif2525+2226extern int getppid_tm_active(void);2327extern int getppid_tm_suspended(void);2828+extern int getppid_scv_tm_active(void);2929+extern int getppid_scv_tm_suspended(void);24302531unsigned retries = 0;26322733#define TEST_DURATION 10 /* seconds */28342929-pid_t getppid_tm(bool suspend)3535+pid_t getppid_tm(bool scv, bool suspend)3036{3137 int i;3238 pid_t pid;33393440 for (i = 0; i < TM_RETRIES; i++) {3535- if (suspend)3636- pid = getppid_tm_suspended();3737- else3838- pid = getppid_tm_active();4141+ if (suspend) {4242+ if (scv)4343+ pid = getppid_scv_tm_suspended();4444+ else4545+ pid = getppid_tm_suspended();4646+ } else {4747+ if (scv)4848+ pid = getppid_scv_tm_active();4949+ else5050+ pid = getppid_tm_active();5151+ }39524053 if (pid >= 0)4154 return pid;···9582 * Test a syscall within a suspended transaction and verify9683 * that it succeeds.9784 */9898- FAIL_IF(getppid_tm(true) == -1); /* Should succeed. */8585+ FAIL_IF(getppid_tm(false, true) == -1); /* Should succeed. */998610087 /*10188 * Test a syscall within an active transaction and verify that10289 * it fails with the correct failure code.10390 */104104- FAIL_IF(getppid_tm(false) != -1); /* Should fail... */9191+ FAIL_IF(getppid_tm(false, false) != -1); /* Should fail... */10592 FAIL_IF(!failure_is_persistent()); /* ...persistently... */10693 FAIL_IF(!failure_is_syscall()); /* ...with code syscall. */9494+9595+ /* Now do it all again with scv if it is available. */9696+ if (have_hwcap2(PPC_FEATURE2_SCV)) {9797+ FAIL_IF(getppid_tm(true, true) == -1); /* Should succeed. */9898+ FAIL_IF(getppid_tm(true, false) != -1); /* Should fail... */9999+ FAIL_IF(!failure_is_persistent()); /* ...persistently... */100100+ FAIL_IF(!failure_is_syscall()); /* ...with code syscall. */101101+ }102102+107103 gettimeofday(&now, 0);108104 }109105