···11-What: sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/cap11+What: /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/cap22Date: December 3, 200933KernelVersion: 2.6.3244Contact: dmaengine@vger.kernel.org55Description: Capabilities the DMA supports.Currently there are DMA_PQ, DMA_PQ_VAL,66 DMA_XOR,DMA_XOR_VAL,DMA_INTERRUPT.7788-What: sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_active88+What: /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_active99Date: December 3, 20091010KernelVersion: 2.6.321111Contact: dmaengine@vger.kernel.org1212Description: The number of descriptors active in the ring.13131414-What: sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_size1414+What: /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_size1515Date: December 3, 20091616KernelVersion: 2.6.321717Contact: dmaengine@vger.kernel.org1818Description: Descriptor ring size, total number of descriptors available.19192020-What: sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/version2020+What: /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/version2121Date: December 3, 20092222KernelVersion: 2.6.322323Contact: dmaengine@vger.kernel.org2424Description: Version of ioatdma device.25252626-What: sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/intr_coalesce2626+What: /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/intr_coalesce2727Date: August 8, 20172828KernelVersion: 4.142929Contact: dmaengine@vger.kernel.org
+1-1
Documentation/ABI/testing/sysfs-class-net
···152152 When an interface is under test, it cannot be expected153153 to pass packets as normal.154154155155-What: /sys/clas/net/<iface>/duplex155155+What: /sys/class/net/<iface>/duplex156156Date: October 2009157157KernelVersion: 2.6.33158158Contact: netdev@vger.kernel.org
···3232 | | vint | bit | | 0 |.....|63| vintx |3333 | +--------------+ +------------+ |3434 | |3535+ | Unmap |3636+ | +--------------+ |3737+ Unmapped events ---->| | umapidx |-------------------------> Globalevents3838+ | +--------------+ |3939+ | |3540 +-----------------------------------------+36413742 Configuration of these Intmap registers that maps global events to vint is···7469 "parent's input irq" specifies the base for parent irq7570 - description: |7671 "limit" specifies the limit for translation7272+7373+ ti,unmapped-event-sources:7474+ $ref: /schemas/types.yaml#definitions/phandle-array7575+ description:7676+ Array of phandles to DMA controllers where the unmapped events originate.77777878required:7979 - compatible
+6
Documentation/filesystems/ext4/journal.rst
···256256 - s\_padding2257257 -258258 * - 0x54259259+ - \_\_be32260260+ - s\_num\_fc\_blocks261261+ - Number of fast commit blocks in the journal.262262+ * - 0x58259263 - \_\_u32260264 - s\_padding[42]261265 -···314310 - This journal uses v3 of the checksum on-disk format. This is the same as315311 v2, but the journal block tag size is fixed regardless of the size of316312 block numbers. (JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3)313313+ * - 0x20314314+ - Journal has fast commit blocks. (JBD2\_FEATURE\_INCOMPAT\_FAST\_COMMIT)317315318316.. _jbd2_checksum_type:319317
+7
Documentation/filesystems/ext4/super.rst
···596596 - Sparse Super Block, v2. If this flag is set, the SB field s\_backup\_bgs597597 points to the two block groups that contain backup superblocks598598 (COMPAT\_SPARSE\_SUPER2).599599+ * - 0x400600600+ - Fast commits supported. Although fast commits blocks are601601+ backward incompatible, fast commit blocks are not always602602+ present in the journal. If fast commit blocks are present in603603+ the journal, JBD2 incompat feature604604+ (JBD2\_FEATURE\_INCOMPAT\_FAST\_COMMIT) gets605605+ set (COMPAT\_FAST\_COMMIT).599606600607.. _super_incompat:601608
+2-4
Documentation/filesystems/journalling.rst
···136136~~~~~~~~~~~~137137138138JBD2 to also allows you to perform file-system specific delta commits known as139139-fast commits. In order to use fast commits, you first need to call140140-:c:func:`jbd2_fc_init` and tell how many blocks at the end of journal141141-area should be reserved for fast commits. Along with that, you will also need142142-to set following callbacks that perform correspodning work:139139+fast commits. In order to use fast commits, you will need to set following140140+callbacks that perform correspodning work:143141144142`journal->j_fc_cleanup_cb`: Cleanup function called after every full commit and145143fast commit.
+4-4
Documentation/firmware-guide/acpi/acpi-lid.rst
···19192020For most platforms, both the _LID method and the lid notifications are2121reliable. However, there are exceptions. In order to work with these2222-exceptional buggy platforms, special restrictions and expections should be2222+exceptional buggy platforms, special restrictions and exceptions should be2323taken into account. This document describes the restrictions and the2424-expections of the Linux ACPI lid device driver.2424+exceptions of the Linux ACPI lid device driver.252526262727Restrictions of the returning value of the _LID control method···4646trigger some system power saving operations on Windows. Since it is fully4747tested, it is reliable from all AML tables.48484949-Expections for the userspace users of the ACPI lid device driver4949+Exceptions for the userspace users of the ACPI lid device driver5050================================================================51515252The ACPI button driver exports the lid state to the userspace via the···100100C. button.lid_init_state=ignore:101101 When this option is specified, the ACPI button driver never reports the102102 initial lid state and there is a compensation mechanism implemented to103103- ensure that the reliable "closed" notifications can always be delievered103103+ ensure that the reliable "closed" notifications can always be delivered104104 to the userspace by always pairing "closed" input events with complement105105 "opened" input events. But there is still no guarantee that the "opened"106106 notifications can be delivered to the userspace when the lid is actually
···20202121 Name (_CRS, ResourceTemplate ()2222 {2323- GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,2323+ GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly,2424 "\\_SB.GPO0", 0, ResourceConsumer) {15}2525- GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,2525+ GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly,2626 "\\_SB.GPO0", 0, ResourceConsumer) {27, 31}2727 })2828···4949pin5050 Pin in the GpioIo()/GpioInt() resource. Typically this is zero.5151active_low5252- If 1 the GPIO is marked as active_low.5252+ If 1, the GPIO is marked as active_low.53535454Since ACPI GpioIo() resource does not have a field saying whether it is5555active low or high, the "active_low" argument can be used here. Setting5656it to 1 marks the GPIO as active low.57575858+Note, active_low in _DSD does not make sense for GpioInt() resource and5959+must be 0. GpioInt() resource has its own means of defining it.6060+5861In our Bluetooth example the "reset-gpios" refers to the second GpioIo()5962resource, second pin in that resource with the GPIO number of 31.6363+6464+The GpioIo() resource unfortunately doesn't explicitly provide an initial6565+state of the output pin which driver should use during its initialization.6666+6767+Linux tries to use common sense here and derives the state from the bias6868+and polarity settings. The table below shows the expectations:6969+7070+========= ============= ==============7171+Pull Bias Polarity Requested...7272+========= ============= ==============7373+Implicit x AS IS (assumed firmware configured for us)7474+Explicit x (no _DSD) as Pull Bias (Up == High, Down == Low),7575+ assuming non-active (Polarity = !Pull Bias)7676+Down Low as low, assuming active7777+Down High as low, assuming non-active7878+Up Low as high, assuming non-active7979+Up High as high, assuming active8080+========= ============= ==============8181+8282+That said, for our above example the both GPIOs, since the bias setting8383+is explicit and _DSD is present, will be treated as active with a high8484+polarity and Linux will configure the pins in this state until a driver8585+reprograms them differently.60866187It is possible to leave holes in the array of GPIOs. This is useful in6288cases like with SPI host controllers where some chip selects may be···138112 Package () {139113 "gpio-line-names",140114 Package () {141141- "SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD", "MUX7_IO",142142- "LVL_C_A1", "MUX0_IO", "SPI1_MISO"115115+ "SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD",116116+ "MUX7_IO", "LVL_C_A1", "MUX0_IO", "SPI1_MISO",143117 }144118 }145119···163137mapping between those names and the ACPI GPIO resources corresponding to them.164138165139To do that, the driver needs to define a mapping table as a NULL-terminated166166-array of struct acpi_gpio_mapping objects that each contain a name, a pointer140140+array of struct acpi_gpio_mapping objects that each contains a name, a pointer167141to an array of line data (struct acpi_gpio_params) objects and the size of that168142array. Each struct acpi_gpio_params object consists of three fields,169143crs_entry_index, line_index, active_low, representing the index of the target···180154 static const struct acpi_gpio_mapping bluetooth_acpi_gpios[] = {181155 { "reset-gpios", &reset_gpio, 1 },182156 { "shutdown-gpios", &shutdown_gpio, 1 },183183- { },157157+ { }184158 };185159186160Next, the mapping table needs to be passed as the second argument to187187-acpi_dev_add_driver_gpios() that will register it with the ACPI device object188188-pointed to by its first argument. That should be done in the driver's .probe()189189-routine. On removal, the driver should unregister its GPIO mapping table by161161+acpi_dev_add_driver_gpios() or its managed analogue that will162162+register it with the ACPI device object pointed to by its first163163+argument. That should be done in the driver's .probe() routine.164164+On removal, the driver should unregister its GPIO mapping table by190165calling acpi_dev_remove_driver_gpios() on the ACPI device object where that191166table was previously registered.192167···218191but since there is no way to know the mapping between "reset" and219192the GpioIo() in _CRS desc will hold ERR_PTR(-ENOENT).220193221221-The driver author can solve this by passing the mapping explictly222222-(the recommended way and documented in the above chapter).194194+The driver author can solve this by passing the mapping explicitly195195+(this is the recommended way and it's documented in the above chapter).223196224197The ACPI GPIO mapping tables should not contaminate drivers that are not225198knowing about which exact device they are servicing on. It implies that226226-the ACPI GPIO mapping tables are hardly linked to ACPI ID and certain199199+the ACPI GPIO mapping tables are hardly linked to an ACPI ID and certain227200objects, as listed in the above chapter, of the device in question.228201229202Getting GPIO descriptor···256229Be aware that gpiod_get_index() in cases 1 and 2, assuming that there257230are two versions of ACPI device description provided and no mapping is258231present in the driver, will return different resources. That's why a259259-certain driver has to handle them carefully as explained in previous232232+certain driver has to handle them carefully as explained in the previous260233chapter.
···9898 [ 0.188903] exdebug-0398 ex_trace_point : Method End [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.9999100100Developers can utilize these special log entries to track the AML101101-interpretion, thus can aid issue debugging and performance tuning. Note101101+interpretation, thus can aid issue debugging and performance tuning. Note102102that, as the "AML tracer" logs are implemented via ACPI_DEBUG_PRINT()103103macro, CONFIG_ACPI_DEBUG is also required to be enabled for enabling104104"AML tracer" logs.
···110110Q: How can I tell whether it got merged?111111A: Start by looking at the main patchworks queue for netdev:112112113113- http://patchwork.ozlabs.org/project/netdev/list/113113+ https://patchwork.kernel.org/project/netdevbpf/list/114114115115The "State" field will tell you exactly where things are at with your116116patch.···152152153153There is a patchworks queue that you can see here:154154155155- http://patchwork.ozlabs.org/bundle/davem/stable/?state=*155155+ https://patchwork.kernel.org/bundle/netdev/stable/?state=*156156157157It contains the patches which Dave has selected, but not yet handed off158158to Greg. If Greg already has the patch, then it will be here:
+2-2
Documentation/networking/phy.rst
···247247 speeds (see below.)248248249249``PHY_INTERFACE_MODE_2500BASEX``250250- This defines a variant of 1000BASE-X which is clocked 2.5 times faster,251251- than the 802.3 standard giving a fixed bit rate of 3.125Gbaud.250250+ This defines a variant of 1000BASE-X which is clocked 2.5 times as fast251251+ as the 802.3 standard, giving a fixed bit rate of 3.125Gbaud.252252253253``PHY_INTERFACE_MODE_SGMII``254254 This is used for Cisco SGMII, which is a modification of 1000BASE-X
+1-1
Documentation/process/stable-kernel-rules.rst
···3939 submission guidelines as described in4040 :ref:`Documentation/networking/netdev-FAQ.rst <netdev-FAQ>`4141 after first checking the stable networking queue at4242- https://patchwork.ozlabs.org/bundle/davem/stable/?series=&submitter=&state=*&q=&archive=4242+ https://patchwork.kernel.org/bundle/netdev/stable/?state=*4343 to ensure the requested patch is not already queued up.4444 - Security patches should not be handled (solely) by the -stable review4545 process but should follow the procedures in
···4646 :ref:`Documentation/translations/it_IT/networking/netdev-FAQ.rst <it_netdev-FAQ>`;4747 ma solo dopo aver verificato al seguente indirizzo che la patch non sia4848 già in coda:4949- https://patchwork.ozlabs.org/bundle/davem/stable/?series=&submitter=&state=*&q=&archive=4949+ https://patchwork.kernel.org/bundle/netdev/stable/?state=*5050 - Una patch di sicurezza non dovrebbero essere gestite (solamente) dal processo5151 di revisione -stable, ma dovrebbe seguire le procedure descritte in5252 :ref:`Documentation/translations/it_IT/admin-guide/security-bugs.rst <it_securitybugs>`.
+2-3
Documentation/virt/kvm/api.rst
···63676367instead get bounced to user space through the KVM_EXIT_X86_RDMSR and63686368KVM_EXIT_X86_WRMSR exit notifications.6369636963706370-8.25 KVM_X86_SET_MSR_FILTER63706370+8.27 KVM_X86_SET_MSR_FILTER63716371---------------------------6372637263736373:Architectures: x86···63816381trap and emulate MSRs that are outside of the scope of KVM as well as63826382limit the attack surface on KVM's MSR emulation code.6383638363846384-63856385-8.26 KVM_CAP_ENFORCE_PV_CPUID63846384+8.28 KVM_CAP_ENFORCE_PV_CPUID63866385-----------------------------6387638663886387Architectures: x86
···6363static inline bool6464bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)6565{6666- return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xf0000000),6666+ return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xff000000),6767 "Bug: fault blocked by AP register !");6868}6969
+14-31
arch/powerpc/include/asm/nohash/32/mmu-8xx.h
···3333 * respectively NA for All or X for Supervisor and no access for User.3434 * Then we use the APG to say whether accesses are according to Page rules or3535 * "all Supervisor" rules (Access to all)3636- * Therefore, we define 2 APG groups. lsb is _PMD_USER3737- * 0 => Kernel => 01 (all accesses performed according to page definition)3838- * 1 => User => 00 (all accesses performed as supervisor iaw page definition)3939- * 2-15 => Not Used3636+ * _PAGE_ACCESSED is also managed via APG. When _PAGE_ACCESSED is not set, say3737+ * "all User" rules, that will lead to NA for all.3838+ * Therefore, we define 4 APG groups. lsb is _PAGE_ACCESSED3939+ * 0 => Kernel => 11 (all accesses performed according as user iaw page definition)4040+ * 1 => Kernel+Accessed => 01 (all accesses performed according to page definition)4141+ * 2 => User => 11 (all accesses performed according as user iaw page definition)4242+ * 3 => User+Accessed => 00 (all accesses performed as supervisor iaw page definition) for INIT4343+ * => 10 (all accesses performed according to swaped page definition) for KUEP4444+ * 4-15 => Not Used4045 */4141-#define MI_APG_INIT 0x400000004242-4343-/*4444- * 0 => Kernel => 01 (all accesses performed according to page definition)4545- * 1 => User => 10 (all accesses performed according to swaped page definition)4646- * 2-15 => Not Used4747- */4848-#define MI_APG_KUEP 0x600000004646+#define MI_APG_INIT 0xdc0000004747+#define MI_APG_KUEP 0xde00000049485049/* The effective page number register. When read, contains the information5150 * about the last instruction TLB miss. When MI_RPN is written, bits in···105106#define MD_Ks 0x80000000 /* Should not be set */106107#define MD_Kp 0x40000000 /* Should always be set */107108108108-/*109109- * All pages' PP data bits are set to either 000 or 011 or 001, which means110110- * respectively RW for Supervisor and no access for User, or RO for111111- * Supervisor and no access for user and NA for ALL.112112- * Then we use the APG to say whether accesses are according to Page rules or113113- * "all Supervisor" rules (Access to all)114114- * Therefore, we define 2 APG groups. lsb is _PMD_USER115115- * 0 => Kernel => 01 (all accesses performed according to page definition)116116- * 1 => User => 00 (all accesses performed as supervisor iaw page definition)117117- * 2-15 => Not Used118118- */119119-#define MD_APG_INIT 0x40000000120120-121121-/*122122- * 0 => No user => 01 (all accesses performed according to page definition)123123- * 1 => User => 10 (all accesses performed according to swaped page definition)124124- * 2-15 => Not Used125125- */126126-#define MD_APG_KUAP 0x60000000109109+/* See explanation above at the definition of MI_APG_INIT */110110+#define MD_APG_INIT 0xdc000000111111+#define MD_APG_KUAP 0xde000000127112128113/* The effective page number register. When read, contains the information129114 * about the last instruction TLB miss. When MD_RPN is written, bits in
+5-4
arch/powerpc/include/asm/nohash/32/pte-8xx.h
···3939 * into the TLB.4040 */4141#define _PAGE_GUARDED 0x0010 /* Copied to L1 G entry in DTLB */4242-#define _PAGE_SPECIAL 0x0020 /* SW entry */4242+#define _PAGE_ACCESSED 0x0020 /* Copied to L1 APG 1 entry in I/DTLB */4343#define _PAGE_EXEC 0x0040 /* Copied to PP (bit 21) in ITLB */4444-#define _PAGE_ACCESSED 0x0080 /* software: page referenced */4444+#define _PAGE_SPECIAL 0x0080 /* SW entry */45454646#define _PAGE_NA 0x0200 /* Supervisor NA, User no access */4747#define _PAGE_RO 0x0600 /* Supervisor RO, User no access */···59596060#define _PMD_PRESENT 0x00016161#define _PMD_PRESENT_MASK _PMD_PRESENT6262-#define _PMD_BAD 0x0fd06262+#define _PMD_BAD 0x0f906363#define _PMD_PAGE_MASK 0x000c6464#define _PMD_PAGE_8M 0x000c6565#define _PMD_PAGE_512K 0x00046666-#define _PMD_USER 0x0020 /* APG 1 */6666+#define _PMD_ACCESSED 0x0020 /* APG 1 */6767+#define _PMD_USER 0x0040 /* APG 2 */67686869#define _PTE_NONE_MASK 06970
···202202203203InstructionTLBMiss:204204 mtspr SPRN_SPRG_SCRATCH0, r10205205-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)206205 mtspr SPRN_SPRG_SCRATCH1, r11207207-#endif208206209207 /* If we are faulting a kernel address, we have to use the210208 * kernel page tables.···2222243:223225 mtcr r11224226#endif225225-#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)226227 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */227228 mtspr SPRN_MD_TWC, r11228228-#else229229- lwz r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */230230- mtspr SPRN_MI_TWC, r10 /* Set segment attributes */231231- mtspr SPRN_MD_TWC, r10232232-#endif233229 mfspr r10, SPRN_MD_TWC234230 lwz r10, 0(r10) /* Get the pte */235235-#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)231231+ rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED236232 rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K237233 mtspr SPRN_MI_TWC, r11238238-#endif239239-#ifdef CONFIG_SWAP240240- rlwinm r11, r10, 32-5, _PAGE_PRESENT241241- and r11, r11, r10242242- rlwimi r10, r11, 0, _PAGE_PRESENT243243-#endif244234 /* The Linux PTE won't go exactly into the MMU TLB.245235 * Software indicator bits 20 and 23 must be clear.246236 * Software indicator bits 22, 24, 25, 26, and 27 must be···242256243257 /* Restore registers */2442580: mfspr r10, SPRN_SPRG_SCRATCH0245245-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)246259 mfspr r11, SPRN_SPRG_SCRATCH1247247-#endif248260 rfi249261 patch_site 0b, patch__itlbmiss_exit_1250262···252268 addi r10, r10, 1253269 stw r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)254270 mfspr r10, SPRN_SPRG_SCRATCH0255255-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)256271 mfspr r11, SPRN_SPRG_SCRATCH1257257-#endif258272 rfi259273#endif260274···279297 mfspr r10, SPRN_MD_TWC280298 lwz r10, 0(r10) /* Get the pte */281299282282- /* Insert the Guarded flag into the TWC from the Linux PTE.300300+ /* Insert Guarded and Accessed flags into the TWC from the Linux PTE.283301 * It is bit 27 of both the Linux PTE and the TWC (at least284302 * I got that right :-). It will be better when we can put285303 * this into the Linux pgd/pmd and load it in the operation286304 * above.287305 */288288- rlwimi r11, r10, 0, _PAGE_GUARDED306306+ rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED289307 rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K290308 mtspr SPRN_MD_TWC, r11291309292292- /* Both _PAGE_ACCESSED and _PAGE_PRESENT has to be set.293293- * We also need to know if the insn is a load/store, so:294294- * Clear _PAGE_PRESENT and load that which will295295- * trap into DTLB Error with store bit set accordinly.296296- */297297- /* PRESENT=0x1, ACCESSED=0x20298298- * r11 = ((r10 & PRESENT) & ((r10 & ACCESSED) >> 5));299299- * r10 = (r10 & ~PRESENT) | r11;300300- */301301-#ifdef CONFIG_SWAP302302- rlwinm r11, r10, 32-5, _PAGE_PRESENT303303- and r11, r11, r10304304- rlwimi r10, r11, 0, _PAGE_PRESENT305305-#endif306310 /* The Linux PTE won't go exactly into the MMU TLB.307311 * Software indicator bits 24, 25, 26, and 27 must be308312 * set. All other Linux PTE bits control the behavior···679711 li r9, 4 /* up to 4 pages of 8M */680712 mtctr r9681713 lis r9, KERNELBASE@h /* Create vaddr for TLB */682682- li r10, MI_PS8MEG | MI_SVALID /* Set 8M byte page */714714+ li r10, MI_PS8MEG | _PMD_ACCESSED | MI_SVALID683715 li r11, MI_BOOTINIT /* Create RPN for address 0 */6847161:685717 mtspr SPRN_MI_CTR, r8 /* Set instruction MMU control */···743775#ifdef CONFIG_PIN_TLB_TEXT744776 LOAD_REG_IMMEDIATE(r5, 28 << 8)745777 LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)746746- LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)778778+ LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)747779 LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_RO | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT)748780 LOAD_REG_ADDR(r9, _sinittext)749781 li r0, 4···765797 LOAD_REG_IMMEDIATE(r5, 28 << 8 | MD_TWAM)766798#ifdef CONFIG_PIN_TLB_DATA767799 LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)768768- LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)800800+ LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)769801#ifdef CONFIG_PIN_TLB_IMMR770802 li r0, 3771803#else···802834#endif803835#ifdef CONFIG_PIN_TLB_IMMR804836 LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID)805805- LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED)837837+ LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED | _PMD_ACCESSED)806838 mfspr r8, SPRN_IMMR807839 rlwinm r8, r8, 0, 0xfff80000808840 ori r8, r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \
-12
arch/powerpc/kernel/head_book3s_32.S
···457457 cmplw 0,r1,r3458458#endif459459 mfspr r2, SPRN_SPRG_PGDIR460460-#ifdef CONFIG_SWAP461460 li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC462462-#else463463- li r1,_PAGE_PRESENT | _PAGE_EXEC464464-#endif465461#if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC)466462 bgt- 112f467463 lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */···519523 lis r1, TASK_SIZE@h /* check if kernel address */520524 cmplw 0,r1,r3521525 mfspr r2, SPRN_SPRG_PGDIR522522-#ifdef CONFIG_SWAP523526 li r1, _PAGE_PRESENT | _PAGE_ACCESSED524524-#else525525- li r1, _PAGE_PRESENT526526-#endif527527 bgt- 112f528528 lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */529529 addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */···595603 lis r1, TASK_SIZE@h /* check if kernel address */596604 cmplw 0,r1,r3597605 mfspr r2, SPRN_SPRG_PGDIR598598-#ifdef CONFIG_SWAP599606 li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED600600-#else601601- li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT602602-#endif603607 bgt- 112f604608 lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */605609 addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */
+2-1
arch/powerpc/kernel/smp.c
···13931393/* Activate a secondary processor. */13941394void start_secondary(void *unused)13951395{13961396- unsigned int cpu = smp_processor_id();13961396+ unsigned int cpu = raw_smp_processor_id();1397139713981398 mmgrab(&init_mm);13991399 current->active_mm = &init_mm;1400140014011401 smp_store_cpu_info(cpu);14021402 set_dec(tb_ticks_per_jiffy);14031403+ rcu_cpu_starting(cpu);14031404 preempt_disable();14041405 cpu_callin_map[cpu] = 1;14051406
+1-1
arch/riscv/include/asm/uaccess.h
···476476do { \477477 long __kr_err; \478478 \479479- __put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \479479+ __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \480480 if (unlikely(__kr_err)) \481481 goto err_label; \482482} while (0)
···4343SYSCFLAGS_vdso.so.dbg = $(c_flags)4444$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE4545 $(call if_changed,vdsold)4646+SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \4747+ -Wl,--build-id -Wl,--hash-style=both46484749# We also create a special relocatable object that should mirror the symbol4850# table and layout of the linked DSO. With ld --just-symbols we can then4951# refer to these symbols in the kernel code rather than hand-coded addresses.5050-5151-SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \5252- -Wl,--build-id=sha1 -Wl,--hash-style=both5353-$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE5454- $(call if_changed,vdsold)5555-5656-LDFLAGS_vdso-syms.o := -r --just-symbols5757-$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE5858- $(call if_changed,ld)5252+$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE5353+ $(call if_changed,so2s)59546055# strip rule for the .so file6156$(obj)/%.so: OBJCOPYFLAGS := -S···6772 $(CROSS_COMPILE)objcopy \6873 $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \6974 rm $@.tmp7575+7676+# Extracts symbol offsets from the VDSO, converting them into an assembly file7777+# that contains the same symbols at the same offsets.7878+quiet_cmd_so2s = SO2S $@7979+ cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@70807181# install commands for the unstripped file7282quiet_cmd_vdso_install = INSTALL $@
···8686 pmd_t *pmd, *pmd_k;8787 pte_t *pte_k;8888 int index;8989+ unsigned long pfn;89909091 /* User mode accesses just cause a SIGSEGV */9192 if (user_mode(regs))···101100 * of a task switch.102101 */103102 index = pgd_index(addr);104104- pgd = (pgd_t *)pfn_to_virt(csr_read(CSR_SATP)) + index;103103+ pfn = csr_read(CSR_SATP) & SATP_PPN;104104+ pgd = (pgd_t *)pfn_to_virt(pfn) + index;105105 pgd_k = init_mm.pgd + index;106106107107 if (!pgd_present(*pgd_k)) {
+21-11
arch/riscv/mm/init.c
···154154155155void __init setup_bootmem(void)156156{157157- phys_addr_t mem_size = 0;158158- phys_addr_t total_mem = 0;159159- phys_addr_t mem_start, start, end = 0;157157+ phys_addr_t mem_start = 0;158158+ phys_addr_t start, end = 0;160159 phys_addr_t vmlinux_end = __pa_symbol(&_end);161160 phys_addr_t vmlinux_start = __pa_symbol(&_start);162161 u64 i;···163164 /* Find the memory region containing the kernel */164165 for_each_mem_range(i, &start, &end) {165166 phys_addr_t size = end - start;166166- if (!total_mem)167167+ if (!mem_start)167168 mem_start = start;168169 if (start <= vmlinux_start && vmlinux_end <= end)169170 BUG_ON(size == 0);170170- total_mem = total_mem + size;171171 }172172173173 /*174174- * Remove memblock from the end of usable area to the175175- * end of region174174+ * The maximal physical memory size is -PAGE_OFFSET.175175+ * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed176176+ * as it is unusable by kernel.176177 */177177- mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET);178178- if (mem_start + mem_size < end)179179- memblock_remove(mem_start + mem_size,180180- end - mem_start - mem_size);178178+ memblock_enforce_memory_limit(mem_start - PAGE_OFFSET);181179182180 /* Reserve from the start of the kernel to the end of the kernel */183181 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);···293297#define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE)294298#endif295299pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE);300300+pmd_t early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);296301297302static pmd_t *__init get_pmd_virt_early(phys_addr_t pa)298303{···491494 load_pa + (va - PAGE_OFFSET),492495 map_size, PAGE_KERNEL_EXEC);493496497497+#ifndef __PAGETABLE_PMD_FOLDED498498+ /* Setup early PMD for DTB */499499+ create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,500500+ (uintptr_t)early_dtb_pmd, PGDIR_SIZE, PAGE_TABLE);501501+ /* Create two consecutive PMD mappings for FDT early scan */502502+ pa = dtb_pa & ~(PMD_SIZE - 1);503503+ create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,504504+ pa, PMD_SIZE, PAGE_KERNEL);505505+ create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA + PMD_SIZE,506506+ pa + PMD_SIZE, PMD_SIZE, PAGE_KERNEL);507507+ dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PMD_SIZE - 1));508508+#else494509 /* Create two consecutive PGD mappings for FDT early scan */495510 pa = dtb_pa & ~(PGDIR_SIZE - 1);496511 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,···510501 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA + PGDIR_SIZE,511502 pa + PGDIR_SIZE, PGDIR_SIZE, PAGE_KERNEL);512503 dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PGDIR_SIZE - 1));504504+#endif513505 dtb_early_pa = dtb_pa;514506515507 /*
+18-5
arch/x86/kernel/apic/x2apic_uv_x.c
···290290{291291 /* Relies on 'to' being NULL chars so result will be NULL terminated */292292 strncpy(to, from, len-1);293293+294294+ /* Trim trailing spaces */295295+ (void)strim(to);293296}294297295298/* Find UV arch type entry in UVsystab */···369366 return ret;370367}371368372372-static int __init uv_set_system_type(char *_oem_id)369369+static int __init uv_set_system_type(char *_oem_id, char *_oem_table_id)373370{374371 /* Save OEM_ID passed from ACPI MADT */375372 uv_stringify(sizeof(oem_id), oem_id, _oem_id);···389386 /* (Not hubless), not a UV */390387 return 0;391388389389+ /* Is UV hubless system */390390+ uv_hubless_system = 0x01;391391+392392+ /* UV5 Hubless */393393+ if (strncmp(uv_archtype, "NSGI5", 5) == 0)394394+ uv_hubless_system |= 0x20;395395+392396 /* UV4 Hubless: CH */393393- if (strncmp(uv_archtype, "NSGI4", 5) == 0)394394- uv_hubless_system = 0x11;397397+ else if (strncmp(uv_archtype, "NSGI4", 5) == 0)398398+ uv_hubless_system |= 0x10;395399396400 /* UV3 Hubless: UV300/MC990X w/o hub */397401 else398398- uv_hubless_system = 0x9;402402+ uv_hubless_system |= 0x8;403403+404404+ /* Copy APIC type */405405+ uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id);399406400407 pr_info("UV: OEM IDs %s/%s, SystemType %d, HUBLESS ID %x\n",401408 oem_id, oem_table_id, uv_system_type, uv_hubless_system);···469456 uv_cpu_info->p_uv_hub_info = &uv_hub_info_node0;470457471458 /* If not UV, return. */472472- if (likely(uv_set_system_type(_oem_id) == 0))459459+ if (uv_set_system_type(_oem_id, _oem_table_id) == 0)473460 return 0;474461475462 /* Save and Decode OEM Table ID */
+33-18
arch/x86/kernel/cpu/bugs.c
···12541254 return 0;12551255}1256125612571257+static bool is_spec_ib_user_controlled(void)12581258+{12591259+ return spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL ||12601260+ spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||12611261+ spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL ||12621262+ spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP;12631263+}12641264+12571265static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)12581266{12591267 switch (ctrl) {···12691261 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&12701262 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)12711263 return 0;12641264+12721265 /*12731273- * Indirect branch speculation is always disabled in strict12741274- * mode. It can neither be enabled if it was force-disabled12751275- * by a previous prctl call.12661266+ * With strict mode for both IBPB and STIBP, the instruction12671267+ * code paths avoid checking this task flag and instead,12681268+ * unconditionally run the instruction. However, STIBP and IBPB12691269+ * are independent and either can be set to conditionally12701270+ * enabled regardless of the mode of the other.12711271+ *12721272+ * If either is set to conditional, allow the task flag to be12731273+ * updated, unless it was force-disabled by a previous prctl12741274+ * call. Currently, this is possible on an AMD CPU which has the12751275+ * feature X86_FEATURE_AMD_STIBP_ALWAYS_ON. In this case, if the12761276+ * kernel is booted with 'spectre_v2_user=seccomp', then12771277+ * spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP and12781278+ * spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED.12761279 */12771277- if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||12781278- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||12791279- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED ||12801280+ if (!is_spec_ib_user_controlled() ||12801281 task_spec_ib_force_disable(task))12811282 return -EPERM;12831283+12821284 task_clear_spec_ib_disable(task);12831285 task_update_spec_tif(task);12841286 break;···13011283 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&13021284 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)13031285 return -EPERM;13041304- if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||13051305- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||13061306- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)12861286+12871287+ if (!is_spec_ib_user_controlled())13071288 return 0;12891289+13081290 task_set_spec_ib_disable(task);13091291 if (ctrl == PR_SPEC_FORCE_DISABLE)13101292 task_set_spec_ib_force_disable(task);···13691351 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&13701352 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)13711353 return PR_SPEC_ENABLE;13721372- else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||13731373- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||13741374- spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)13751375- return PR_SPEC_DISABLE;13761376- else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL ||13771377- spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||13781378- spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL ||13791379- spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP) {13541354+ else if (is_spec_ib_user_controlled()) {13801355 if (task_spec_ib_force_disable(task))13811356 return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE;13821357 if (task_spec_ib_disable(task))13831358 return PR_SPEC_PRCTL | PR_SPEC_DISABLE;13841359 return PR_SPEC_PRCTL | PR_SPEC_ENABLE;13851385- } else13601360+ } else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||13611361+ spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||13621362+ spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)13631363+ return PR_SPEC_DISABLE;13641364+ else13861365 return PR_SPEC_NOT_AFFECTED;13871366}13881367
+16-7
arch/x86/kvm/cpuid.c
···9090 return 0;9191}92929393+void kvm_update_pv_runtime(struct kvm_vcpu *vcpu)9494+{9595+ struct kvm_cpuid_entry2 *best;9696+9797+ best = kvm_find_cpuid_entry(vcpu, KVM_CPUID_FEATURES, 0);9898+9999+ /*100100+ * save the feature bitmap to avoid cpuid lookup for every PV101101+ * operation102102+ */103103+ if (best)104104+ vcpu->arch.pv_cpuid.features = best->eax;105105+}106106+93107void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)94108{95109 struct kvm_cpuid_entry2 *best;···138124 (best->eax & (1 << KVM_FEATURE_PV_UNHALT)))139125 best->eax &= ~(1 << KVM_FEATURE_PV_UNHALT);140126141141- /*142142- * save the feature bitmap to avoid cpuid lookup for every PV143143- * operation144144- */145145- if (best)146146- vcpu->arch.pv_cpuid.features = best->eax;147147-148127 if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) {149128 best = kvm_find_cpuid_entry(vcpu, 0x1, 0);150129 if (best)···168161 else169162 vcpu->arch.guest_supported_xcr0 =170163 (best->eax | ((u64)best->edx << 32)) & supported_xcr0;164164+165165+ kvm_update_pv_runtime(vcpu);171166172167 vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu);173168 kvm_mmu_reset_context(vcpu);
···856856 } else {857857 rmap_printk("pte_list_add: %p %llx many->many\n", spte, *spte);858858 desc = (struct pte_list_desc *)(rmap_head->val & ~1ul);859859- while (desc->sptes[PTE_LIST_EXT-1] && desc->more) {860860- desc = desc->more;859859+ while (desc->sptes[PTE_LIST_EXT-1]) {861860 count += PTE_LIST_EXT;862862- }863863- if (desc->sptes[PTE_LIST_EXT-1]) {864864- desc->more = mmu_alloc_pte_list_desc(vcpu);861861+862862+ if (!desc->more) {863863+ desc->more = mmu_alloc_pte_list_desc(vcpu);864864+ desc = desc->more;865865+ break;866866+ }865867 desc = desc->more;866868 }867869 for (i = 0; desc->sptes[i]; ++i)
+55-17
arch/x86/kvm/x86.c
···255255256256/*257257 * When called, it means the previous get/set msr reached an invalid msr.258258- * Return 0 if we want to ignore/silent this failed msr access, or 1 if we want259259- * to fail the caller.258258+ * Return true if we want to ignore/silent this failed msr access.260259 */261261-static int kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,262262- u64 data, bool write)260260+static bool kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,261261+ u64 data, bool write)263262{264263 const char *op = write ? "wrmsr" : "rdmsr";265264···267268 kvm_pr_unimpl("ignored %s: 0x%x data 0x%llx\n",268269 op, msr, data);269270 /* Mask the error */270270- return 0;271271+ return true;271272 } else {272273 kvm_debug_ratelimited("unhandled %s: 0x%x data 0x%llx\n",273274 op, msr, data);274274- return -ENOENT;275275+ return false;275276 }276277}277278···14151416 if (r == KVM_MSR_RET_INVALID) {14161417 /* Unconditionally clear the output for simplicity */14171418 *data = 0;14181418- r = kvm_msr_ignored_check(vcpu, index, 0, false);14191419+ if (kvm_msr_ignored_check(vcpu, index, 0, false))14201420+ r = 0;14191421 }1420142214211423 if (r)···15401540 struct msr_data msr;1541154115421542 if (!host_initiated && !kvm_msr_allowed(vcpu, index, KVM_MSR_FILTER_WRITE))15431543- return -EPERM;15431543+ return KVM_MSR_RET_FILTERED;1544154415451545 switch (index) {15461546 case MSR_FS_BASE:···15811581 int ret = __kvm_set_msr(vcpu, index, data, host_initiated);1582158215831583 if (ret == KVM_MSR_RET_INVALID)15841584- ret = kvm_msr_ignored_check(vcpu, index, data, true);15841584+ if (kvm_msr_ignored_check(vcpu, index, data, true))15851585+ ret = 0;1585158615861587 return ret;15871588}···16001599 int ret;1601160016021601 if (!host_initiated && !kvm_msr_allowed(vcpu, index, KVM_MSR_FILTER_READ))16031603- return -EPERM;16021602+ return KVM_MSR_RET_FILTERED;1604160316051604 msr.index = index;16061605 msr.host_initiated = host_initiated;···16191618 if (ret == KVM_MSR_RET_INVALID) {16201619 /* Unconditionally clear *data for simplicity */16211620 *data = 0;16221622- ret = kvm_msr_ignored_check(vcpu, index, 0, false);16211621+ if (kvm_msr_ignored_check(vcpu, index, 0, false))16221622+ ret = 0;16231623 }1624162416251625 return ret;···16641662static u64 kvm_msr_reason(int r)16651663{16661664 switch (r) {16671667- case -ENOENT:16651665+ case KVM_MSR_RET_INVALID:16681666 return KVM_MSR_EXIT_REASON_UNKNOWN;16691669- case -EPERM:16671667+ case KVM_MSR_RET_FILTERED:16701668 return KVM_MSR_EXIT_REASON_FILTER;16711669 default:16721670 return KVM_MSR_EXIT_REASON_INVAL;···19671965 struct kvm_arch *ka = &vcpu->kvm->arch;1968196619691967 if (vcpu->vcpu_id == 0 && !host_initiated) {19701970- if (ka->boot_vcpu_runs_old_kvmclock && old_msr)19681968+ if (ka->boot_vcpu_runs_old_kvmclock != old_msr)19711969 kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);1972197019731971 ka->boot_vcpu_runs_old_kvmclock = old_msr;···30653063 /* Values other than LBR and BTF are vendor-specific,30663064 thus reserved and should throw a #GP */30673065 return 1;30683068- }30693069- vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",30703070- __func__, data);30663066+ } else if (report_ignored_msrs)30673067+ vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",30683068+ __func__, data);30713069 break;30723070 case 0x200 ... 0x2ff:30733071 return kvm_mtrr_set_msr(vcpu, msr, data);···34653463 msr_info->data = vcpu->arch.efer;34663464 break;34673465 case MSR_KVM_WALL_CLOCK:34663466+ if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE))34673467+ return 1;34683468+34693469+ msr_info->data = vcpu->kvm->arch.wall_clock;34703470+ break;34683471 case MSR_KVM_WALL_CLOCK_NEW:34723472+ if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))34733473+ return 1;34743474+34693475 msr_info->data = vcpu->kvm->arch.wall_clock;34703476 break;34713477 case MSR_KVM_SYSTEM_TIME:34783478+ if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE))34793479+ return 1;34803480+34813481+ msr_info->data = vcpu->arch.time;34823482+ break;34723483 case MSR_KVM_SYSTEM_TIME_NEW:34843484+ if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))34853485+ return 1;34863486+34733487 msr_info->data = vcpu->arch.time;34743488 break;34753489 case MSR_KVM_ASYNC_PF_EN:34903490+ if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF))34913491+ return 1;34923492+34763493 msr_info->data = vcpu->arch.apf.msr_en_val;34773494 break;34783495 case MSR_KVM_ASYNC_PF_INT:34963496+ if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT))34973497+ return 1;34983498+34793499 msr_info->data = vcpu->arch.apf.msr_int_val;34803500 break;34813501 case MSR_KVM_ASYNC_PF_ACK:35023502+ if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF))35033503+ return 1;35043504+34823505 msr_info->data = 0;34833506 break;34843507 case MSR_KVM_STEAL_TIME:35083508+ if (!guest_pv_has(vcpu, KVM_FEATURE_STEAL_TIME))35093509+ return 1;35103510+34853511 msr_info->data = vcpu->arch.st.msr_val;34863512 break;34873513 case MSR_KVM_PV_EOI_EN:35143514+ if (!guest_pv_has(vcpu, KVM_FEATURE_PV_EOI))35153515+ return 1;35163516+34883517 msr_info->data = vcpu->arch.pv_eoi.msr_val;34893518 break;34903519 case MSR_KVM_POLL_CONTROL:35203520+ if (!guest_pv_has(vcpu, KVM_FEATURE_POLL_CONTROL))35213521+ return 1;35223522+34913523 msr_info->data = vcpu->arch.msr_kvm_poll_control;34923524 break;34933525 case MSR_IA32_P5_MC_ADDR:···4611457546124576 case KVM_CAP_ENFORCE_PV_FEATURE_CPUID:46134577 vcpu->arch.pv_cpuid.enforce = cap->args[0];45784578+ if (vcpu->arch.pv_cpuid.enforce)45794579+ kvm_update_pv_runtime(vcpu);4614458046154581 return 0;46164582
+7-1
arch/x86/kvm/x86.h
···376376int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva);377377bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);378378379379-#define KVM_MSR_RET_INVALID 2379379+/*380380+ * Internal error codes that are used to indicate that MSR emulation encountered381381+ * an error that should result in #GP in the guest, unless userspace382382+ * handles it.383383+ */384384+#define KVM_MSR_RET_INVALID 2 /* in-kernel MSR emulation #GP condition */385385+#define KVM_MSR_RET_FILTERED 3 /* #GP due to userspace MSR filter */380386381387#define __cr4_reserved_bits(__cpu_has, __c) \382388({ \
+1-3
arch/x86/lib/memcpy_64.S
···1616 * to a jmp to memcpy_erms which does the REP; MOVSB mem copy.1717 */18181919-.weak memcpy2020-2119/*2220 * memcpy - Copy a memory block.2321 *···2830 * rax original destination2931 */3032SYM_FUNC_START_ALIAS(__memcpy)3131-SYM_FUNC_START_LOCAL(memcpy)3333+SYM_FUNC_START_WEAK(memcpy)3234 ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \3335 "jmp memcpy_erms", X86_FEATURE_ERMS3436
···66#include <asm/alternative-asm.h>77#include <asm/export.h>8899-.weak memset1010-119/*1210 * ISO C memset - set a memory block to a byte value. This function uses fast1311 * string to get better performance than the original function. The code is···1719 *1820 * rax original destination1921 */2020-SYM_FUNC_START_ALIAS(memset)2222+SYM_FUNC_START_WEAK(memset)2123SYM_FUNC_START(__memset)2224 /*2325 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
···134134void acpi_power_add_remove_device(struct acpi_device *adev, bool add);135135int acpi_power_wakeup_list_init(struct list_head *list, int *system_level);136136int acpi_device_sleep_wake(struct acpi_device *dev,137137- int enable, int sleep_state, int dev_state);137137+ int enable, int sleep_state, int dev_state);138138int acpi_power_get_inferred_state(struct acpi_device *device, int *state);139139int acpi_power_on_resources(struct acpi_device *device, int state);140140int acpi_power_transition(struct acpi_device *device, int state);
···175175 * configure the IRQ assigned to this slot|dev|pin. The 'source_index'176176 * indicates which resource descriptor in the resource template (of177177 * the link device) this interrupt is allocated from.178178- * 178178+ *179179 * NOTE: Don't query the Link Device for IRQ information at this time180180 * because Link Device enumeration may not have occurred yet181181 * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
+6-6
drivers/acpi/pci_link.c
···66 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>77 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>88 *99- * TBD: 1010- * 1. Support more than one IRQ resource entry per link device (index).99+ * TBD:1010+ * 1. Support more than one IRQ resource entry per link device (index).1111 * 2. Implement start/stop mechanism and use ACPI Bus Driver facilities1212 * for IRQ management (e.g. start()->_SRS).1313 */···249249 }250250 }251251252252- /* 253253- * Query and parse _CRS to get the current IRQ assignment. 252252+ /*253253+ * Query and parse _CRS to get the current IRQ assignment.254254 */255255256256 status = acpi_walk_resources(link->device->handle, METHOD_NAME__CRS,···396396/*397397 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt398398 * Link Devices to move the PIRQs around to minimize sharing.399399- * 399399+ *400400 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs401401 * that the BIOS has already set to active. This is necessary because402402 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that···414414 *415415 * Note that PCI IRQ routers have a list of possible IRQs,416416 * which may not include the IRQs this table says are available.417417- * 417417+ *418418 * Since this heuristic can't tell the difference between a link419419 * that no device will attach to, vs. a link which may be shared420420 * by multiple active devices -- it is not optimal.
···1313 * 1. via "Device Specific (D-State) Control"1414 * 2. via "Power Resource Control".1515 * The code below deals with ACPI Power Resources control.1616- * 1616+ *1717 * An ACPI "power resource object" represents a software controllable power1818 * plane, clock plane, or other resource depended on by a device.1919 *···645645 * -ENODEV if the execution of either _DSW or _PSW has failed646646 */647647int acpi_device_sleep_wake(struct acpi_device *dev,648648- int enable, int sleep_state, int dev_state)648648+ int enable, int sleep_state, int dev_state)649649{650650 union acpi_object in_arg[3];651651 struct acpi_object_list arg_list = { 3, in_arg };···690690691691/*692692 * Prepare a wakeup device, two steps (Ref ACPI 2.0:P229):693693- * 1. Power on the power resources required for the wakeup device 693693+ * 1. Power on the power resources required for the wakeup device694694 * 2. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power695695 * State Wake) for the device, if present696696 */
+3-3
drivers/acpi/processor_perflib.c
···354354 (u32) px->control, (u32) px->status));355355356356 /*357357- * Check that ACPI's u64 MHz will be valid as u32 KHz in cpufreq357357+ * Check that ACPI's u64 MHz will be valid as u32 KHz in cpufreq358358 */359359 if (!px->core_frequency ||360360 ((u32)(px->core_frequency * 1000) !=···627627 goto err_ret;628628629629 /*630630- * Now that we have _PSD data from all CPUs, lets setup P-state 630630+ * Now that we have _PSD data from all CPUs, lets setup P-state631631 * domain info.632632 */633633 for_each_possible_cpu(i) {···693693 if (match_pdomain->domain != pdomain->domain)694694 continue;695695696696- match_pr->performance->shared_type = 696696+ match_pr->performance->shared_type =697697 pr->performance->shared_type;698698 cpumask_copy(match_pr->performance->shared_cpu_map,699699 pr->performance->shared_cpu_map);
···14531453}1454145414551455/**14561456- * acpi_dma_configure - Set-up DMA configuration for the device.14561456+ * acpi_dma_configure_id - Set-up DMA configuration for the device.14571457 * @dev: The pointer to the device14581458 * @attr: device dma attributes14591459 * @input_id: input device id const value pointer
+8-8
drivers/acpi/video_detect.c
···178178 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),179179 },180180 },181181- {182182- .callback = video_detect_force_video,183183- .ident = "ThinkPad X201T",184184- .matches = {185185- DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),186186- DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),187187- },188188- },181181+ {182182+ .callback = video_detect_force_video,183183+ .ident = "ThinkPad X201T",184184+ .matches = {185185+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),186186+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),187187+ },188188+ },189189190190 /* The native backlight controls do not work on some older machines */191191 {
···4747 unsigned int nr_zones_closed;4848 struct blk_zone *zones;4949 sector_t zone_size_sects;5050- spinlock_t zone_dev_lock;5050+ spinlock_t zone_lock;5151 unsigned long *zone_locks;52525353 unsigned long size; /* device size in MB */
+31-16
drivers/block/null_blk_zoned.c
···4646 if (!dev->zones)4747 return -ENOMEM;48484949- spin_lock_init(&dev->zone_dev_lock);5050- dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL);5151- if (!dev->zone_locks) {5252- kvfree(dev->zones);5353- return -ENOMEM;4949+ /*5050+ * With memory backing, the zone_lock spinlock needs to be temporarily5151+ * released to avoid scheduling in atomic context. To guarantee zone5252+ * information protection, use a bitmap to lock zones with5353+ * wait_on_bit_lock_io(). Sleeping on the lock is OK as memory backing5454+ * implies that the queue is marked with BLK_MQ_F_BLOCKING.5555+ */5656+ spin_lock_init(&dev->zone_lock);5757+ if (dev->memory_backed) {5858+ dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL);5959+ if (!dev->zone_locks) {6060+ kvfree(dev->zones);6161+ return -ENOMEM;6262+ }5463 }55645665 if (dev->zone_nr_conv >= dev->nr_zones) {···146137147138static inline void null_lock_zone(struct nullb_device *dev, unsigned int zno)148139{149149- wait_on_bit_lock_io(dev->zone_locks, zno, TASK_UNINTERRUPTIBLE);140140+ if (dev->memory_backed)141141+ wait_on_bit_lock_io(dev->zone_locks, zno, TASK_UNINTERRUPTIBLE);142142+ spin_lock_irq(&dev->zone_lock);150143}151144152145static inline void null_unlock_zone(struct nullb_device *dev, unsigned int zno)153146{154154- clear_and_wake_up_bit(zno, dev->zone_locks);147147+ spin_unlock_irq(&dev->zone_lock);148148+149149+ if (dev->memory_backed)150150+ clear_and_wake_up_bit(zno, dev->zone_locks);155151}156152157153int null_report_zones(struct gendisk *disk, sector_t sector,···336322 return null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors);337323338324 null_lock_zone(dev, zno);339339- spin_lock(&dev->zone_dev_lock);340325341326 switch (zone->cond) {342327 case BLK_ZONE_COND_FULL:···388375 if (zone->cond != BLK_ZONE_COND_EXP_OPEN)389376 zone->cond = BLK_ZONE_COND_IMP_OPEN;390377391391- spin_unlock(&dev->zone_dev_lock);378378+ /*379379+ * Memory backing allocation may sleep: release the zone_lock spinlock380380+ * to avoid scheduling in atomic context. Zone operation atomicity is381381+ * still guaranteed through the zone_locks bitmap.382382+ */383383+ if (dev->memory_backed)384384+ spin_unlock_irq(&dev->zone_lock);392385 ret = null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors);393393- spin_lock(&dev->zone_dev_lock);386386+ if (dev->memory_backed)387387+ spin_lock_irq(&dev->zone_lock);388388+394389 if (ret != BLK_STS_OK)395390 goto unlock;396391···413392 ret = BLK_STS_OK;414393415394unlock:416416- spin_unlock(&dev->zone_dev_lock);417395 null_unlock_zone(dev, zno);418396419397 return ret;···536516 null_lock_zone(dev, i);537517 zone = &dev->zones[i];538518 if (zone->cond != BLK_ZONE_COND_EMPTY) {539539- spin_lock(&dev->zone_dev_lock);540519 null_reset_zone(dev, zone);541541- spin_unlock(&dev->zone_dev_lock);542520 trace_nullb_zone_op(cmd, i, zone->cond);543521 }544522 null_unlock_zone(dev, i);···548530 zone = &dev->zones[zone_no];549531550532 null_lock_zone(dev, zone_no);551551- spin_lock(&dev->zone_dev_lock);552533553534 switch (op) {554535 case REQ_OP_ZONE_RESET:···566549 ret = BLK_STS_NOTSUPP;567550 break;568551 }569569-570570- spin_unlock(&dev->zone_dev_lock);571552572553 if (ret == BLK_STS_OK)573554 trace_nullb_zone_op(cmd, zone_no, zone->cond);
···25272527}2528252825292529static void intel_cpufreq_adjust_hwp(struct cpudata *cpu, u32 target_pstate,25302530- bool fast_switch)25302530+ bool strict, bool fast_switch)25312531{25322532 u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev;25332533···25392539 * field in it, so opportunistically update the max too if needed.25402540 */25412541 value &= ~HWP_MAX_PERF(~0L);25422542- value |= HWP_MAX_PERF(cpu->max_perf_ratio);25422542+ value |= HWP_MAX_PERF(strict ? target_pstate : cpu->max_perf_ratio);2543254325442544 if (value == prev)25452545 return;···25622562 pstate_funcs.get_val(cpu, target_pstate));25632563}2564256425652565-static int intel_cpufreq_update_pstate(struct cpudata *cpu, int target_pstate,25662566- bool fast_switch)25652565+static int intel_cpufreq_update_pstate(struct cpufreq_policy *policy,25662566+ int target_pstate, bool fast_switch)25672567{25682568+ struct cpudata *cpu = all_cpu_data[policy->cpu];25682569 int old_pstate = cpu->pstate.current_pstate;2569257025702571 target_pstate = intel_pstate_prepare_request(cpu, target_pstate);25712572 if (hwp_active) {25722572- intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch);25732573+ intel_cpufreq_adjust_hwp(cpu, target_pstate,25742574+ policy->strict_target, fast_switch);25732575 cpu->pstate.current_pstate = target_pstate;25742576 } else if (target_pstate != old_pstate) {25752577 intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch);···26112609 break;26122610 }2613261126142614- target_pstate = intel_cpufreq_update_pstate(cpu, target_pstate, false);26122612+ target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, false);2615261326162614 freqs.new = target_pstate * cpu->pstate.scaling;26172615···2630262826312629 target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling);2632263026332633- target_pstate = intel_cpufreq_update_pstate(cpu, target_pstate, true);26312631+ target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, true);2634263226352633 return target_pstate * cpu->pstate.scaling;26362634}
+1-1
drivers/i2c/busses/Kconfig
···733733734734config I2C_MLXBF735735 tristate "Mellanox BlueField I2C controller"736736- depends on ARM64736736+ depends on MELLANOX_PLATFORM && ARM64737737 help738738 Enabling this option will add I2C SMBus support for Mellanox BlueField739739 system.
+18-32
drivers/i2c/busses/i2c-designware-slave.c
···159159 u32 raw_stat, stat, enabled, tmp;160160 u8 val = 0, slave_activity;161161162162- regmap_read(dev->map, DW_IC_INTR_STAT, &stat);163162 regmap_read(dev->map, DW_IC_ENABLE, &enabled);164163 regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_stat);165164 regmap_read(dev->map, DW_IC_STATUS, &tmp);···167168 if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)168169 return 0;169170171171+ stat = i2c_dw_read_clear_intrbits_slave(dev);170172 dev_dbg(dev->dev,171173 "%#x STATUS SLAVE_ACTIVITY=%#x : RAW_INTR_STAT=%#x : INTR_STAT=%#x\n",172174 enabled, slave_activity, raw_stat, stat);173175174174- if ((stat & DW_IC_INTR_RX_FULL) && (stat & DW_IC_INTR_STOP_DET))175175- i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED, &val);176176+ if (stat & DW_IC_INTR_RX_FULL) {177177+ if (dev->status != STATUS_WRITE_IN_PROGRESS) {178178+ dev->status = STATUS_WRITE_IN_PROGRESS;179179+ i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED,180180+ &val);181181+ }182182+183183+ regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);184184+ val = tmp;185185+ if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,186186+ &val))187187+ dev_vdbg(dev->dev, "Byte %X acked!", val);188188+ }176189177190 if (stat & DW_IC_INTR_RD_REQ) {178191 if (slave_activity) {179179- if (stat & DW_IC_INTR_RX_FULL) {180180- regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);181181- val = tmp;192192+ regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);182193183183- if (!i2c_slave_event(dev->slave,184184- I2C_SLAVE_WRITE_RECEIVED,185185- &val)) {186186- dev_vdbg(dev->dev, "Byte %X acked!",187187- val);188188- }189189- regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);190190- stat = i2c_dw_read_clear_intrbits_slave(dev);191191- } else {192192- regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);193193- regmap_read(dev->map, DW_IC_CLR_RX_UNDER, &tmp);194194- stat = i2c_dw_read_clear_intrbits_slave(dev);195195- }194194+ dev->status = STATUS_READ_IN_PROGRESS;196195 if (!i2c_slave_event(dev->slave,197196 I2C_SLAVE_READ_REQUESTED,198197 &val))···202205 if (!i2c_slave_event(dev->slave, I2C_SLAVE_READ_PROCESSED,203206 &val))204207 regmap_read(dev->map, DW_IC_CLR_RX_DONE, &tmp);205205-206206- i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);207207- stat = i2c_dw_read_clear_intrbits_slave(dev);208208- return 1;209208 }210209211211- if (stat & DW_IC_INTR_RX_FULL) {212212- regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);213213- val = tmp;214214- if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,215215- &val))216216- dev_vdbg(dev->dev, "Byte %X acked!", val);217217- } else {210210+ if (stat & DW_IC_INTR_STOP_DET) {211211+ dev->status = STATUS_IDLE;218212 i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);219219- stat = i2c_dw_read_clear_intrbits_slave(dev);220213 }221214222215 return 1;···217230 struct dw_i2c_dev *dev = dev_id;218231 int ret;219232220220- i2c_dw_read_clear_intrbits_slave(dev);221233 ret = i2c_dw_irq_handler_slave(dev);222234 if (ret > 0)223235 complete(&dev->cmd_complete);
+86-118
drivers/i2c/busses/i2c-mlxbf.c
···6262 * Master. Default value is set to 400MHz.6363 */6464#define MLXBF_I2C_TYU_PLL_OUT_FREQ (400 * 1000 * 1000)6565-/* Reference clock for Bluefield 1 - 156 MHz. */6666-#define MLXBF_I2C_TYU_PLL_IN_FREQ (156 * 1000 * 1000)6767-/* Reference clock for BlueField 2 - 200 MHz. */6868-#define MLXBF_I2C_YU_PLL_IN_FREQ (200 * 1000 * 1000)6565+/* Reference clock for Bluefield - 156 MHz. */6666+#define MLXBF_I2C_PLL_IN_FREQ (156 * 1000 * 1000)69677068/* Constant used to determine the PLL frequency. */7169#define MLNXBF_I2C_COREPLL_CONST 16384···487489488490#define MLXBF_I2C_FREQUENCY_1GHZ 1000000000489491490490-static void mlxbf_i2c_write(void __iomem *io, int reg, u32 val)491491-{492492- writel(val, io + reg);493493-}494494-495495-static u32 mlxbf_i2c_read(void __iomem *io, int reg)496496-{497497- return readl(io + reg);498498-}499499-500500-/*501501- * This function is used to read data from Master GW Data Descriptor.502502- * Data bytes in the Master GW Data Descriptor are shifted left so the503503- * data starts at the MSB of the descriptor registers as set by the504504- * underlying hardware. TYU_READ_DATA enables byte swapping while505505- * reading data bytes, and MUST be called by the SMBus read routines506506- * to copy data from the 32 * 32-bit HW Data registers a.k.a Master GW507507- * Data Descriptor.508508- */509509-static u32 mlxbf_i2c_read_data(void __iomem *io, int reg)510510-{511511- return (u32)be32_to_cpu(mlxbf_i2c_read(io, reg));512512-}513513-514514-/*515515- * This function is used to write data to the Master GW Data Descriptor.516516- * Data copied to the Master GW Data Descriptor MUST be shifted left so517517- * the data starts at the MSB of the descriptor registers as required by518518- * the underlying hardware. TYU_WRITE_DATA enables byte swapping when519519- * writing data bytes, and MUST be called by the SMBus write routines to520520- * copy data to the 32 * 32-bit HW Data registers a.k.a Master GW Data521521- * Descriptor.522522- */523523-static void mlxbf_i2c_write_data(void __iomem *io, int reg, u32 val)524524-{525525- mlxbf_i2c_write(io, reg, (u32)cpu_to_be32(val));526526-}527527-528492/*529493 * Function to poll a set of bits at a specific address; it checks whether530494 * the bits are equal to zero when eq_zero is set to 'true', and not equal···501541 timeout = (timeout / MLXBF_I2C_POLL_FREQ_IN_USEC) + 1;502542503543 do {504504- bits = mlxbf_i2c_read(io, addr) & mask;544544+ bits = readl(io + addr) & mask;505545 if (eq_zero ? bits == 0 : bits != 0)506546 return eq_zero ? 1 : bits;507547 udelay(MLXBF_I2C_POLL_FREQ_IN_USEC);···569609 MLXBF_I2C_SMBUS_TIMEOUT);570610571611 /* Read cause status bits. */572572- cause_status_bits = mlxbf_i2c_read(priv->mst_cause->io,573573- MLXBF_I2C_CAUSE_ARBITER);612612+ cause_status_bits = readl(priv->mst_cause->io +613613+ MLXBF_I2C_CAUSE_ARBITER);574614 cause_status_bits &= MLXBF_I2C_CAUSE_MASTER_ARBITER_BITS_MASK;575615576616 /*577617 * Parse both Cause and Master GW bits, then return transaction status.578618 */579619580580- master_status_bits = mlxbf_i2c_read(priv->smbus->io,581581- MLXBF_I2C_SMBUS_MASTER_STATUS);620620+ master_status_bits = readl(priv->smbus->io +621621+ MLXBF_I2C_SMBUS_MASTER_STATUS);582622 master_status_bits &= MLXBF_I2C_SMBUS_MASTER_STATUS_MASK;583623584624 if (mlxbf_i2c_smbus_transaction_success(master_status_bits,···609649610650 aligned_length = round_up(length, 4);611651612612- /* Copy data bytes from 4-byte aligned source buffer. */652652+ /*653653+ * Copy data bytes from 4-byte aligned source buffer.654654+ * Data copied to the Master GW Data Descriptor MUST be shifted655655+ * left so the data starts at the MSB of the descriptor registers656656+ * as required by the underlying hardware. Enable byte swapping657657+ * when writing data bytes to the 32 * 32-bit HW Data registers658658+ * a.k.a Master GW Data Descriptor.659659+ */613660 for (offset = 0; offset < aligned_length; offset += sizeof(u32)) {614661 data32 = *((u32 *)(data + offset));615615- mlxbf_i2c_write_data(priv->smbus->io, addr + offset, data32);662662+ iowrite32be(data32, priv->smbus->io + addr + offset);616663 }617664}618665···631664632665 mask = sizeof(u32) - 1;633666667667+ /*668668+ * Data bytes in the Master GW Data Descriptor are shifted left669669+ * so the data starts at the MSB of the descriptor registers as670670+ * set by the underlying hardware. Enable byte swapping while671671+ * reading data bytes from the 32 * 32-bit HW Data registers672672+ * a.k.a Master GW Data Descriptor.673673+ */674674+634675 for (offset = 0; offset < (length & ~mask); offset += sizeof(u32)) {635635- data32 = mlxbf_i2c_read_data(priv->smbus->io, addr + offset);676676+ data32 = ioread32be(priv->smbus->io + addr + offset);636677 *((u32 *)(data + offset)) = data32;637678 }638679639680 if (!(length & mask))640681 return;641682642642- data32 = mlxbf_i2c_read_data(priv->smbus->io, addr + offset);683683+ data32 = ioread32be(priv->smbus->io + addr + offset);643684644685 for (byte = 0; byte < (length & mask); byte++) {645686 data[offset + byte] = data32 & GENMASK(7, 0);···673698 command |= rol32(pec_en, MLXBF_I2C_MASTER_SEND_PEC_SHIFT);674699675700 /* Clear status bits. */676676- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_STATUS, 0x0);701701+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_STATUS);677702 /* Set the cause data. */678678- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_CAUSE_OR_CLEAR, ~0x0);703703+ writel(~0x0, priv->smbus->io + MLXBF_I2C_CAUSE_OR_CLEAR);679704 /* Zero PEC byte. */680680- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_PEC, 0x0);705705+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_PEC);681706 /* Zero byte count. */682682- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_RS_BYTES, 0x0);707707+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_RS_BYTES);683708684709 /* GW activation. */685685- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_GW, command);710710+ writel(command, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_GW);686711687712 /*688713 * Poll master status and check status bits. An ACK is sent when···798823 * needs to be 'manually' reset. This should be removed in799824 * next tag integration.800825 */801801- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_FSM,802802- MLXBF_I2C_SMBUS_MASTER_FSM_PS_STATE_MASK);826826+ writel(MLXBF_I2C_SMBUS_MASTER_FSM_PS_STATE_MASK,827827+ priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_FSM);803828 }804829805830 return ret;···10881113 timer |= mlxbf_i2c_set_timer(priv, timings->scl_low,10891114 false, MLXBF_I2C_MASK_16,10901115 MLXBF_I2C_SHIFT_16);10911091- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_SCL_LOW_SCL_HIGH,10921092- timer);11161116+ writel(timer, priv->smbus->io +11171117+ MLXBF_I2C_SMBUS_TIMER_SCL_LOW_SCL_HIGH);1093111810941119 timer = mlxbf_i2c_set_timer(priv, timings->sda_rise, false,10951120 MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_0);···10991124 MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_16);11001125 timer |= mlxbf_i2c_set_timer(priv, timings->scl_fall, false,11011126 MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_24);11021102- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_FALL_RISE_SPIKE,11031103- timer);11271127+ writel(timer, priv->smbus->io +11281128+ MLXBF_I2C_SMBUS_TIMER_FALL_RISE_SPIKE);1104112911051130 timer = mlxbf_i2c_set_timer(priv, timings->hold_start, true,11061131 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);11071132 timer |= mlxbf_i2c_set_timer(priv, timings->hold_data, true,11081133 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);11091109- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_THOLD, timer);11341134+ writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_TIMER_THOLD);1110113511111136 timer = mlxbf_i2c_set_timer(priv, timings->setup_start, true,11121137 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);11131138 timer |= mlxbf_i2c_set_timer(priv, timings->setup_stop, true,11141139 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);11151115- mlxbf_i2c_write(priv->smbus->io,11161116- MLXBF_I2C_SMBUS_TIMER_TSETUP_START_STOP, timer);11401140+ writel(timer, priv->smbus->io +11411141+ MLXBF_I2C_SMBUS_TIMER_TSETUP_START_STOP);1117114211181143 timer = mlxbf_i2c_set_timer(priv, timings->setup_data, true,11191144 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);11201120- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_TSETUP_DATA,11211121- timer);11451145+ writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_TIMER_TSETUP_DATA);1122114611231147 timer = mlxbf_i2c_set_timer(priv, timings->buf, false,11241148 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);11251149 timer |= mlxbf_i2c_set_timer(priv, timings->thigh_max, false,11261150 MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);11271127- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_THIGH_MAX_TBUF,11281128- timer);11511151+ writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_THIGH_MAX_TBUF);1129115211301153 timer = timings->timeout;11311131- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT,11321132- timer);11541154+ writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT);11331155}1134115611351157enum mlxbf_i2c_timings_config {···13981426 * platform firmware; disabling the bus might compromise the system13991427 * functionality.14001428 */14011401- config_reg = mlxbf_i2c_read(gpio_res->io,14021402- MLXBF_I2C_GPIO_0_FUNC_EN_0);14291429+ config_reg = readl(gpio_res->io + MLXBF_I2C_GPIO_0_FUNC_EN_0);14031430 config_reg = MLXBF_I2C_GPIO_SMBUS_GW_ASSERT_PINS(priv->bus,14041431 config_reg);14051405- mlxbf_i2c_write(gpio_res->io, MLXBF_I2C_GPIO_0_FUNC_EN_0,14061406- config_reg);14321432+ writel(config_reg, gpio_res->io + MLXBF_I2C_GPIO_0_FUNC_EN_0);1407143314081408- config_reg = mlxbf_i2c_read(gpio_res->io,14091409- MLXBF_I2C_GPIO_0_FORCE_OE_EN);14341434+ config_reg = readl(gpio_res->io + MLXBF_I2C_GPIO_0_FORCE_OE_EN);14101435 config_reg = MLXBF_I2C_GPIO_SMBUS_GW_RESET_PINS(priv->bus,14111436 config_reg);14121412- mlxbf_i2c_write(gpio_res->io, MLXBF_I2C_GPIO_0_FORCE_OE_EN,14131413- config_reg);14371437+ writel(config_reg, gpio_res->io + MLXBF_I2C_GPIO_0_FORCE_OE_EN);1414143814151439 mutex_unlock(gpio_res->lock);14161440···14201452 u32 corepll_val;14211453 u16 core_f;1422145414231423- pad_frequency = MLXBF_I2C_TYU_PLL_IN_FREQ;14551455+ pad_frequency = MLXBF_I2C_PLL_IN_FREQ;1424145614251425- corepll_val = mlxbf_i2c_read(corepll_res->io,14261426- MLXBF_I2C_CORE_PLL_REG1);14571457+ corepll_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG1);1427145814281459 /* Get Core PLL configuration bits. */14291460 core_f = rol32(corepll_val, MLXBF_I2C_COREPLL_CORE_F_TYU_SHIFT) &···14551488 u8 core_od, core_r;14561489 u32 core_f;1457149014581458- pad_frequency = MLXBF_I2C_YU_PLL_IN_FREQ;14911491+ pad_frequency = MLXBF_I2C_PLL_IN_FREQ;1459149214601460- corepll_reg1_val = mlxbf_i2c_read(corepll_res->io,14611461- MLXBF_I2C_CORE_PLL_REG1);14621462- corepll_reg2_val = mlxbf_i2c_read(corepll_res->io,14631463- MLXBF_I2C_CORE_PLL_REG2);14931493+ corepll_reg1_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG1);14941494+ corepll_reg2_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG2);1464149514651496 /* Get Core PLL configuration bits */14661497 core_f = rol32(corepll_reg1_val, MLXBF_I2C_COREPLL_CORE_F_YU_SHIFT) &···15501585 * (7-bit address, 1 status bit (1 if enabled, 0 if not)).15511586 */15521587 for (reg = 0; reg < reg_cnt; reg++) {15531553- slave_reg = mlxbf_i2c_read(priv->smbus->io,15881588+ slave_reg = readl(priv->smbus->io +15541589 MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4);15551590 /*15561591 * Each register holds 4 slave addresses. So, we have to keep···1608164316091644 /* Enable the slave address and update the register. */16101645 slave_reg |= (1 << MLXBF_I2C_SMBUS_SLAVE_ADDR_EN_BIT) << (byte * 8);16111611- mlxbf_i2c_write(priv->smbus->io,16121612- MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4, slave_reg);16461646+ writel(slave_reg, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG +16471647+ reg * 0x4);1613164816141649 return 0;16151650}···16331668 * (7-bit address, 1 status bit (1 if enabled, 0 if not)).16341669 */16351670 for (reg = 0; reg < reg_cnt; reg++) {16361636- slave_reg = mlxbf_i2c_read(priv->smbus->io,16711671+ slave_reg = readl(priv->smbus->io +16371672 MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4);1638167316391674 /* Check whether the address slots are empty. */···1673170816741709 /* Cleanup the slave address slot. */16751710 slave_reg &= ~(GENMASK(7, 0) << (slave_byte * 8));16761676- mlxbf_i2c_write(priv->smbus->io,16771677- MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4, slave_reg);17111711+ writel(slave_reg, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG +17121712+ reg * 0x4);1678171316791714 return 0;16801715}···17661801 int ret;1767180217681803 /* Reset FSM. */17691769- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_FSM, 0);18041804+ writel(0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_FSM);1770180517711806 /*17721807 * Enable slave cause interrupt bits. Drive···17751810 * masters issue a Read and Write, respectively. But, clear all17761811 * interrupts first.17771812 */17781778- mlxbf_i2c_write(priv->slv_cause->io,17791779- MLXBF_I2C_CAUSE_OR_CLEAR, ~0);18131813+ writel(~0, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_CLEAR);17801814 int_reg = MLXBF_I2C_CAUSE_READ_WAIT_FW_RESPONSE;17811815 int_reg |= MLXBF_I2C_CAUSE_WRITE_SUCCESS;17821782- mlxbf_i2c_write(priv->slv_cause->io,17831783- MLXBF_I2C_CAUSE_OR_EVTEN0, int_reg);18161816+ writel(int_reg, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_EVTEN0);1784181717851818 /* Finally, set the 'ready' bit to start handling transactions. */17861786- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);18191819+ writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);1787182017881821 /* Initialize the cause coalesce resource. */17891822 ret = mlxbf_i2c_init_coalesce(pdev, priv);···18071844 MLXBF_I2C_CAUSE_YU_SLAVE_BIT :18081845 priv->bus + MLXBF_I2C_CAUSE_TYU_SLAVE_BIT;1809184618101810- coalesce0_reg = mlxbf_i2c_read(priv->coalesce->io,18111811- MLXBF_I2C_CAUSE_COALESCE_0);18471847+ coalesce0_reg = readl(priv->coalesce->io + MLXBF_I2C_CAUSE_COALESCE_0);18121848 is_set = coalesce0_reg & (1 << slave_shift);1813184918141850 if (!is_set)18151851 return false;1816185218171853 /* Check the source of the interrupt, i.e. whether a Read or Write. */18181818- cause_reg = mlxbf_i2c_read(priv->slv_cause->io,18191819- MLXBF_I2C_CAUSE_ARBITER);18541854+ cause_reg = readl(priv->slv_cause->io + MLXBF_I2C_CAUSE_ARBITER);18201855 if (cause_reg & MLXBF_I2C_CAUSE_READ_WAIT_FW_RESPONSE)18211856 *read = true;18221857 else if (cause_reg & MLXBF_I2C_CAUSE_WRITE_SUCCESS)18231858 *write = true;1824185918251860 /* Clear cause bits. */18261826- mlxbf_i2c_write(priv->slv_cause->io, MLXBF_I2C_CAUSE_OR_CLEAR, ~0x0);18611861+ writel(~0x0, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_CLEAR);1827186218281863 return true;18291864}···18611900 * address, if supplied.18621901 */18631902 if (recv_bytes > 0) {18641864- data32 = mlxbf_i2c_read_data(priv->smbus->io,18651865- MLXBF_I2C_SLAVE_DATA_DESC_ADDR);19031903+ data32 = ioread32be(priv->smbus->io +19041904+ MLXBF_I2C_SLAVE_DATA_DESC_ADDR);1866190518671906 /* Parse the received bytes. */18681907 switch (recv_bytes) {···19271966 control32 |= rol32(write_size, MLXBF_I2C_SLAVE_WRITE_BYTES_SHIFT);19281967 control32 |= rol32(pec_en, MLXBF_I2C_SLAVE_SEND_PEC_SHIFT);1929196819301930- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_GW, control32);19691969+ writel(control32, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_GW);1931197019321971 /*19331972 * Wait until the transfer is completed; the driver will wait···19361975 mlxbf_smbus_slave_wait_for_idle(priv, MLXBF_I2C_SMBUS_TIMEOUT);1937197619381977 /* Release the Slave GW. */19391939- mlxbf_i2c_write(priv->smbus->io,19401940- MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES, 0x0);19411941- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_PEC, 0x0);19421942- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);19781978+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);19791979+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_PEC);19801980+ writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);1943198119441982 return 0;19451983}···19832023 i2c_slave_event(slave, I2C_SLAVE_STOP, &value);1984202419852025 /* Release the Slave GW. */19861986- mlxbf_i2c_write(priv->smbus->io,19871987- MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES, 0x0);19881988- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_PEC, 0x0);19891989- mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);20262026+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);20272027+ writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_PEC);20282028+ writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);1990202919912030 return ret;19922031}···20202061 * slave, if the higher 8 bits are sent then the slave expect N bytes20212062 * from the master.20222063 */20232023- rw_bytes_reg = mlxbf_i2c_read(priv->smbus->io,20242024- MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);20642064+ rw_bytes_reg = readl(priv->smbus->io +20652065+ MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);20252066 recv_bytes = (rw_bytes_reg >> 8) & GENMASK(7, 0);2026206720272068 /*···2223226422242265MODULE_DEVICE_TABLE(of, mlxbf_i2c_dt_ids);2225226622672267+#ifdef CONFIG_ACPI22262268static const struct acpi_device_id mlxbf_i2c_acpi_ids[] = {22272269 { "MLNXBF03", (kernel_ulong_t)&mlxbf_i2c_chip[MLXBF_I2C_CHIP_TYPE_1] },22282270 { "MLNXBF23", (kernel_ulong_t)&mlxbf_i2c_chip[MLXBF_I2C_CHIP_TYPE_2] },···2265230522662306 return ret;22672307}23082308+#else23092309+static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)23102310+{23112311+ return -ENOENT;23122312+}23132313+#endif /* CONFIG_ACPI */2268231422692315static int mlxbf_i2c_of_probe(struct device *dev, struct mlxbf_i2c_priv *priv)22702316{···24392473 .driver = {24402474 .name = "i2c-mlxbf",24412475 .of_match_table = mlxbf_i2c_dt_ids,24762476+#ifdef CONFIG_ACPI24422477 .acpi_match_table = ACPI_PTR(mlxbf_i2c_acpi_ids),24782478+#endif /* CONFIG_ACPI */24432479 },24442480};24452481···24702502module_exit(mlxbf_i2c_exit);2471250324722504MODULE_DESCRIPTION("Mellanox BlueField I2C bus driver");24732473-MODULE_AUTHOR("Khalil Blaiech <kblaiech@mellanox.com>");25052505+MODULE_AUTHOR("Khalil Blaiech <kblaiech@nvidia.com>");24742506MODULE_LICENSE("GPL v2");
···8585 * @base: Base address of the memory mapped IO registers8686 * @pdev: Pointer to platform device.8787 * @ti_sci_id: TI-SCI device identifier8888+ * @unmapped_cnt: Number of @unmapped_dev_ids entries8989+ * @unmapped_dev_ids: Pointer to an array of TI-SCI device identifiers of9090+ * unmapped event sources.9191+ * Unmapped Events are not part of the Global Event Map and9292+ * they are converted to Global event within INTA to be9393+ * received by the same INTA to generate an interrupt.9494+ * In case an interrupt request comes for a device which is9595+ * generating Unmapped Event, we must use the INTA's TI-SCI9696+ * device identifier in place of the source device9797+ * identifier to let sysfw know where it has to program the9898+ * Global Event number.8899 */89100struct ti_sci_inta_irq_domain {90101 const struct ti_sci_handle *sci;···10796 void __iomem *base;10897 struct platform_device *pdev;10998 u32 ti_sci_id;9999+100100+ int unmapped_cnt;101101+ u16 *unmapped_dev_ids;110102};111103112104#define to_vint_desc(e, i) container_of(e, struct ti_sci_inta_vint_desc, \113105 events[i])106106+107107+static u16 ti_sci_inta_get_dev_id(struct ti_sci_inta_irq_domain *inta, u32 hwirq)108108+{109109+ u16 dev_id = HWIRQ_TO_DEVID(hwirq);110110+ int i;111111+112112+ if (inta->unmapped_cnt == 0)113113+ return dev_id;114114+115115+ /*116116+ * For devices sending Unmapped Events we must use the INTA's TI-SCI117117+ * device identifier number to be able to convert it to a Global Event118118+ * and map it to an interrupt.119119+ */120120+ for (i = 0; i < inta->unmapped_cnt; i++) {121121+ if (dev_id == inta->unmapped_dev_ids[i]) {122122+ dev_id = inta->ti_sci_id;123123+ break;124124+ }125125+ }126126+127127+ return dev_id;128128+}114129115130/**116131 * ti_sci_inta_irq_handler() - Chained IRQ handler for the vint irqs···288251 u16 dev_id, dev_index;289252 int err;290253291291- dev_id = HWIRQ_TO_DEVID(hwirq);254254+ dev_id = ti_sci_inta_get_dev_id(inta, hwirq);292255 dev_index = HWIRQ_TO_IRQID(hwirq);293256294257 event_desc = &vint_desc->events[free_bit];···389352{390353 struct ti_sci_inta_vint_desc *vint_desc;391354 struct ti_sci_inta_irq_domain *inta;355355+ u16 dev_id;392356393357 vint_desc = to_vint_desc(event_desc, event_desc->vint_bit);394358 inta = vint_desc->domain->host_data;359359+ dev_id = ti_sci_inta_get_dev_id(inta, hwirq);395360 /* free event irq */396361 mutex_lock(&inta->vint_mutex);397362 inta->sci->ops.rm_irq_ops.free_event_map(inta->sci,398398- HWIRQ_TO_DEVID(hwirq),399399- HWIRQ_TO_IRQID(hwirq),363363+ dev_id, HWIRQ_TO_IRQID(hwirq),400364 inta->ti_sci_id,401365 vint_desc->vint_id,402366 event_desc->global_event,···612574 .chip = &ti_sci_inta_msi_irq_chip,613575};614576577577+static int ti_sci_inta_get_unmapped_sources(struct ti_sci_inta_irq_domain *inta)578578+{579579+ struct device *dev = &inta->pdev->dev;580580+ struct device_node *node = dev_of_node(dev);581581+ struct of_phandle_iterator it;582582+ int count, err, ret, i;583583+584584+ count = of_count_phandle_with_args(node, "ti,unmapped-event-sources", NULL);585585+ if (count <= 0)586586+ return 0;587587+588588+ inta->unmapped_dev_ids = devm_kcalloc(dev, count,589589+ sizeof(*inta->unmapped_dev_ids),590590+ GFP_KERNEL);591591+ if (!inta->unmapped_dev_ids)592592+ return -ENOMEM;593593+594594+ i = 0;595595+ of_for_each_phandle(&it, err, node, "ti,unmapped-event-sources", NULL, 0) {596596+ u32 dev_id;597597+598598+ ret = of_property_read_u32(it.node, "ti,sci-dev-id", &dev_id);599599+ if (ret) {600600+ dev_err(dev, "ti,sci-dev-id read failure for %pOFf\n", it.node);601601+ of_node_put(it.node);602602+ return ret;603603+ }604604+ inta->unmapped_dev_ids[i++] = dev_id;605605+ }606606+607607+ inta->unmapped_cnt = count;608608+609609+ return 0;610610+}611611+615612static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)616613{617614 struct irq_domain *parent_domain, *domain, *msi_domain;···701628 inta->base = devm_ioremap_resource(dev, res);702629 if (IS_ERR(inta->base))703630 return PTR_ERR(inta->base);631631+632632+ ret = ti_sci_inta_get_unmapped_sources(inta);633633+ if (ret)634634+ return ret;704635705636 domain = irq_domain_add_linear(dev_of_node(dev),706637 ti_sci_get_num_resources(inta->vint),
+3-1
drivers/net/dsa/mv88e6xxx/devlink.c
···393393 mv88e6xxx_reg_lock(chip);394394395395 err = mv88e6xxx_fid_map(chip, fid_bitmap);396396- if (err)396396+ if (err) {397397+ kfree(table);397398 goto out;399399+ }398400399401 while (1) {400402 fid = find_next_bit(fid_bitmap, MV88E6XXX_N_FID, fid + 1);
···890890}891891EXPORT_SYMBOL(cxgb4_write_sgl);892892893893+/* cxgb4_write_partial_sgl - populate SGL for partial packet894894+ * @skb: the packet895895+ * @q: the Tx queue we are writing into896896+ * @sgl: starting location for writing the SGL897897+ * @end: points right after the end of the SGL898898+ * @addr: the list of bus addresses for the SGL elements899899+ * @start: start offset in the SKB where partial data starts900900+ * @len: length of data from @start to send out901901+ *902902+ * This API will handle sending out partial data of a skb if required.903903+ * Unlike cxgb4_write_sgl, @start can be any offset into the skb data,904904+ * and @len will decide how much data after @start offset to send out.905905+ */906906+void cxgb4_write_partial_sgl(const struct sk_buff *skb, struct sge_txq *q,907907+ struct ulptx_sgl *sgl, u64 *end,908908+ const dma_addr_t *addr, u32 start, u32 len)909909+{910910+ struct ulptx_sge_pair buf[MAX_SKB_FRAGS / 2 + 1] = {0}, *to;911911+ u32 frag_size, skb_linear_data_len = skb_headlen(skb);912912+ struct skb_shared_info *si = skb_shinfo(skb);913913+ u8 i = 0, frag_idx = 0, nfrags = 0;914914+ skb_frag_t *frag;915915+916916+ /* Fill the first SGL either from linear data or from partial917917+ * frag based on @start.918918+ */919919+ if (unlikely(start < skb_linear_data_len)) {920920+ frag_size = min(len, skb_linear_data_len - start);921921+ sgl->len0 = htonl(frag_size);922922+ sgl->addr0 = cpu_to_be64(addr[0] + start);923923+ len -= frag_size;924924+ nfrags++;925925+ } else {926926+ start -= skb_linear_data_len;927927+ frag = &si->frags[frag_idx];928928+ frag_size = skb_frag_size(frag);929929+ /* find the first frag */930930+ while (start >= frag_size) {931931+ start -= frag_size;932932+ frag_idx++;933933+ frag = &si->frags[frag_idx];934934+ frag_size = skb_frag_size(frag);935935+ }936936+937937+ frag_size = min(len, skb_frag_size(frag) - start);938938+ sgl->len0 = cpu_to_be32(frag_size);939939+ sgl->addr0 = cpu_to_be64(addr[frag_idx + 1] + start);940940+ len -= frag_size;941941+ nfrags++;942942+ frag_idx++;943943+ }944944+945945+ /* If the entire partial data fit in one SGL, then send it out946946+ * now.947947+ */948948+ if (!len)949949+ goto done;950950+951951+ /* Most of the complexity below deals with the possibility we hit the952952+ * end of the queue in the middle of writing the SGL. For this case953953+ * only we create the SGL in a temporary buffer and then copy it.954954+ */955955+ to = (u8 *)end > (u8 *)q->stat ? buf : sgl->sge;956956+957957+ /* If the skb couldn't fit in first SGL completely, fill the958958+ * rest of the frags in subsequent SGLs. Note that each SGL959959+ * pair can store 2 frags.960960+ */961961+ while (len) {962962+ frag_size = min(len, skb_frag_size(&si->frags[frag_idx]));963963+ to->len[i & 1] = cpu_to_be32(frag_size);964964+ to->addr[i & 1] = cpu_to_be64(addr[frag_idx + 1]);965965+ if (i && (i & 1))966966+ to++;967967+ nfrags++;968968+ frag_idx++;969969+ i++;970970+ len -= frag_size;971971+ }972972+973973+ /* If we ended in an odd boundary, then set the second SGL's974974+ * length in the pair to 0.975975+ */976976+ if (i & 1)977977+ to->len[1] = cpu_to_be32(0);978978+979979+ /* Copy from temporary buffer to Tx ring, in case we hit the980980+ * end of the queue in the middle of writing the SGL.981981+ */982982+ if (unlikely((u8 *)end > (u8 *)q->stat)) {983983+ u32 part0 = (u8 *)q->stat - (u8 *)sgl->sge, part1;984984+985985+ if (likely(part0))986986+ memcpy(sgl->sge, buf, part0);987987+ part1 = (u8 *)end - (u8 *)q->stat;988988+ memcpy(q->desc, (u8 *)buf + part0, part1);989989+ end = (void *)q->desc + part1;990990+ }991991+992992+ /* 0-pad to multiple of 16 */993993+ if ((uintptr_t)end & 8)994994+ *end = 0;995995+done:996996+ sgl->cmd_nsge = htonl(ULPTX_CMD_V(ULP_TX_SC_DSGL) |997997+ ULPTX_NSGE_V(nfrags));998998+}999999+EXPORT_SYMBOL(cxgb4_write_partial_sgl);10001000+8931001/* This function copies 64 byte coalesced work request to8941002 * memory mapped BAR2 space. For coalesced WR SGE fetches8951003 * data from the FIFO instead of from Host.···15301422#endif /* CHELSIO_IPSEC_INLINE */1531142315321424#if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE)15331533- if (skb->decrypted)14251425+ if (cxgb4_is_ktls_skb(skb) &&14261426+ (skb->len - (skb_transport_offset(skb) + tcp_hdrlen(skb))))15341427 return adap->uld[CXGB4_ULD_KTLS].tx_handler(skb, dev);15351428#endif /* CHELSIO_TLS_DEVICE */15361429
···107107 mlx5e_tc_encap_flows_del(priv, e, &flow_list);108108109109 if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) {110110+ struct net_device *route_dev;111111+110112 ether_addr_copy(e->h_dest, ha);111113 ether_addr_copy(eth->h_dest, ha);112114 /* Update the encap source mac, in case that we delete113115 * the flows when encap source mac changed.114116 */115115- ether_addr_copy(eth->h_source, e->route_dev->dev_addr);117117+ route_dev = __dev_get_by_index(dev_net(priv->netdev), e->route_dev_ifindex);118118+ if (route_dev)119119+ ether_addr_copy(eth->h_source, route_dev->dev_addr);116120117121 mlx5e_tc_encap_flows_add(priv, e, &flow_list);118122 }
···674674static int lan743x_dp_write(struct lan743x_adapter *adapter,675675 u32 select, u32 addr, u32 length, u32 *buf)676676{677677- int ret = -EIO;678677 u32 dp_sel;679678 int i;680679681681- mutex_lock(&adapter->dp_lock);682680 if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_,683681 1, 40, 100, 100))684684- goto unlock;682682+ return -EIO;685683 dp_sel = lan743x_csr_read(adapter, DP_SEL);686684 dp_sel &= ~DP_SEL_MASK_;687685 dp_sel |= select;···691693 lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_);692694 if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_,693695 1, 40, 100, 100))694694- goto unlock;696696+ return -EIO;695697 }696696- ret = 0;697698698698-unlock:699699- mutex_unlock(&adapter->dp_lock);700700- return ret;699699+ return 0;701700}702701703702static u32 lan743x_mac_mii_access(u16 id, u16 index, int read)···10131018static int lan743x_phy_open(struct lan743x_adapter *adapter)10141019{10151020 struct lan743x_phy *phy = &adapter->phy;10211021+ struct phy_device *phydev = NULL;10161022 struct device_node *phynode;10171017- struct phy_device *phydev;10181023 struct net_device *netdev;10191024 int ret = -EIO;1020102510211026 netdev = adapter->netdev;10221027 phynode = of_node_get(adapter->pdev->dev.of_node);10231023- adapter->phy_mode = PHY_INTERFACE_MODE_GMII;1024102810251029 if (phynode) {10301030+ /* try devicetree phy, or fixed link */10261031 of_get_phy_mode(phynode, &adapter->phy_mode);1027103210281033 if (of_phy_is_fixed_link(phynode)) {···10381043 lan743x_phy_link_status_change, 0,10391044 adapter->phy_mode);10401045 of_node_put(phynode);10411041- if (!phydev)10421042- goto return_error;10431043- } else {10461046+ }10471047+10481048+ if (!phydev) {10491049+ /* try internal phy */10441050 phydev = phy_find_first(adapter->mdiobus);10451051 if (!phydev)10461052 goto return_error;1047105310541054+ adapter->phy_mode = PHY_INTERFACE_MODE_GMII;10481055 ret = phy_connect_direct(netdev, phydev,10491056 lan743x_phy_link_status_change,10501057 adapter->phy_mode);···2729273227302733 adapter->intr.irq = adapter->pdev->irq;27312734 lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF);27322732- mutex_init(&adapter->dp_lock);2733273527342736 ret = lan743x_gpio_init(adapter);27352737 if (ret)
-3
drivers/net/ethernet/microchip/lan743x_main.h
···712712 struct lan743x_csr csr;713713 struct lan743x_intr intr;714714715715- /* lock, used to prevent concurrent access to data port */716716- struct mutex dp_lock;717717-718715 struct lan743x_gpio gpio;719716 struct lan743x_ptp ptp;720717
+5-13
drivers/net/ethernet/realtek/r8169_main.c
···41344134 opts[1] |= transport_offset << TCPHO_SHIFT;41354135 } else {41364136 if (unlikely(skb->len < ETH_ZLEN && rtl_test_hw_pad_bug(tp)))41374137- return !eth_skb_pad(skb);41374137+ /* eth_skb_pad would free the skb on error */41384138+ return !__skb_put_padto(skb, ETH_ZLEN, false);41384139 }4139414041404141 return true;···43144313 rtl_chip_supports_csum_v2(tp))43154314 features &= ~NETIF_F_ALL_TSO;43164315 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {43174317- if (skb->len < ETH_ZLEN) {43184318- switch (tp->mac_version) {43194319- case RTL_GIGA_MAC_VER_11:43204320- case RTL_GIGA_MAC_VER_12:43214321- case RTL_GIGA_MAC_VER_17:43224322- case RTL_GIGA_MAC_VER_34:43234323- features &= ~NETIF_F_CSUM_MASK;43244324- break;43254325- default:43264326- break;43274327- }43284328- }43164316+ /* work around hw bug on some chip versions */43174317+ if (skb->len < ETH_ZLEN)43184318+ features &= ~NETIF_F_CSUM_MASK;4329431943304320 if (transport_offset > TCPHO_MAX &&43314321 rtl_chip_supports_csum_v2(tp))
···17401740 reply_q->irq_poll_scheduled = false;17411741 reply_q->irq_line_enable = true;17421742 enable_irq(reply_q->os_irq);17431743+ /*17441744+ * Go for one more round of processing the17451745+ * reply descriptor post queue incase if HBA17461746+ * Firmware has posted some reply descriptors17471747+ * while reenabling the IRQ.17481748+ */17491749+ _base_process_reply_queue(reply_q);17431750 }1744175117451752 return num_entries;
···522522 depends on OF523523 select SERIAL_EARLYCON524524 select SERIAL_CORE_CONSOLE525525+ default y if SERIAL_IMX_CONSOLE525526 help526527 If you have enabled the earlycon on the Freescale IMX527528 CPU you can make it the earlycon by answering Y to this option.
+3
drivers/tty/serial/serial_txx9.c
···1280128012811281#ifdef ENABLE_SERIAL_TXX9_PCI12821282 ret = pci_register_driver(&serial_txx9_pci_driver);12831283+ if (ret) {12841284+ platform_driver_unregister(&serial_txx9_plat_driver);12851285+ }12831286#endif12841287 if (ret == 0)12851288 goto out;
+4-2
drivers/tty/tty_io.c
···15151515 tty->ops->shutdown(tty);15161516 tty_save_termios(tty);15171517 tty_driver_remove_tty(tty->driver, tty);15181518- tty->port->itty = NULL;15181518+ if (tty->port)15191519+ tty->port->itty = NULL;15191520 if (tty->link)15201521 tty->link->port->itty = NULL;15211521- tty_buffer_cancel_work(tty->port);15221522+ if (tty->port)15231523+ tty_buffer_cancel_work(tty->port);15221524 if (tty->link)15231525 tty_buffer_cancel_work(tty->link->port);15241526
+2-22
drivers/tty/vt/vt.c
···47044704 return rc;47054705}4706470647074707-static int con_font_copy(struct vc_data *vc, struct console_font_op *op)47084708-{47094709- int con = op->height;47104710- int rc;47114711-47124712-47134713- console_lock();47144714- if (vc->vc_mode != KD_TEXT)47154715- rc = -EINVAL;47164716- else if (!vc->vc_sw->con_font_copy)47174717- rc = -ENOSYS;47184718- else if (con < 0 || !vc_cons_allocated(con))47194719- rc = -ENOTTY;47204720- else if (con == vc->vc_num) /* nothing to do */47214721- rc = 0;47224722- else47234723- rc = vc->vc_sw->con_font_copy(vc, con);47244724- console_unlock();47254725- return rc;47264726-}47274727-47284707int con_font_op(struct vc_data *vc, struct console_font_op *op)47294708{47304709 switch (op->op) {···47144735 case KD_FONT_OP_SET_DEFAULT:47154736 return con_font_default(vc, op);47164737 case KD_FONT_OP_COPY:47174717- return con_font_copy(vc, op);47384738+ /* was buggy and never really used */47394739+ return -EINVAL;47184740 }47194741 return -ENOSYS;47204742}
···511511 /*DEFAULT_RATELIMIT_BURST*/ 1);512512 if (__ratelimit(&_rs))513513 WARN(1, KERN_DEBUG514514- "BTRFS: block rsv returned %d\n", ret);514514+ "BTRFS: block rsv %d returned %d\n",515515+ block_rsv->type, ret);515516 }516517try_reserve:517518 ret = btrfs_reserve_metadata_bytes(root, block_rsv, blocksize,
+24-2
fs/btrfs/dev-replace.c
···9191 ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0);9292 if (ret) {9393no_valid_dev_replace_entry_found:9494+ /*9595+ * We don't have a replace item or it's corrupted. If there is9696+ * a replace target, fail the mount.9797+ */9898+ if (btrfs_find_device(fs_info->fs_devices,9999+ BTRFS_DEV_REPLACE_DEVID, NULL, NULL, false)) {100100+ btrfs_err(fs_info,101101+ "found replace target device without a valid replace item");102102+ ret = -EUCLEAN;103103+ goto out;104104+ }94105 ret = 0;95106 dev_replace->replace_state =96107 BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED;···154143 case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED:155144 case BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED:156145 case BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED:157157- dev_replace->srcdev = NULL;158158- dev_replace->tgtdev = NULL;146146+ /*147147+ * We don't have an active replace item but if there is a148148+ * replace target, fail the mount.149149+ */150150+ if (btrfs_find_device(fs_info->fs_devices,151151+ BTRFS_DEV_REPLACE_DEVID, NULL, NULL, false)) {152152+ btrfs_err(fs_info,153153+ "replace devid present without an active replace item");154154+ ret = -EUCLEAN;155155+ } else {156156+ dev_replace->srcdev = NULL;157157+ dev_replace->tgtdev = NULL;158158+ }159159 break;160160 case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:161161 case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
···34353435{34363436 struct rb_node *node;34373437 struct rb_node *next;34383438- struct ulist_node *entry = NULL;34383438+ struct ulist_node *entry;34393439 int ret = 0;3440344034413441 node = reserved->range_changed.root.rb_node;34423442+ if (!node)34433443+ return 0;34423444 while (node) {34433445 entry = rb_entry(node, struct ulist_node, rb_node);34443446 if (entry->val < start)34453447 node = node->rb_right;34463446- else if (entry)34473447- node = node->rb_left;34483448 else34493449- break;34493449+ node = node->rb_left;34503450 }34513451-34523452- /* Empty changeset */34533453- if (!entry)34543454- return 0;3455345134563452 if (entry->val > start && rb_prev(&entry->rb_node))34573453 entry = rb_entry(rb_prev(&entry->rb_node), struct ulist_node,
+1
fs/btrfs/ref-verify.c
···860860"dropping a ref for a root that doesn't have a ref on the block");861861 dump_block_entry(fs_info, be);862862 dump_ref_action(fs_info, ra);863863+ kfree(ref);863864 kfree(ra);864865 goto out_unlock;865866 }
+3-1
fs/btrfs/relocation.c
···16481648 struct btrfs_root_item *root_item;16491649 struct btrfs_path *path;16501650 struct extent_buffer *leaf;16511651+ int reserve_level;16511652 int level;16521653 int max_level;16531654 int replaced = 0;···16971696 * Thus the needed metadata size is at most root_level * nodesize,16981697 * and * 2 since we have two trees to COW.16991698 */17001700- min_reserved = fs_info->nodesize * btrfs_root_level(root_item) * 2;16991699+ reserve_level = max_t(int, 1, btrfs_root_level(root_item));17001700+ min_reserved = fs_info->nodesize * reserve_level * 2;17011701 memset(&next_key, 0, sizeof(next_key));1702170217031703 while (1) {
+3-2
fs/btrfs/scrub.c
···38663866 if (!is_dev_replace && !readonly &&38673867 !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {38683868 mutex_unlock(&fs_info->fs_devices->device_list_mutex);38693869- btrfs_err_in_rcu(fs_info, "scrub: device %s is not writable",38703870- rcu_str_deref(dev->name));38693869+ btrfs_err_in_rcu(fs_info,38703870+ "scrub on devid %llu: filesystem on %s is not writable",38713871+ devid, rcu_str_deref(dev->name));38713872 ret = -EROFS;38723873 goto out;38733874 }
+7-19
fs/btrfs/volumes.c
···10561056 continue;10571057 }1058105810591059- if (device->devid == BTRFS_DEV_REPLACE_DEVID) {10601060- /*10611061- * In the first step, keep the device which has10621062- * the correct fsid and the devid that is used10631063- * for the dev_replace procedure.10641064- * In the second step, the dev_replace state is10651065- * read from the device tree and it is known10661066- * whether the procedure is really active or10671067- * not, which means whether this device is10681068- * used or whether it should be removed.10691069- */10701070- if (step == 0 || test_bit(BTRFS_DEV_STATE_REPLACE_TGT,10711071- &device->dev_state)) {10721072- continue;10731073- }10741074- }10591059+ /*10601060+ * We have already validated the presence of BTRFS_DEV_REPLACE_DEVID,10611061+ * in btrfs_init_dev_replace() so just continue.10621062+ */10631063+ if (device->devid == BTRFS_DEV_REPLACE_DEVID)10641064+ continue;10651065+10751066 if (device->bdev) {10761067 blkdev_put(device->bdev, device->mode);10771068 device->bdev = NULL;···10711080 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {10721081 list_del_init(&device->dev_alloc_list);10731082 clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);10741074- if (!test_bit(BTRFS_DEV_STATE_REPLACE_TGT,10751075- &device->dev_state))10761076- fs_devices->rw_devices--;10771083 }10781084 list_del_init(&device->dev_list);10791085 fs_devices->num_devices--;
···42314231 dname.len, dname.name);4232423242334233 mutex_lock(&session->s_mutex);42344234- session->s_seq++;42344234+ inc_session_sequence(session);4235423542364236 if (!inode) {42374237 dout("handle_lease no inode %llx\n", vino.ino);···4385438543864386bool check_session_state(struct ceph_mds_session *s)43874387{43884388- if (s->s_state == CEPH_MDS_SESSION_CLOSING) {43894389- dout("resending session close request for mds%d\n",43904390- s->s_mds);43914391- request_close_session(s);43924392- return false;43934393- }43944394- if (s->s_ttl && time_after(jiffies, s->s_ttl)) {43954395- if (s->s_state == CEPH_MDS_SESSION_OPEN) {43884388+ switch (s->s_state) {43894389+ case CEPH_MDS_SESSION_OPEN:43904390+ if (s->s_ttl && time_after(jiffies, s->s_ttl)) {43964391 s->s_state = CEPH_MDS_SESSION_HUNG;43974392 pr_info("mds%d hung\n", s->s_mds);43984393 }43994399- }44004400- if (s->s_state == CEPH_MDS_SESSION_NEW ||44014401- s->s_state == CEPH_MDS_SESSION_RESTARTING ||44024402- s->s_state == CEPH_MDS_SESSION_CLOSED ||44034403- s->s_state == CEPH_MDS_SESSION_REJECTED)44044404- /* this mds is failed or recovering, just wait */43944394+ break;43954395+ case CEPH_MDS_SESSION_CLOSING:43964396+ /* Should never reach this when we're unmounting */43974397+ WARN_ON_ONCE(true);43984398+ fallthrough;43994399+ case CEPH_MDS_SESSION_NEW:44004400+ case CEPH_MDS_SESSION_RESTARTING:44014401+ case CEPH_MDS_SESSION_CLOSED:44024402+ case CEPH_MDS_SESSION_REJECTED:44054403 return false;44044404+ }4406440544074406 return true;44074407+}44084408+44094409+/*44104410+ * If the sequence is incremented while we're waiting on a REQUEST_CLOSE reply,44114411+ * then we need to retransmit that request.44124412+ */44134413+void inc_session_sequence(struct ceph_mds_session *s)44144414+{44154415+ lockdep_assert_held(&s->s_mutex);44164416+44174417+ s->s_seq++;44184418+44194419+ if (s->s_state == CEPH_MDS_SESSION_CLOSING) {44204420+ int ret;44214421+44224422+ dout("resending session close request for mds%d\n", s->s_mds);44234423+ ret = request_close_session(s);44244424+ if (ret < 0)44254425+ pr_err("unable to close session to mds%d: %d\n",44264426+ s->s_mds, ret);44274427+ }44084428}4409442944104430/*
···269269 * New inodes may not have an inode number assigned yet.270270 * Hashing their inode number is delayed until later.271271 */272272- if (ci->ci_inode->i_ino == 0)273273- WARN_ON(!(ci->ci_inode->i_state & I_CREATING));274274- else272272+ if (ci->ci_inode->i_ino)275273 fscrypt_hash_inode_number(ci, mk);276274 return 0;277275}
+11-10
fs/erofs/inode.c
···107107 i_gid_write(inode, le32_to_cpu(die->i_gid));108108 set_nlink(inode, le32_to_cpu(die->i_nlink));109109110110- /* ns timestamp */111111- inode->i_mtime.tv_sec = inode->i_ctime.tv_sec =112112- le64_to_cpu(die->i_ctime);113113- inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec =114114- le32_to_cpu(die->i_ctime_nsec);110110+ /* extended inode has its own timestamp */111111+ inode->i_ctime.tv_sec = le64_to_cpu(die->i_ctime);112112+ inode->i_ctime.tv_nsec = le32_to_cpu(die->i_ctime_nsec);115113116114 inode->i_size = le64_to_cpu(die->i_size);117115···147149 i_gid_write(inode, le16_to_cpu(dic->i_gid));148150 set_nlink(inode, le16_to_cpu(dic->i_nlink));149151150150- /* use build time to derive all file time */151151- inode->i_mtime.tv_sec = inode->i_ctime.tv_sec =152152- sbi->build_time;153153- inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec =154154- sbi->build_time_nsec;152152+ /* use build time for compact inodes */153153+ inode->i_ctime.tv_sec = sbi->build_time;154154+ inode->i_ctime.tv_nsec = sbi->build_time_nsec;155155156156 inode->i_size = le32_to_cpu(dic->i_size);157157 if (erofs_inode_is_data_compressed(vi->datalayout))···162166 err = -EOPNOTSUPP;163167 goto err_out;164168 }169169+170170+ inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;171171+ inode->i_atime.tv_sec = inode->i_ctime.tv_sec;172172+ inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;173173+ inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;165174166175 if (!nblks)167176 /* measure inode.i_blocks as generic filesystems */
+5-2
fs/erofs/zdata.c
···10781078 cond_resched();10791079 goto repeat;10801080 }10811081- set_page_private(page, (unsigned long)pcl);10821082- SetPagePrivate(page);10811081+10821082+ if (tocache) {10831083+ set_page_private(page, (unsigned long)pcl);10841084+ SetPagePrivate(page);10851085+ }10831086out: /* the only exit (for tracing and debugging) */10841087 return page;10851088}
+46-20
fs/ext4/ext4.h
···10281028 * protected by sbi->s_fc_lock.10291029 */1030103010311031- /* Fast commit subtid when this inode was committed */10321032- unsigned int i_fc_committed_subtid;10331033-10341031 /* Start of lblk range that needs to be committed in this fast commit */10351032 ext4_lblk_t i_fc_lblk_start;10361033···1419142214201423#ifdef __KERNEL__1421142414221422-/*14231423- * run-time mount flags14241424- */14251425-#define EXT4_MF_MNTDIR_SAMPLED 0x000114261426-#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */14271427-#define EXT4_MF_FC_INELIGIBLE 0x0004 /* Fast commit ineligible */14281428-#define EXT4_MF_FC_COMMITTING 0x0008 /* File system underoing a fast14291429- * commit.14301430- */14311431-14321425#ifdef CONFIG_FS_ENCRYPTION14331426#define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL)14341427#else···14531466 struct buffer_head * __rcu *s_group_desc;14541467 unsigned int s_mount_opt;14551468 unsigned int s_mount_opt2;14561456- unsigned int s_mount_flags;14691469+ unsigned long s_mount_flags;14571470 unsigned int s_def_mount_opt;14581471 ext4_fsblk_t s_sb_block;14591472 atomic64_t s_resv_clusters;···16821695})1683169616841697/*16981698+ * run-time mount flags16991699+ */17001700+enum {17011701+ EXT4_MF_MNTDIR_SAMPLED,17021702+ EXT4_MF_FS_ABORTED, /* Fatal error detected */17031703+ EXT4_MF_FC_INELIGIBLE, /* Fast commit ineligible */17041704+ EXT4_MF_FC_COMMITTING /* File system underoing a fast17051705+ * commit.17061706+ */17071707+};17081708+17091709+static inline void ext4_set_mount_flag(struct super_block *sb, int bit)17101710+{17111711+ set_bit(bit, &EXT4_SB(sb)->s_mount_flags);17121712+}17131713+17141714+static inline void ext4_clear_mount_flag(struct super_block *sb, int bit)17151715+{17161716+ clear_bit(bit, &EXT4_SB(sb)->s_mount_flags);17171717+}17181718+17191719+static inline int ext4_test_mount_flag(struct super_block *sb, int bit)17201720+{17211721+ return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);17221722+}17231723+17241724+17251725+/*16851726 * Simulate_fail codes16861727 */16871728#define EXT4_SIM_BBITMAP_EIO 1···18781863#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x001018791864#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x002018801865#define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x020018661866+/*18671867+ * The reason why "FAST_COMMIT" is a compat feature is that, FS becomes18681868+ * incompatible only if fast commit blocks are present in the FS. Since we18691869+ * clear the journal (and thus the fast commit blocks), we don't mark FS as18701870+ * incompatible. We also have a JBD2 incompat feature, which gets set when18711871+ * there are fast commit blocks present in the journal.18721872+ */18811873#define EXT4_FEATURE_COMPAT_FAST_COMMIT 0x040018821874#define EXT4_FEATURE_COMPAT_STABLE_INODES 0x080018831875···27532731int ext4_fc_info_show(struct seq_file *seq, void *v);27542732void ext4_fc_init(struct super_block *sb, journal_t *journal);27552733void ext4_fc_init_inode(struct inode *inode);27562756-void ext4_fc_track_range(struct inode *inode, ext4_lblk_t start,27342734+void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t start,27572735 ext4_lblk_t end);27582758-void ext4_fc_track_unlink(struct inode *inode, struct dentry *dentry);27592759-void ext4_fc_track_link(struct inode *inode, struct dentry *dentry);27602760-void ext4_fc_track_create(struct inode *inode, struct dentry *dentry);27612761-void ext4_fc_track_inode(struct inode *inode);27362736+void __ext4_fc_track_unlink(handle_t *handle, struct inode *inode,27372737+ struct dentry *dentry);27382738+void __ext4_fc_track_link(handle_t *handle, struct inode *inode,27392739+ struct dentry *dentry);27402740+void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry);27412741+void ext4_fc_track_link(handle_t *handle, struct dentry *dentry);27422742+void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);27432743+void ext4_fc_track_inode(handle_t *handle, struct inode *inode);27622744void ext4_fc_mark_ineligible(struct super_block *sb, int reason);27632745void ext4_fc_start_ineligible(struct super_block *sb, int reason);27642746void ext4_fc_stop_ineligible(struct super_block *sb);···34783452extern int ext4_ci_compare(const struct inode *parent,34793453 const struct qstr *fname,34803454 const struct qstr *entry, bool quick);34813481-extern int __ext4_unlink(struct inode *dir, const struct qstr *d_name,34553455+extern int __ext4_unlink(handle_t *handle, struct inode *dir, const struct qstr *d_name,34823456 struct inode *inode);34833457extern int __ext4_link(struct inode *dir, struct inode *inode,34843458 struct dentry *dentry);
+1-6
fs/ext4/extents.c
···37243724 err = ext4_ext_dirty(handle, inode, path + path->p_depth);37253725out:37263726 ext4_ext_show_leaf(inode, path);37273727- ext4_fc_track_range(inode, ee_block, ee_block + ee_len - 1);37283727 return err;37293728}37303729···37953796 if (*allocated > map->m_len)37963797 *allocated = map->m_len;37973798 map->m_len = *allocated;37983798- ext4_fc_track_range(inode, ee_block, ee_block + ee_len - 1);37993799 return 0;38003800}38013801···43274329 map->m_len = ar.len;43284330 allocated = map->m_len;43294331 ext4_ext_show_leaf(inode, path);43304330- ext4_fc_track_range(inode, map->m_lblk, map->m_lblk + map->m_len - 1);43314332out:43324333 ext4_ext_drop_refs(path);43334334 kfree(path);···45994602 ret = ext4_mark_inode_dirty(handle, inode);46004603 if (unlikely(ret))46014604 goto out_handle;46024602- ext4_fc_track_range(inode, offset >> inode->i_sb->s_blocksize_bits,46054605+ ext4_fc_track_range(handle, inode, offset >> inode->i_sb->s_blocksize_bits,46034606 (offset + len - 1) >> inode->i_sb->s_blocksize_bits);46044607 /* Zero out partial block at the edges of the range */46054608 ret = ext4_zero_partial_blocks(handle, inode, offset, len);···46484651 FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |46494652 FALLOC_FL_INSERT_RANGE))46504653 return -EOPNOTSUPP;46514651- ext4_fc_track_range(inode, offset >> blkbits,46524652- (offset + len - 1) >> blkbits);4653465446544655 ext4_fc_start_update(inode);46554656
+90-84
fs/ext4/fast_commit.c
···8383 *8484 * Atomicity of commits8585 * --------------------8686- * In order to gaurantee atomicity during the commit operation, fast commit8686+ * In order to guarantee atomicity during the commit operation, fast commit8787 * uses "EXT4_FC_TAG_TAIL" tag that marks a fast commit as complete. Tail8888 * tag contains CRC of the contents and TID of the transaction after which8989 * this fast commit should be applied. Recovery code replays fast commit···152152 INIT_LIST_HEAD(&ei->i_fc_list);153153 init_waitqueue_head(&ei->i_fc_wait);154154 atomic_set(&ei->i_fc_updates, 0);155155- ei->i_fc_committed_subtid = 0;155155+}156156+157157+/* This function must be called with sbi->s_fc_lock held. */158158+static void ext4_fc_wait_committing_inode(struct inode *inode)159159+__releases(&EXT4_SB(inode->i_sb)->s_fc_lock)160160+{161161+ wait_queue_head_t *wq;162162+ struct ext4_inode_info *ei = EXT4_I(inode);163163+164164+#if (BITS_PER_LONG < 64)165165+ DEFINE_WAIT_BIT(wait, &ei->i_state_flags,166166+ EXT4_STATE_FC_COMMITTING);167167+ wq = bit_waitqueue(&ei->i_state_flags,168168+ EXT4_STATE_FC_COMMITTING);169169+#else170170+ DEFINE_WAIT_BIT(wait, &ei->i_flags,171171+ EXT4_STATE_FC_COMMITTING);172172+ wq = bit_waitqueue(&ei->i_flags,173173+ EXT4_STATE_FC_COMMITTING);174174+#endif175175+ lockdep_assert_held(&EXT4_SB(inode->i_sb)->s_fc_lock);176176+ prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE);177177+ spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock);178178+ schedule();179179+ finish_wait(wq, &wait.wq_entry);156180}157181158182/*···200176 goto out;201177202178 if (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) {203203- wait_queue_head_t *wq;204204-#if (BITS_PER_LONG < 64)205205- DEFINE_WAIT_BIT(wait, &ei->i_state_flags,206206- EXT4_STATE_FC_COMMITTING);207207- wq = bit_waitqueue(&ei->i_state_flags,208208- EXT4_STATE_FC_COMMITTING);209209-#else210210- DEFINE_WAIT_BIT(wait, &ei->i_flags,211211- EXT4_STATE_FC_COMMITTING);212212- wq = bit_waitqueue(&ei->i_flags,213213- EXT4_STATE_FC_COMMITTING);214214-#endif215215- prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE);216216- spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock);217217- schedule();218218- finish_wait(wq, &wait.wq_entry);179179+ ext4_fc_wait_committing_inode(inode);219180 goto restart;220181 }221182out:···243234 }244235245236 if (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) {246246- wait_queue_head_t *wq;247247-#if (BITS_PER_LONG < 64)248248- DEFINE_WAIT_BIT(wait, &ei->i_state_flags,249249- EXT4_STATE_FC_COMMITTING);250250- wq = bit_waitqueue(&ei->i_state_flags,251251- EXT4_STATE_FC_COMMITTING);252252-#else253253- DEFINE_WAIT_BIT(wait, &ei->i_flags,254254- EXT4_STATE_FC_COMMITTING);255255- wq = bit_waitqueue(&ei->i_flags,256256- EXT4_STATE_FC_COMMITTING);257257-#endif258258- prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE);259259- spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock);260260- schedule();261261- finish_wait(wq, &wait.wq_entry);237237+ ext4_fc_wait_committing_inode(inode);262238 goto restart;263239 }264264- if (!list_empty(&ei->i_fc_list))265265- list_del_init(&ei->i_fc_list);240240+ list_del_init(&ei->i_fc_list);266241 spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock);267242}268243···262269 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))263270 return;264271265265- sbi->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;272272+ ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);266273 WARN_ON(reason >= EXT4_FC_REASON_MAX);267274 sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;268275}···295302 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))296303 return;297304298298- EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;305305+ ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);299306 atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates);300307}301308302309static inline int ext4_fc_is_ineligible(struct super_block *sb)303310{304304- return (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FC_INELIGIBLE) ||305305- atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates);311311+ return (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE) ||312312+ atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates));306313}307314308315/*···316323 * If enqueue is set, this function enqueues the inode in fast commit list.317324 */318325static int ext4_fc_track_template(319319- struct inode *inode, int (*__fc_track_fn)(struct inode *, void *, bool),326326+ handle_t *handle, struct inode *inode,327327+ int (*__fc_track_fn)(struct inode *, void *, bool),320328 void *args, int enqueue)321329{322322- tid_t running_txn_tid;323330 bool update = false;324331 struct ext4_inode_info *ei = EXT4_I(inode);325332 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);333333+ tid_t tid = 0;326334 int ret;327335328336 if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) ||···333339 if (ext4_fc_is_ineligible(inode->i_sb))334340 return -EINVAL;335341336336- running_txn_tid = sbi->s_journal ?337337- sbi->s_journal->j_commit_sequence + 1 : 0;338338-342342+ tid = handle->h_transaction->t_tid;339343 mutex_lock(&ei->i_fc_lock);340340- if (running_txn_tid == ei->i_sync_tid) {344344+ if (tid == ei->i_sync_tid) {341345 update = true;342346 } else {343347 ext4_fc_reset_inode(inode);344344- ei->i_sync_tid = running_txn_tid;348348+ ei->i_sync_tid = tid;345349 }346350 ret = __fc_track_fn(inode, args, update);347351 mutex_unlock(&ei->i_fc_lock);···350358 spin_lock(&sbi->s_fc_lock);351359 if (list_empty(&EXT4_I(inode)->i_fc_list))352360 list_add_tail(&EXT4_I(inode)->i_fc_list,353353- (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING) ?361361+ (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) ?354362 &sbi->s_fc_q[FC_Q_STAGING] :355363 &sbi->s_fc_q[FC_Q_MAIN]);356364 spin_unlock(&sbi->s_fc_lock);···376384 mutex_unlock(&ei->i_fc_lock);377385 node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS);378386 if (!node) {379379- ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_MEM);387387+ ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM);380388 mutex_lock(&ei->i_fc_lock);381389 return -ENOMEM;382390 }···389397 if (!node->fcd_name.name) {390398 kmem_cache_free(ext4_fc_dentry_cachep, node);391399 ext4_fc_mark_ineligible(inode->i_sb,392392- EXT4_FC_REASON_MEM);400400+ EXT4_FC_REASON_NOMEM);393401 mutex_lock(&ei->i_fc_lock);394402 return -ENOMEM;395403 }···403411 node->fcd_name.len = dentry->d_name.len;404412405413 spin_lock(&sbi->s_fc_lock);406406- if (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING)414414+ if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING))407415 list_add_tail(&node->fcd_list,408416 &sbi->s_fc_dentry_q[FC_Q_STAGING]);409417 else···414422 return 0;415423}416424417417-void ext4_fc_track_unlink(struct inode *inode, struct dentry *dentry)425425+void __ext4_fc_track_unlink(handle_t *handle,426426+ struct inode *inode, struct dentry *dentry)418427{419428 struct __track_dentry_update_args args;420429 int ret;···423430 args.dentry = dentry;424431 args.op = EXT4_FC_TAG_UNLINK;425432426426- ret = ext4_fc_track_template(inode, __track_dentry_update,433433+ ret = ext4_fc_track_template(handle, inode, __track_dentry_update,427434 (void *)&args, 0);428435 trace_ext4_fc_track_unlink(inode, dentry, ret);429436}430437431431-void ext4_fc_track_link(struct inode *inode, struct dentry *dentry)438438+void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry)439439+{440440+ __ext4_fc_track_unlink(handle, d_inode(dentry), dentry);441441+}442442+443443+void __ext4_fc_track_link(handle_t *handle,444444+ struct inode *inode, struct dentry *dentry)432445{433446 struct __track_dentry_update_args args;434447 int ret;···442443 args.dentry = dentry;443444 args.op = EXT4_FC_TAG_LINK;444445445445- ret = ext4_fc_track_template(inode, __track_dentry_update,446446+ ret = ext4_fc_track_template(handle, inode, __track_dentry_update,446447 (void *)&args, 0);447448 trace_ext4_fc_track_link(inode, dentry, ret);448449}449450450450-void ext4_fc_track_create(struct inode *inode, struct dentry *dentry)451451+void ext4_fc_track_link(handle_t *handle, struct dentry *dentry)452452+{453453+ __ext4_fc_track_link(handle, d_inode(dentry), dentry);454454+}455455+456456+void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)451457{452458 struct __track_dentry_update_args args;459459+ struct inode *inode = d_inode(dentry);453460 int ret;454461455462 args.dentry = dentry;456463 args.op = EXT4_FC_TAG_CREAT;457464458458- ret = ext4_fc_track_template(inode, __track_dentry_update,465465+ ret = ext4_fc_track_template(handle, inode, __track_dentry_update,459466 (void *)&args, 0);460467 trace_ext4_fc_track_create(inode, dentry, ret);461468}···477472 return 0;478473}479474480480-void ext4_fc_track_inode(struct inode *inode)475475+void ext4_fc_track_inode(handle_t *handle, struct inode *inode)481476{482477 int ret;483478484479 if (S_ISDIR(inode->i_mode))485480 return;486481487487- ret = ext4_fc_track_template(inode, __track_inode, NULL, 1);482482+ if (ext4_should_journal_data(inode)) {483483+ ext4_fc_mark_ineligible(inode->i_sb,484484+ EXT4_FC_REASON_INODE_JOURNAL_DATA);485485+ return;486486+ }487487+488488+ ret = ext4_fc_track_template(handle, inode, __track_inode, NULL, 1);488489 trace_ext4_fc_track_inode(inode, ret);489490}490491···526515 return 0;527516}528517529529-void ext4_fc_track_range(struct inode *inode, ext4_lblk_t start,518518+void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t start,530519 ext4_lblk_t end)531520{532521 struct __track_range_args args;···538527 args.start = start;539528 args.end = end;540529541541- ret = ext4_fc_track_template(inode, __track_range, &args, 1);530530+ ret = ext4_fc_track_template(handle, inode, __track_range, &args, 1);542531543532 trace_ext4_fc_track_range(inode, start, end, ret);544533}···548537 int write_flags = REQ_SYNC;549538 struct buffer_head *bh = EXT4_SB(sb)->s_fc_bh;550539540540+ /* TODO: REQ_FUA | REQ_PREFLUSH is unnecessarily expensive. */551541 if (test_opt(sb, BARRIER))552542 write_flags |= REQ_FUA | REQ_PREFLUSH;553543 lock_buffer(bh);554554- clear_buffer_dirty(bh);544544+ set_buffer_dirty(bh);555545 set_buffer_uptodate(bh);556546 bh->b_end_io = ext4_end_buffer_io_sync;557547 submit_bh(REQ_OP_WRITE, write_flags, bh);···858846 int ret = 0;859847860848 spin_lock(&sbi->s_fc_lock);861861- sbi->s_mount_flags |= EXT4_MF_FC_COMMITTING;849849+ ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);862850 list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {863851 ei = list_entry(pos, struct ext4_inode_info, i_fc_list);864852 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);···912900913901/* Commit all the directory entry updates */914902static int ext4_fc_commit_dentry_updates(journal_t *journal, u32 *crc)903903+__acquires(&sbi->s_fc_lock)904904+__releases(&sbi->s_fc_lock)915905{916906 struct super_block *sb = (struct super_block *)(journal->j_private);917907 struct ext4_sb_info *sbi = EXT4_SB(sb);···1010996 if (ret)1011997 return ret;1012998999999+ /*10001000+ * If file system device is different from journal device, issue a cache10011001+ * flush before we start writing fast commit blocks.10021002+ */10031003+ if (journal->j_fs_dev != journal->j_dev)10041004+ blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS);10051005+10131006 blk_start_plug(&plug);10141007 if (sbi->s_fc_bytes == 0) {10151008 /*···10521031 if (ret)10531032 goto out;10541033 spin_lock(&sbi->s_fc_lock);10551055- EXT4_I(inode)->i_fc_committed_subtid =10561056- atomic_read(&sbi->s_fc_subtid);10571034 }10581035 spin_unlock(&sbi->s_fc_lock);10591036···11501131 "Fast commit ended with blks = %d, reason = %d, subtid - %d",11511132 nblks, reason, subtid);11521133 if (reason == EXT4_FC_REASON_FC_FAILED)11531153- return jbd2_fc_end_commit_fallback(journal, commit_tid);11341134+ return jbd2_fc_end_commit_fallback(journal);11541135 if (reason == EXT4_FC_REASON_FC_START_FAILED ||11551136 reason == EXT4_FC_REASON_INELIGIBLE)11561137 return jbd2_complete_transaction(journal, commit_tid);···12091190 list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],12101191 &sbi->s_fc_q[FC_Q_STAGING]);1211119212121212- sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;12131213- sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;11931193+ ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING);11941194+ ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);1214119512151196 if (full)12161197 sbi->s_fc_bytes = 0;···12821263 return 0;12831264 }1284126512851285- ret = __ext4_unlink(old_parent, &entry, inode);12661266+ ret = __ext4_unlink(NULL, old_parent, &entry, inode);12861267 /* -ENOENT ok coz it might not exist anymore. */12871268 if (ret == -ENOENT)12881269 ret = 0;···2098207920992080void ext4_fc_init(struct super_block *sb, journal_t *journal)21002081{21012101- int num_fc_blocks;21022102-21032082 /*21042083 * We set replay callback even if fast commit disabled because we may21052084 * could still have fast commit blocks that need to be replayed even if···21072090 if (!test_opt2(sb, JOURNAL_FAST_COMMIT))21082091 return;21092092 journal->j_fc_cleanup_callback = ext4_fc_cleanup;21102110- if (!buffer_uptodate(journal->j_sb_buffer)21112111- && ext4_read_bh_lock(journal->j_sb_buffer, REQ_META | REQ_PRIO,21122112- true)) {21132113- ext4_msg(sb, KERN_ERR, "I/O error on journal");21142114- return;21152115- }21162116- num_fc_blocks = be32_to_cpu(journal->j_superblock->s_num_fc_blks);21172117- if (jbd2_fc_init(journal, num_fc_blocks ? num_fc_blocks :21182118- EXT4_NUM_FC_BLKS)) {21192119- pr_warn("Error while enabling fast commits, turning off.");21202120- ext4_clear_feature_fast_commit(sb);21212121- }21222093}2123209421242124-const char *fc_ineligible_reasons[] = {20952095+static const char *fc_ineligible_reasons[] = {21252096 "Extended attributes changed",21262097 "Cross rename",21272098 "Journal flag changed",···21182113 "Resize",21192114 "Dir renamed",21202115 "Falloc range op",21162116+ "Data journalling",21212117 "FC Commit Failed"21222118};21232119
+2-4
fs/ext4/fast_commit.h
···33#ifndef __FAST_COMMIT_H__44#define __FAST_COMMIT_H__5566-/* Number of blocks in journal area to allocate for fast commits */77-#define EXT4_NUM_FC_BLKS 25688-96/* Fast commit tags */107#define EXT4_FC_TAG_ADD_RANGE 0x0001118#define EXT4_FC_TAG_DEL_RANGE 0x0002···97100 EXT4_FC_REASON_XATTR = 0,98101 EXT4_FC_REASON_CROSS_RENAME,99102 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,100100- EXT4_FC_REASON_MEM,103103+ EXT4_FC_REASON_NOMEM,101104 EXT4_FC_REASON_SWAP_BOOT,102105 EXT4_FC_REASON_RESIZE,103106 EXT4_FC_REASON_RENAME_DIR,104107 EXT4_FC_REASON_FALLOC_RANGE,108108+ EXT4_FC_REASON_INODE_JOURNAL_DATA,105109 EXT4_FC_COMMIT_FAILED,106110 EXT4_FC_REASON_MAX107111};
+2-4
fs/ext4/file.c
···761761 if (!daxdev_mapping_supported(vma, dax_dev))762762 return -EOPNOTSUPP;763763764764- ext4_fc_start_update(inode);765764 file_accessed(file);766765 if (IS_DAX(file_inode(file))) {767766 vma->vm_ops = &ext4_dax_vm_ops;···768769 } else {769770 vma->vm_ops = &ext4_file_vm_ops;770771 }771771- ext4_fc_stop_update(inode);772772 return 0;773773}774774···780782 handle_t *handle;781783 int err;782784783783- if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED))785785+ if (likely(ext4_test_mount_flag(sb, EXT4_MF_MNTDIR_SAMPLED)))784786 return 0;785787786788 if (sb_rdonly(sb) || !sb_start_intwrite_trylock(sb))787789 return 0;788790789789- sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;791791+ ext4_set_mount_flag(sb, EXT4_MF_MNTDIR_SAMPLED);790792 /*791793 * Sample where the filesystem has been mounted and792794 * store it in the superblock for sysadmin convenience
+1-1
fs/ext4/fsmap.c
···280280281281 /* Fabricate an rmap entry for the external log device. */282282 irec.fmr_physical = journal->j_blk_offset;283283- irec.fmr_length = journal->j_maxlen;283283+ irec.fmr_length = journal->j_total_len;284284 irec.fmr_owner = EXT4_FMR_OWN_LOG;285285 irec.fmr_flags = 0;286286
+1-1
fs/ext4/fsync.c
···143143 if (sb_rdonly(inode->i_sb)) {144144 /* Make sure that we read updated s_mount_flags value */145145 smp_rmb();146146- if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)146146+ if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))147147 ret = -EROFS;148148 goto out;149149 }
···995995 if (mm) {996996 kthread_unuse_mm(mm);997997 mmput(mm);998998+ current->mm = NULL;998999 }9991000}1000100110011002static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx)10021003{10031003- if (!current->mm) {10041004- if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||10051005- !ctx->sqo_task->mm ||10061006- !mmget_not_zero(ctx->sqo_task->mm)))10071007- return -EFAULT;10081008- kthread_use_mm(ctx->sqo_task->mm);10041004+ struct mm_struct *mm;10051005+10061006+ if (current->mm)10071007+ return 0;10081008+10091009+ /* Should never happen */10101010+ if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL)))10111011+ return -EFAULT;10121012+10131013+ task_lock(ctx->sqo_task);10141014+ mm = ctx->sqo_task->mm;10151015+ if (unlikely(!mm || !mmget_not_zero(mm)))10161016+ mm = NULL;10171017+ task_unlock(ctx->sqo_task);10181018+10191019+ if (mm) {10201020+ kthread_use_mm(mm);10211021+ return 0;10091022 }1010102310111011- return 0;10241024+ return -EFAULT;10121025}1013102610141027static int io_sq_thread_acquire_mm(struct io_ring_ctx *ctx,···12871274 /* add one for this request */12881275 refcount_inc(&id->count);1289127612901290- /* drop old identity, assign new one. one ref for req, one for tctx */12911291- if (req->work.identity != tctx->identity &&12921292- refcount_sub_and_test(2, &req->work.identity->count))12771277+ /* drop tctx and req identity references, if needed */12781278+ if (tctx->identity != &tctx->__identity &&12791279+ refcount_dec_and_test(&tctx->identity->count))12801280+ kfree(tctx->identity);12811281+ if (req->work.identity != &tctx->__identity &&12821282+ refcount_dec_and_test(&req->work.identity->count))12931283 kfree(req->work.identity);1294128412951285 req->work.identity = id;···15931577 }15941578}1595157915961596-static inline bool io_match_files(struct io_kiocb *req,15971597- struct files_struct *files)15801580+static inline bool __io_match_files(struct io_kiocb *req,15811581+ struct files_struct *files)15981582{15831583+ return ((req->flags & REQ_F_WORK_INITIALIZED) &&15841584+ (req->work.flags & IO_WQ_WORK_FILES)) &&15851585+ req->work.identity->files == files;15861586+}15871587+15881588+static bool io_match_files(struct io_kiocb *req,15891589+ struct files_struct *files)15901590+{15911591+ struct io_kiocb *link;15921592+15991593 if (!files)16001594 return true;16011601- if ((req->flags & REQ_F_WORK_INITIALIZED) &&16021602- (req->work.flags & IO_WQ_WORK_FILES))16031603- return req->work.identity->files == files;15951595+ if (__io_match_files(req, files))15961596+ return true;15971597+ if (req->flags & REQ_F_LINK_HEAD) {15981598+ list_for_each_entry(link, &req->link_list, link_list) {15991599+ if (__io_match_files(link, files))16001600+ return true;16011601+ }16021602+ }16041603 return false;16051604}16061605···16991668 WRITE_ONCE(cqe->user_data, req->user_data);17001669 WRITE_ONCE(cqe->res, res);17011670 WRITE_ONCE(cqe->flags, cflags);17021702- } else if (ctx->cq_overflow_flushed || req->task->io_uring->in_idle) {16711671+ } else if (ctx->cq_overflow_flushed ||16721672+ atomic_read(&req->task->io_uring->in_idle)) {17031673 /*17041674 * If we're in ring overflow flush mode, or in task cancel mode,17051675 * then we cannot store the request for later flushing, we need···18701838 io_dismantle_req(req);1871183918721840 percpu_counter_dec(&tctx->inflight);18731873- if (tctx->in_idle)18411841+ if (atomic_read(&tctx->in_idle))18741842 wake_up(&tctx->wait);18751843 put_task_struct(req->task);18761844···77277695 xa_init(&tctx->xa);77287696 init_waitqueue_head(&tctx->wait);77297697 tctx->last = NULL;77307730- tctx->in_idle = 0;76987698+ atomic_set(&tctx->in_idle, 0);76997699+ tctx->sqpoll = false;77317700 io_init_identity(&tctx->__identity);77327701 tctx->identity = &tctx->__identity;77337702 task->io_uring = tctx;···84218388 return false;84228389}8423839084248424-static bool io_match_link_files(struct io_kiocb *req,84258425- struct files_struct *files)84268426-{84278427- struct io_kiocb *link;84288428-84298429- if (io_match_files(req, files))84308430- return true;84318431- if (req->flags & REQ_F_LINK_HEAD) {84328432- list_for_each_entry(link, &req->link_list, link_list) {84338433- if (io_match_files(link, files))84348434- return true;84358435- }84368436- }84378437- return false;84388438-}84398439-84408391/*84418392 * We're looking to cancel 'req' because it's holding on to our files, but84428393 * 'req' could be a link to another request. See if it is, and cancel that···8470845384718454static bool io_cancel_link_cb(struct io_wq_work *work, void *data)84728455{84738473- return io_match_link(container_of(work, struct io_kiocb, work), data);84568456+ struct io_kiocb *req = container_of(work, struct io_kiocb, work);84578457+ bool ret;84588458+84598459+ if (req->flags & REQ_F_LINK_TIMEOUT) {84608460+ unsigned long flags;84618461+ struct io_ring_ctx *ctx = req->ctx;84628462+84638463+ /* protect against races with linked timeouts */84648464+ spin_lock_irqsave(&ctx->completion_lock, flags);84658465+ ret = io_match_link(req, data);84668466+ spin_unlock_irqrestore(&ctx->completion_lock, flags);84678467+ } else {84688468+ ret = io_match_link(req, data);84698469+ }84708470+ return ret;84748471}8475847284768473static void io_attempt_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req)···85108479}8511848085128481static void io_cancel_defer_files(struct io_ring_ctx *ctx,84828482+ struct task_struct *task,85138483 struct files_struct *files)85148484{85158485 struct io_defer_entry *de = NULL;···8518848685198487 spin_lock_irq(&ctx->completion_lock);85208488 list_for_each_entry_reverse(de, &ctx->defer_list, list) {85218521- if (io_match_link_files(de->req, files)) {84898489+ if (io_task_match(de->req, task) &&84908490+ io_match_files(de->req, files)) {85228491 list_cut_position(&list, &ctx->defer_list, &de->list);85238492 break;85248493 }···85458512 if (list_empty_careful(&ctx->inflight_list))85468513 return false;8547851485488548- io_cancel_defer_files(ctx, files);85498515 /* cancel all at once, should be faster than doing it one by one*/85508516 io_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true);85518517···86308598{86318599 struct task_struct *task = current;8632860086338633- if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data)86018601+ if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {86348602 task = ctx->sq_data->thread;86038603+ atomic_inc(&task->io_uring->in_idle);86048604+ io_sq_thread_park(ctx->sq_data);86058605+ }86068606+86078607+ if (files)86088608+ io_cancel_defer_files(ctx, NULL, files);86098609+ else86108610+ io_cancel_defer_files(ctx, task, NULL);8635861186368612 io_cqring_overflow_flush(ctx, true, task, files);86378613···86478607 io_run_task_work();86488608 cond_resched();86498609 }86108610+86118611+ if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {86128612+ atomic_dec(&task->io_uring->in_idle);86138613+ /*86148614+ * If the files that are going away are the ones in the thread86158615+ * identity, clear them out.86168616+ */86178617+ if (task->io_uring->identity->files == files)86188618+ task->io_uring->identity->files = NULL;86198619+ io_sq_thread_unpark(ctx->sq_data);86208620+ }86508621}8651862286528623/*86538624 * Note that this task has used io_uring. We use it for cancelation purposes.86548625 */86558655-static int io_uring_add_task_file(struct file *file)86268626+static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)86568627{86578628 struct io_uring_task *tctx = current->io_uring;86588629···86848633 }86858634 tctx->last = file;86868635 }86368636+86378637+ /*86388638+ * This is race safe in that the task itself is doing this, hence it86398639+ * cannot be going through the exit/cancel paths at the same time.86408640+ * This cannot be modified while exit/cancel is running.86418641+ */86428642+ if (!tctx->sqpoll && (ctx->flags & IORING_SETUP_SQPOLL))86438643+ tctx->sqpoll = true;8687864486888645 return 0;86898646}···87348675 unsigned long index;8735867687368677 /* make sure overflow events are dropped */87378737- tctx->in_idle = true;86788678+ atomic_inc(&tctx->in_idle);8738867987398680 xa_for_each(&tctx->xa, index, file) {87408681 struct io_ring_ctx *ctx = file->private_data;···87438684 if (files)87448685 io_uring_del_task_file(file);87458686 }86878687+86888688+ atomic_dec(&tctx->in_idle);86898689+}86908690+86918691+static s64 tctx_inflight(struct io_uring_task *tctx)86928692+{86938693+ unsigned long index;86948694+ struct file *file;86958695+ s64 inflight;86968696+86978697+ inflight = percpu_counter_sum(&tctx->inflight);86988698+ if (!tctx->sqpoll)86998699+ return inflight;87008700+87018701+ /*87028702+ * If we have SQPOLL rings, then we need to iterate and find them, and87038703+ * add the pending count for those.87048704+ */87058705+ xa_for_each(&tctx->xa, index, file) {87068706+ struct io_ring_ctx *ctx = file->private_data;87078707+87088708+ if (ctx->flags & IORING_SETUP_SQPOLL) {87098709+ struct io_uring_task *__tctx = ctx->sqo_task->io_uring;87108710+87118711+ inflight += percpu_counter_sum(&__tctx->inflight);87128712+ }87138713+ }87148714+87158715+ return inflight;87468716}8747871787488718/*···87858697 s64 inflight;8786869887878699 /* make sure overflow events are dropped */87888788- tctx->in_idle = true;87008700+ atomic_inc(&tctx->in_idle);8789870187908702 do {87918703 /* read completions before cancelations */87928792- inflight = percpu_counter_sum(&tctx->inflight);87048704+ inflight = tctx_inflight(tctx);87938705 if (!inflight)87948706 break;87958707 __io_uring_files_cancel(NULL);···88008712 * If we've seen completions, retry. This avoids a race where88018713 * a completion comes in before we did prepare_to_wait().88028714 */88038803- if (inflight != percpu_counter_sum(&tctx->inflight))87158715+ if (inflight != tctx_inflight(tctx))88048716 continue;88058717 schedule();88068718 } while (1);8807871988088720 finish_wait(&tctx->wait, &wait);88098809- tctx->in_idle = false;87218721+ atomic_dec(&tctx->in_idle);88108722}8811872388128724static int io_uring_flush(struct file *file, void *data)···89518863 io_sqpoll_wait_sq(ctx);89528864 submitted = to_submit;89538865 } else if (to_submit) {89548954- ret = io_uring_add_task_file(f.file);88668866+ ret = io_uring_add_task_file(ctx, f.file);89558867 if (unlikely(ret))89568868 goto out;89578869 mutex_lock(&ctx->uring_lock);···89888900#ifdef CONFIG_PROC_FS89898901static int io_uring_show_cred(int id, void *p, void *data)89908902{89918991- const struct cred *cred = p;89038903+ struct io_identity *iod = p;89048904+ const struct cred *cred = iod->creds;89928905 struct seq_file *m = data;89938906 struct user_namespace *uns = seq_user_ns(m);89948907 struct group_info *gi;···91819092#if defined(CONFIG_UNIX)91829093 ctx->ring_sock->file = file;91839094#endif91849184- if (unlikely(io_uring_add_task_file(file))) {90959095+ if (unlikely(io_uring_add_task_file(ctx, file))) {91859096 file = ERR_PTR(-ENOMEM);91869097 goto err_fd;91879098 }
+10-20
fs/iomap/buffered-io.c
···13741374 WARN_ON_ONCE(!wpc->ioend && !list_empty(&submit_list));13751375 WARN_ON_ONCE(!PageLocked(page));13761376 WARN_ON_ONCE(PageWriteback(page));13771377+ WARN_ON_ONCE(PageDirty(page));1377137813781379 /*13791380 * We cannot cancel the ioend directly here on error. We may have···13831382 * appropriately.13841383 */13851384 if (unlikely(error)) {13851385+ /*13861386+ * Let the filesystem know what portion of the current page13871387+ * failed to map. If the page wasn't been added to ioend, it13881388+ * won't be affected by I/O completion and we must unlock it13891389+ * now.13901390+ */13911391+ if (wpc->ops->discard_page)13921392+ wpc->ops->discard_page(page, file_offset);13861393 if (!count) {13871387- /*13881388- * If the current page hasn't been added to ioend, it13891389- * won't be affected by I/O completions and we must13901390- * discard and unlock it right here.13911391- */13921392- if (wpc->ops->discard_page)13931393- wpc->ops->discard_page(page);13941394 ClearPageUptodate(page);13951395 unlock_page(page);13961396 goto done;13971397 }13981398-13991399- /*14001400- * If the page was not fully cleaned, we need to ensure that the14011401- * higher layers come back to it correctly. That means we need14021402- * to keep the page dirty, and for WB_SYNC_ALL writeback we need14031403- * to ensure the PAGECACHE_TAG_TOWRITE index mark is not removed14041404- * so another attempt to write this page in this writeback sweep14051405- * will be made.14061406- */14071407- set_page_writeback_keepwrite(page);14081408- } else {14091409- clear_page_dirty_for_io(page);14101410- set_page_writeback(page);14111398 }1412139914001400+ set_page_writeback(page);14131401 unlock_page(page);1414140214151403 /*
+2
fs/jbd2/checkpoint.c
···106106 * for a checkpoint to free up some space in the log.107107 */108108void __jbd2_log_wait_for_space(journal_t *journal)109109+__acquires(&journal->j_state_lock)110110+__releases(&journal->j_state_lock)109111{110112 int nblocks, space_left;111113 /* assert_spin_locked(&journal->j_state_lock); */
+10-1
fs/jbd2/commit.c
···450450 schedule();451451 write_lock(&journal->j_state_lock);452452 finish_wait(&journal->j_fc_wait, &wait);453453+ /*454454+ * TODO: by blocking fast commits here, we are increasing455455+ * fsync() latency slightly. Strictly speaking, we don't need456456+ * to block fast commits until the transaction enters T_FLUSH457457+ * state. So an optimization is possible where we block new fast458458+ * commits here and wait for existing ones to complete459459+ * just before we enter T_FLUSH. That way, the existing fast460460+ * commits and this full commit can proceed parallely.461461+ */453462 }454463 write_unlock(&journal->j_state_lock);455464···810801 if (first_block < journal->j_tail)811802 freed += journal->j_last - journal->j_first;812803 /* Update tail only if we free significant amount of space */813813- if (freed < journal->j_maxlen / 4)804804+ if (freed < jbd2_journal_get_max_txn_bufs(journal))814805 update_tail = 0;815806 }816807 J_ASSERT(commit_transaction->t_state == T_COMMIT);
+78-62
fs/jbd2/journal.c
···727727 */728728int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)729729{730730+ if (unlikely(is_journal_aborted(journal)))731731+ return -EIO;730732 /*731733 * Fast commits only allowed if at least one full commit has732734 * been processed.···736734 if (!journal->j_stats.ts_tid)737735 return -EINVAL;738736739739- if (tid <= journal->j_commit_sequence)740740- return -EALREADY;741741-742737 write_lock(&journal->j_state_lock);738738+ if (tid <= journal->j_commit_sequence) {739739+ write_unlock(&journal->j_state_lock);740740+ return -EALREADY;741741+ }742742+743743 if (journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||744744 (journal->j_flags & JBD2_FAST_COMMIT_ONGOING)) {745745 DEFINE_WAIT(wait);···781777782778int jbd2_fc_end_commit(journal_t *journal)783779{784784- return __jbd2_fc_end_commit(journal, 0, 0);780780+ return __jbd2_fc_end_commit(journal, 0, false);785781}786782EXPORT_SYMBOL(jbd2_fc_end_commit);787783788788-int jbd2_fc_end_commit_fallback(journal_t *journal, tid_t tid)784784+int jbd2_fc_end_commit_fallback(journal_t *journal)789785{790790- return __jbd2_fc_end_commit(journal, tid, 1);786786+ tid_t tid;787787+788788+ read_lock(&journal->j_state_lock);789789+ tid = journal->j_running_transaction ?790790+ journal->j_running_transaction->t_tid : 0;791791+ read_unlock(&journal->j_state_lock);792792+ return __jbd2_fc_end_commit(journal, tid, true);791793}792794EXPORT_SYMBOL(jbd2_fc_end_commit_fallback);793795···875865 int fc_off;876866877867 *bh_out = NULL;878878- write_lock(&journal->j_state_lock);879868880869 if (journal->j_fc_off + journal->j_fc_first < journal->j_fc_last) {881870 fc_off = journal->j_fc_off;···883874 } else {884875 ret = -EINVAL;885876 }886886- write_unlock(&journal->j_state_lock);887877888878 if (ret)889879 return ret;···895887 if (!bh)896888 return -ENOMEM;897889898898- lock_buffer(bh);899890900900- clear_buffer_uptodate(bh);901901- set_buffer_dirty(bh);902902- unlock_buffer(bh);903891 journal->j_fc_wbuf[fc_off] = bh;904892905893 *bh_out = bh;···913909 struct buffer_head *bh;914910 int i, j_fc_off;915911916916- read_lock(&journal->j_state_lock);917912 j_fc_off = journal->j_fc_off;918918- read_unlock(&journal->j_state_lock);919913920914 /*921915 * Wait in reverse order to minimize chances of us being woken up before···941939 struct buffer_head *bh;942940 int i, j_fc_off;943941944944- read_lock(&journal->j_state_lock);945942 j_fc_off = journal->j_fc_off;946946- read_unlock(&journal->j_state_lock);947943948944 /*949945 * Wait in reverse order to minimize chances of us being woken up before···13481348 journal->j_dev = bdev;13491349 journal->j_fs_dev = fs_dev;13501350 journal->j_blk_offset = start;13511351- journal->j_maxlen = len;13511351+ journal->j_total_len = len;13521352 /* We need enough buffers to write out full descriptor block. */13531353 n = journal->j_blocksize / jbd2_min_tag_size();13541354 journal->j_wbufsize = n;13551355+ journal->j_fc_wbuf = NULL;13551356 journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *),13561357 GFP_KERNEL);13571358 if (!journal->j_wbuf)13581359 goto err_cleanup;13591359-13601360- if (journal->j_fc_wbufsize > 0) {13611361- journal->j_fc_wbuf = kmalloc_array(journal->j_fc_wbufsize,13621362- sizeof(struct buffer_head *),13631363- GFP_KERNEL);13641364- if (!journal->j_fc_wbuf)13651365- goto err_cleanup;13661366- }1367136013681361 bh = getblk_unmovable(journal->j_dev, start, journal->j_blocksize);13691362 if (!bh) {···1371137813721379err_cleanup:13731380 kfree(journal->j_wbuf);13741374- kfree(journal->j_fc_wbuf);13751381 jbd2_journal_destroy_revoke(journal);13761382 kfree(journal);13771383 return NULL;13781384}13791379-13801380-int jbd2_fc_init(journal_t *journal, int num_fc_blks)13811381-{13821382- journal->j_fc_wbufsize = num_fc_blks;13831383- journal->j_fc_wbuf = kmalloc_array(journal->j_fc_wbufsize,13841384- sizeof(struct buffer_head *), GFP_KERNEL);13851385- if (!journal->j_fc_wbuf)13861386- return -ENOMEM;13871387- return 0;13881388-}13891389-EXPORT_SYMBOL(jbd2_fc_init);1390138513911386/* jbd2_journal_init_dev and jbd2_journal_init_inode:13921387 *···14931512 }1494151314951514 journal->j_first = first;14961496-14971497- if (jbd2_has_feature_fast_commit(journal) &&14981498- journal->j_fc_wbufsize > 0) {14991499- journal->j_fc_last = last;15001500- journal->j_last = last - journal->j_fc_wbufsize;15011501- journal->j_fc_first = journal->j_last + 1;15021502- journal->j_fc_off = 0;15031503- } else {15041504- journal->j_last = last;15051505- }15151515+ journal->j_last = last;1506151615071517 journal->j_head = journal->j_first;15081518 journal->j_tail = journal->j_first;···15031531 journal->j_commit_sequence = journal->j_transaction_sequence - 1;15041532 journal->j_commit_request = journal->j_commit_sequence;1505153315061506- journal->j_max_transaction_buffers = journal->j_maxlen / 4;15341534+ journal->j_max_transaction_buffers = jbd2_journal_get_max_txn_bufs(journal);15351535+15361536+ /*15371537+ * Now that journal recovery is done, turn fast commits off here. This15381538+ * way, if fast commit was enabled before the crash but if now FS has15391539+ * disabled it, we don't enable fast commits.15401540+ */15411541+ jbd2_clear_feature_fast_commit(journal);1507154215081543 /*15091544 * As a special case, if the on-disk copy is already marked as needing···17711792 goto out;17721793 }1773179417741774- if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen)17751775- journal->j_maxlen = be32_to_cpu(sb->s_maxlen);17761776- else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) {17951795+ if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len)17961796+ journal->j_total_len = be32_to_cpu(sb->s_maxlen);17971797+ else if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) {17771798 printk(KERN_WARNING "JBD2: journal file too short\n");17781799 goto out;17791800 }1780180117811802 if (be32_to_cpu(sb->s_first) == 0 ||17821782- be32_to_cpu(sb->s_first) >= journal->j_maxlen) {18031803+ be32_to_cpu(sb->s_first) >= journal->j_total_len) {17831804 printk(KERN_WARNING17841805 "JBD2: Invalid start block of journal: %u\n",17851806 be32_to_cpu(sb->s_first));···18511872{18521873 int err;18531874 journal_superblock_t *sb;18751875+ int num_fc_blocks;1854187618551877 err = journal_get_superblock(journal);18561878 if (err)···18631883 journal->j_tail = be32_to_cpu(sb->s_start);18641884 journal->j_first = be32_to_cpu(sb->s_first);18651885 journal->j_errno = be32_to_cpu(sb->s_errno);18861886+ journal->j_last = be32_to_cpu(sb->s_maxlen);1866188718671867- if (jbd2_has_feature_fast_commit(journal) &&18681868- journal->j_fc_wbufsize > 0) {18881888+ if (jbd2_has_feature_fast_commit(journal)) {18691889 journal->j_fc_last = be32_to_cpu(sb->s_maxlen);18701870- journal->j_last = journal->j_fc_last - journal->j_fc_wbufsize;18901890+ num_fc_blocks = be32_to_cpu(sb->s_num_fc_blks);18911891+ if (!num_fc_blocks)18921892+ num_fc_blocks = JBD2_MIN_FC_BLOCKS;18931893+ if (journal->j_last - num_fc_blocks >= JBD2_MIN_JOURNAL_BLOCKS)18941894+ journal->j_last = journal->j_fc_last - num_fc_blocks;18711895 journal->j_fc_first = journal->j_last + 1;18721896 journal->j_fc_off = 0;18731873- } else {18741874- journal->j_last = be32_to_cpu(sb->s_maxlen);18751897 }1876189818771899 return 0;···19361954 */19371955 journal->j_flags &= ~JBD2_ABORT;1938195619391939- if (journal->j_fc_wbufsize > 0)19401940- jbd2_journal_set_features(journal, 0, 0,19411941- JBD2_FEATURE_INCOMPAT_FAST_COMMIT);19421957 /* OK, we've finished with the dynamic journal bits:19431958 * reinitialise the dynamic contents of the superblock in memory19441959 * and reset them on disk. */···20192040 jbd2_journal_destroy_revoke(journal);20202041 if (journal->j_chksum_driver)20212042 crypto_free_shash(journal->j_chksum_driver);20222022- if (journal->j_fc_wbufsize > 0)20232023- kfree(journal->j_fc_wbuf);20432043+ kfree(journal->j_fc_wbuf);20242044 kfree(journal->j_wbuf);20252045 kfree(journal);20262046···20942116 return 0;20952117}2096211821192119+static int21202120+jbd2_journal_initialize_fast_commit(journal_t *journal)21212121+{21222122+ journal_superblock_t *sb = journal->j_superblock;21232123+ unsigned long long num_fc_blks;21242124+21252125+ num_fc_blks = be32_to_cpu(sb->s_num_fc_blks);21262126+ if (num_fc_blks == 0)21272127+ num_fc_blks = JBD2_MIN_FC_BLOCKS;21282128+ if (journal->j_last - num_fc_blks < JBD2_MIN_JOURNAL_BLOCKS)21292129+ return -ENOSPC;21302130+21312131+ /* Are we called twice? */21322132+ WARN_ON(journal->j_fc_wbuf != NULL);21332133+ journal->j_fc_wbuf = kmalloc_array(num_fc_blks,21342134+ sizeof(struct buffer_head *), GFP_KERNEL);21352135+ if (!journal->j_fc_wbuf)21362136+ return -ENOMEM;21372137+21382138+ journal->j_fc_wbufsize = num_fc_blks;21392139+ journal->j_fc_last = journal->j_last;21402140+ journal->j_last = journal->j_fc_last - num_fc_blks;21412141+ journal->j_fc_first = journal->j_last + 1;21422142+ journal->j_fc_off = 0;21432143+ journal->j_free = journal->j_last - journal->j_first;21442144+ journal->j_max_transaction_buffers =21452145+ jbd2_journal_get_max_txn_bufs(journal);21462146+21472147+ return 0;21482148+}21492149+20972150/**20982151 * int jbd2_journal_set_features() - Mark a given journal feature in the superblock20992152 * @journal: Journal to act on.···21672158 compat, ro, incompat);2168215921692160 sb = journal->j_superblock;21612161+21622162+ if (incompat & JBD2_FEATURE_INCOMPAT_FAST_COMMIT) {21632163+ if (jbd2_journal_initialize_fast_commit(journal)) {21642164+ pr_err("JBD2: Cannot enable fast commits.\n");21652165+ return 0;21662166+ }21672167+ }2170216821712169 /* Load the checksum driver if necessary */21722170 if ((journal->j_chksum_driver == NULL) &&
+3-3
fs/jbd2/recovery.c
···74747575 /* Do up to 128K of readahead */7676 max = start + (128 * 1024 / journal->j_blocksize);7777- if (max > journal->j_maxlen)7878- max = journal->j_maxlen;7777+ if (max > journal->j_total_len)7878+ max = journal->j_total_len;79798080 /* Do the readahead itself. We'll submit MAXBUF buffer_heads at8181 * a time to the block device IO layer. */···134134135135 *bhp = NULL;136136137137- if (offset >= journal->j_maxlen) {137137+ if (offset >= journal->j_total_len) {138138 printk(KERN_ERR "JBD2: corrupted journal superblock\n");139139 return -EFSCORRUPTED;140140 }
···247247#define asm_inline asm248248#endif249249250250-#ifndef __no_fgcse251251-# define __no_fgcse252252-#endif253253-254250/* Are two types/vars the same type (ignoring qualifiers)? */255251#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))256252
+16-2
include/linux/cpufreq.h
···110110 bool fast_switch_enabled;111111112112 /*113113+ * Set if the CPUFREQ_GOV_STRICT_TARGET flag is set for the current114114+ * governor.115115+ */116116+ bool strict_target;117117+118118+ /*113119 * Preferred average time interval between consecutive invocations of114120 * the driver to set the frequency for this policy. To be set by the115121 * scaling driver (0, which is the default, means no preference).···576570 char *buf);577571 int (*store_setspeed) (struct cpufreq_policy *policy,578572 unsigned int freq);579579- /* For governors which change frequency dynamically by themselves */580580- bool dynamic_switching;581573 struct list_head governor_list;582574 struct module *owner;575575+ u8 flags;583576};577577+578578+/* Governor flags */579579+580580+/* For governors which change frequency dynamically by themselves */581581+#define CPUFREQ_GOV_DYNAMIC_SWITCHING BIT(0)582582+583583+/* For governors wanting the target frequency to be set exactly */584584+#define CPUFREQ_GOV_STRICT_TARGET BIT(1)585585+584586585587/* Pass a target to the cpufreq driver */586588unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
···221221 * Optional, allows the file system to discard state on a page where222222 * we failed to submit any I/O.223223 */224224- void (*discard_page)(struct page *page);224224+ void (*discard_page)(struct page *page, loff_t fileoff);225225};226226227227struct iomap_writepage_ctx {
+15-8
include/linux/jbd2.h
···6868extern void jbd2_free(void *ptr, size_t size);69697070#define JBD2_MIN_JOURNAL_BLOCKS 10247171+#define JBD2_MIN_FC_BLOCKS 25671727273#ifdef __KERNEL__7374···945944 /**946945 * @j_fc_off:947946 *948948- * Number of fast commit blocks currently allocated.949949- * [j_state_lock].947947+ * Number of fast commit blocks currently allocated. Accessed only948948+ * during fast commit. Currently only process can do fast commit, so949949+ * this field is not protected by any lock.950950 */951951 unsigned long j_fc_off;952952···990988 struct block_device *j_fs_dev;991989992990 /**993993- * @j_maxlen: Total maximum capacity of the journal region on disk.991991+ * @j_total_len: Total maximum capacity of the journal region on disk.994992 */995995- unsigned int j_maxlen;993993+ unsigned int j_total_len;996994997995 /**998996 * @j_reserved_credits:···11101108 struct buffer_head **j_wbuf;1111110911121110 /**11131113- * @j_fc_wbuf: Array of fast commit bhs for11141114- * jbd2_journal_commit_transaction.11111111+ * @j_fc_wbuf: Array of fast commit bhs for fast commit. Accessed only11121112+ * during a fast commit. Currently only process can do fast commit, so11131113+ * this field is not protected by any lock.11151114 */11161115 struct buffer_head **j_fc_wbuf;11171116···16171614extern int jbd2_cleanup_journal_tail(journal_t *);1618161516191616/* Fast commit related APIs */16201620-int jbd2_fc_init(journal_t *journal, int num_fc_blks);16211617int jbd2_fc_begin_commit(journal_t *journal, tid_t tid);16221618int jbd2_fc_end_commit(journal_t *journal);16231623-int jbd2_fc_end_commit_fallback(journal_t *journal, tid_t tid);16191619+int jbd2_fc_end_commit_fallback(journal_t *journal);16241620int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out);16251621int jbd2_submit_inode_data(struct jbd2_inode *jinode);16261622int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode);16271623int jbd2_fc_wait_bufs(journal_t *journal, int num_blks);16281624int jbd2_fc_release_bufs(journal_t *journal);16251625+16261626+static inline int jbd2_journal_get_max_txn_bufs(journal_t *journal)16271627+{16281628+ return (journal->j_total_len - journal->j_fc_wbufsize) / 4;16291629+}1629163016301631/*16311632 * is_journal_abort
···1313#include <linux/bpf_verifier.h>1414#include <net/bpf_sk_storage.h>1515#include <linux/bpf_local_storage.h>1616+#include <linux/btf_ids.h>16171718/* For every LSM hook that allows attachment of BPF programs, declare a nop1819 * function where a BPF program can be attached.···2726#include <linux/lsm_hook_defs.h>2827#undef LSM_HOOK29283030-#define BPF_LSM_SYM_PREFX "bpf_lsm_"2929+#define LSM_HOOK(RET, DEFAULT, NAME, ...) BTF_ID(func, bpf_lsm_##NAME)3030+BTF_SET_START(bpf_lsm_hooks)3131+#include <linux/lsm_hook_defs.h>3232+#undef LSM_HOOK3333+BTF_SET_END(bpf_lsm_hooks)31343235int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,3336 const struct bpf_prog *prog)···4237 return -EINVAL;4338 }44394545- if (strncmp(BPF_LSM_SYM_PREFX, prog->aux->attach_func_name,4646- sizeof(BPF_LSM_SYM_PREFX) - 1)) {4040+ if (!btf_id_set_contains(&bpf_lsm_hooks, prog->aux->attach_btf_id)) {4741 bpf_log(vlog, "attach_btf_id %u points to wrong type name %s\n",4842 prog->aux->attach_btf_id, prog->aux->attach_func_name);4943 return -EINVAL;
···821821 }822822}823823824824+static void pcpu_init_value(struct bpf_htab *htab, void __percpu *pptr,825825+ void *value, bool onallcpus)826826+{827827+ /* When using prealloc and not setting the initial value on all cpus,828828+ * zero-fill element values for other cpus (just as what happens when829829+ * not using prealloc). Otherwise, bpf program has no way to ensure830830+ * known initial values for cpus other than current one831831+ * (onallcpus=false always when coming from bpf prog).832832+ */833833+ if (htab_is_prealloc(htab) && !onallcpus) {834834+ u32 size = round_up(htab->map.value_size, 8);835835+ int current_cpu = raw_smp_processor_id();836836+ int cpu;837837+838838+ for_each_possible_cpu(cpu) {839839+ if (cpu == current_cpu)840840+ bpf_long_memcpy(per_cpu_ptr(pptr, cpu), value,841841+ size);842842+ else843843+ memset(per_cpu_ptr(pptr, cpu), 0, size);844844+ }845845+ } else {846846+ pcpu_copy_value(htab, pptr, value, onallcpus);847847+ }848848+}849849+824850static bool fd_htab_map_needs_adjust(const struct bpf_htab *htab)825851{826852 return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS &&···917891 }918892 }919893920920- pcpu_copy_value(htab, pptr, value, onallcpus);894894+ pcpu_init_value(htab, pptr, value, onallcpus);921895922896 if (!prealloc)923897 htab_elem_set_ptr(l_new, key_size, pptr);···12091183 pcpu_copy_value(htab, htab_elem_get_ptr(l_old, key_size),12101184 value, onallcpus);12111185 } else {12121212- pcpu_copy_value(htab, htab_elem_get_ptr(l_new, key_size),11861186+ pcpu_init_value(htab, htab_elem_get_ptr(l_new, key_size),12131187 value, onallcpus);12141188 hlist_nulls_add_head_rcu(&l_new->hash_node, head);12151189 l_new = NULL;
+1
kernel/bpf/preload/Kconfig
···66menuconfig BPF_PRELOAD77 bool "Preload BPF file system with kernel specific program and map iterators"88 depends on BPF99+ depends on BPF_SYSCALL910 # The dependency on !COMPILE_TEST prevents it from being enabled1011 # in allmodconfig or allyesconfig configurations1112 depends on !COMPILE_TEST
···337337 * already contains a warning when RCU is not watching, so no point338338 * in having another one here.339339 */340340+ lockdep_hardirqs_off(CALLER_ADDR0);340341 instrumentation_begin();341342 rcu_irq_enter_check_tick();342342- /* Use the combo lockdep/tracing function */343343- trace_hardirqs_off();343343+ trace_hardirqs_off_finish();344344 instrumentation_end();345345346346 return ret;
···454454 mmap_read_unlock(mm);455455456456 self.task = current;457457- self.next = xchg(&core_state->dumper.next, &self);457457+ if (self.task->flags & PF_SIGNALED)458458+ self.next = xchg(&core_state->dumper.next, &self);459459+ else460460+ self.task = NULL;458461 /*459462 * Implies mb(), the result of xchg() must be visible460463 * to core_state->dumper.
+5-5
kernel/fork.c
···21672167 /* ok, now we should be set up.. */21682168 p->pid = pid_nr(pid);21692169 if (clone_flags & CLONE_THREAD) {21702170- p->exit_signal = -1;21712170 p->group_leader = current->group_leader;21722171 p->tgid = current->tgid;21732172 } else {21742174- if (clone_flags & CLONE_PARENT)21752175- p->exit_signal = current->group_leader->exit_signal;21762176- else21772177- p->exit_signal = args->exit_signal;21782173 p->group_leader = p;21792174 p->tgid = p->pid;21802175 }···22132218 if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {22142219 p->real_parent = current->real_parent;22152220 p->parent_exec_id = current->parent_exec_id;22212221+ if (clone_flags & CLONE_THREAD)22222222+ p->exit_signal = -1;22232223+ else22242224+ p->exit_signal = current->group_leader->exit_signal;22162225 } else {22172226 p->real_parent = current;22182227 p->parent_exec_id = current->self_exec_id;22282228+ p->exit_signal = args->exit_signal;22192229 }2220223022212231 klp_copy_process(p);
+14-2
kernel/futex.c
···23802380 }2381238123822382 /*23832383- * Since we just failed the trylock; there must be an owner.23832383+ * The trylock just failed, so either there is an owner or23842384+ * there is a higher priority waiter than this one.23842385 */23852386 newowner = rt_mutex_owner(&pi_state->pi_mutex);23862386- BUG_ON(!newowner);23872387+ /*23882388+ * If the higher priority waiter has not yet taken over the23892389+ * rtmutex then newowner is NULL. We can't return here with23902390+ * that state because it's inconsistent vs. the user space23912391+ * state. So drop the locks and try again. It's a valid23922392+ * situation and not any different from the other retry23932393+ * conditions.23942394+ */23952395+ if (unlikely(!newowner)) {23962396+ err = -EAGAIN;23972397+ goto handle_err;23982398+ }23872399 } else {23882400 WARN_ON_ONCE(argowner != current);23892401 if (oldowner == current) {
···82548254{82558255 struct devlink_port_attrs *attrs = &devlink_port->attrs;8256825682578257- if (WARN_ON(devlink_port->registered))82588258- return -EEXIST;82598257 devlink_port->attrs_set = true;82608258 attrs->flavour = flavour;82618259 if (attrs->switch_id.id_len) {···82778279{82788280 int ret;8279828182828282+ if (WARN_ON(devlink_port->registered))82838283+ return;82808284 devlink_port->attrs = *attrs;82818285 ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);82828286 if (ret)···83018301 struct devlink_port_attrs *attrs = &devlink_port->attrs;83028302 int ret;8303830383048304+ if (WARN_ON(devlink_port->registered))83058305+ return;83048306 ret = __devlink_port_attrs_set(devlink_port,83058307 DEVLINK_PORT_FLAVOUR_PCI_PF);83068308 if (ret)···83288326 struct devlink_port_attrs *attrs = &devlink_port->attrs;83298327 int ret;8330832883298329+ if (WARN_ON(devlink_port->registered))83308330+ return;83318331 ret = __devlink_port_attrs_set(devlink_port,83328332 DEVLINK_PORT_FLAVOUR_PCI_VF);83338333 if (ret)
···287287sub output_rest {288288 create_labels();289289290290+ my $part = "";291291+290292 foreach my $what (sort {291293 ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") ||292294 $a cmp $b···308306 $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;309307310308 if ($type ne "File") {309309+ my $cur_part = $what;310310+ if ($what =~ '/') {311311+ if ($what =~ m#^(\/?(?:[\w\-]+\/?){1,2})#) {312312+ $cur_part = "Symbols under $1";313313+ $cur_part =~ s,/$,,;314314+ }315315+ }316316+317317+ if ($cur_part ne "" && $part ne $cur_part) {318318+ $part = $cur_part;319319+ my $bar = $part;320320+ $bar =~ s/./-/g;321321+ print "$part\n$bar\n\n";322322+ }323323+311324 printf ".. _%s:\n\n", $data{$what}->{label};312325313326 my @names = split /, /,$w;···369352370353 if (!($desc =~ /^\s*$/)) {371354 if ($description_is_rst) {355355+ # Remove title markups from the description356356+ # Having titles inside ABI files will only work if extra357357+ # care would be taken in order to strictly follow the same358358+ # level order for each markup.359359+ $desc =~ s/\n[\-\*\=\^\~]+\n/\n\n/g;360360+372361 # Enrich text by creating cross-references373362374363 $desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
+6-1
tools/bpf/bpftool/feature.c
···843843 else844844 p_err("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'",845845 capability_msg(bpf_caps, 0),846846+#ifdef CAP_BPF846847 capability_msg(bpf_caps, 1),847848 capability_msg(bpf_caps, 2),848848- capability_msg(bpf_caps, 3));849849+ capability_msg(bpf_caps, 3)850850+#else851851+ "", "", "", "", "", ""852852+#endif /* CAP_BPF */853853+ );849854 goto exit_free;850855 }851856
···7070static inline void7171fexit_update_maps(u32 id, struct bpf_perf_event_value *after)7272{7373- struct bpf_perf_event_value *before, diff, *accum;7373+ struct bpf_perf_event_value *before, diff;74747575 before = bpf_map_lookup_elem(&fentry_readings, &id);7676 /* only account samples with a valid fentry_reading */···9595{9696 struct bpf_perf_event_value readings[MAX_NUM_MATRICS];9797 u32 cpu = bpf_get_smp_processor_id();9898- u32 i, one = 1, zero = 0;9898+ u32 i, zero = 0;9999 int err;100100 u64 *count;101101
+9-6
tools/lib/bpf/hashmap.h
···1515static inline size_t hash_bits(size_t h, int bits)1616{1717 /* shuffle bits and return requested number of upper bits */1818+ if (bits == 0)1919+ return 0;2020+1821#if (__SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__)1922 /* LP64 case */2023 return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits);···177174 * @key: key to iterate entries for178175 */179176#define hashmap__for_each_key_entry(map, cur, _key) \180180- for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\181181- map->cap_bits); \182182- map->buckets ? map->buckets[bkt] : NULL; }); \177177+ for (cur = map->buckets \178178+ ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \179179+ : NULL; \183180 cur; \184181 cur = cur->next) \185182 if (map->equal_fn(cur->key, (_key), map->ctx))186183187184#define hashmap__for_each_key_entry_safe(map, cur, tmp, _key) \188188- for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\189189- map->cap_bits); \190190- cur = map->buckets ? map->buckets[bkt] : NULL; }); \185185+ for (cur = map->buckets \186186+ ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \187187+ : NULL; \191188 cur && ({ tmp = cur->next; true; }); \192189 cur = tmp) \193190 if (map->equal_fn(cur->key, (_key), map->ctx))
+6-3
tools/lib/bpf/xsk.c
···891891void xsk_socket__delete(struct xsk_socket *xsk)892892{893893 size_t desc_sz = sizeof(struct xdp_desc);894894- struct xsk_ctx *ctx = xsk->ctx;895894 struct xdp_mmap_offsets off;895895+ struct xsk_umem *umem;896896+ struct xsk_ctx *ctx;896897 int err;897898898899 if (!xsk)899900 return;900901902902+ ctx = xsk->ctx;903903+ umem = ctx->umem;901904 if (ctx->prog_fd != -1) {902905 xsk_delete_bpf_maps(xsk);903906 close(ctx->prog_fd);···920917921918 xsk_put_ctx(ctx);922919923923- ctx->umem->refcount--;920920+ umem->refcount--;924921 /* Do not close an fd that also has an associated umem connected925922 * to it.926923 */927927- if (xsk->fd != ctx->umem->fd)924924+ if (xsk->fd != umem->fd)928925 close(xsk->fd);929926 free(xsk);930927}
···622622 }623623}624624625625+/*626626+ * Open a file, and exit on failure627627+ */628628+FILE *fopen_or_die(const char *path, const char *mode)629629+{630630+ FILE *filep = fopen(path, "r");631631+632632+ if (!filep)633633+ err(1, "%s: open failed", path);634634+ return filep;635635+}636636+637637+void err_on_hypervisor(void)638638+{639639+ FILE *cpuinfo;640640+ char *flags, *hypervisor;641641+ char *buffer;642642+643643+ /* On VMs /proc/cpuinfo contains a "flags" entry for hypervisor */644644+ cpuinfo = fopen_or_die("/proc/cpuinfo", "ro");645645+646646+ buffer = malloc(4096);647647+ if (!buffer) {648648+ fclose(cpuinfo);649649+ err(-ENOMEM, "buffer malloc fail");650650+ }651651+652652+ if (!fread(buffer, 1024, 1, cpuinfo)) {653653+ fclose(cpuinfo);654654+ free(buffer);655655+ err(1, "Reading /proc/cpuinfo failed");656656+ }657657+658658+ flags = strstr(buffer, "flags");659659+ rewind(cpuinfo);660660+ fseek(cpuinfo, flags - buffer, SEEK_SET);661661+ if (!fgets(buffer, 4096, cpuinfo)) {662662+ fclose(cpuinfo);663663+ free(buffer);664664+ err(1, "Reading /proc/cpuinfo failed");665665+ }666666+ fclose(cpuinfo);667667+668668+ hypervisor = strstr(buffer, "hypervisor");669669+670670+ free(buffer);671671+672672+ if (hypervisor)673673+ err(-1,674674+ "not supported on this virtual machine");675675+}625676626677int get_msr(int cpu, int offset, unsigned long long *msr)627678{···686635 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root", pathname);687636688637 retval = pread(fd, msr, sizeof(*msr), offset);689689- if (retval != sizeof(*msr))638638+ if (retval != sizeof(*msr)) {639639+ err_on_hypervisor();690640 err(-1, "%s offset 0x%llx read failed", pathname, (unsigned long long)offset);641641+ }691642692643 if (debug > 1)693644 fprintf(stderr, "get_msr(cpu%d, 0x%X, 0x%llX)\n", cpu, offset, *msr);···1137108411381085 update_hwp_request(cpu);11391086 return 0;11401140-}11411141-11421142-/*11431143- * Open a file, and exit on failure11441144- */11451145-FILE *fopen_or_die(const char *path, const char *mode)11461146-{11471147- FILE *filep = fopen(path, "r");11481148-11491149- if (!filep)11501150- err(1, "%s: open failed", path);11511151- return filep;11521087}1153108811541089unsigned int get_pkg_num(int cpu)
+214
tools/testing/selftests/bpf/prog_tests/map_init.c
···11+// SPDX-License-Identifier: GPL-2.0-only22+/* Copyright (c) 2020 Tessares SA <http://www.tessares.net> */33+44+#include <test_progs.h>55+#include "test_map_init.skel.h"66+77+#define TEST_VALUE 0x123488+#define FILL_VALUE 0xdeadbeef99+1010+static int nr_cpus;1111+static int duration;1212+1313+typedef unsigned long long map_key_t;1414+typedef unsigned long long map_value_t;1515+typedef struct {1616+ map_value_t v; /* padding */1717+} __bpf_percpu_val_align pcpu_map_value_t;1818+1919+2020+static int map_populate(int map_fd, int num)2121+{2222+ pcpu_map_value_t value[nr_cpus];2323+ int i, err;2424+ map_key_t key;2525+2626+ for (i = 0; i < nr_cpus; i++)2727+ bpf_percpu(value, i) = FILL_VALUE;2828+2929+ for (key = 1; key <= num; key++) {3030+ err = bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST);3131+ if (!ASSERT_OK(err, "bpf_map_update_elem"))3232+ return -1;3333+ }3434+3535+ return 0;3636+}3737+3838+static struct test_map_init *setup(enum bpf_map_type map_type, int map_sz,3939+ int *map_fd, int populate)4040+{4141+ struct test_map_init *skel;4242+ int err;4343+4444+ skel = test_map_init__open();4545+ if (!ASSERT_OK_PTR(skel, "skel_open"))4646+ return NULL;4747+4848+ err = bpf_map__set_type(skel->maps.hashmap1, map_type);4949+ if (!ASSERT_OK(err, "bpf_map__set_type"))5050+ goto error;5151+5252+ err = bpf_map__set_max_entries(skel->maps.hashmap1, map_sz);5353+ if (!ASSERT_OK(err, "bpf_map__set_max_entries"))5454+ goto error;5555+5656+ err = test_map_init__load(skel);5757+ if (!ASSERT_OK(err, "skel_load"))5858+ goto error;5959+6060+ *map_fd = bpf_map__fd(skel->maps.hashmap1);6161+ if (CHECK(*map_fd < 0, "bpf_map__fd", "failed\n"))6262+ goto error;6363+6464+ err = map_populate(*map_fd, populate);6565+ if (!ASSERT_OK(err, "map_populate"))6666+ goto error_map;6767+6868+ return skel;6969+7070+error_map:7171+ close(*map_fd);7272+error:7373+ test_map_init__destroy(skel);7474+ return NULL;7575+}7676+7777+/* executes bpf program that updates map with key, value */7878+static int prog_run_insert_elem(struct test_map_init *skel, map_key_t key,7979+ map_value_t value)8080+{8181+ struct test_map_init__bss *bss;8282+8383+ bss = skel->bss;8484+8585+ bss->inKey = key;8686+ bss->inValue = value;8787+ bss->inPid = getpid();8888+8989+ if (!ASSERT_OK(test_map_init__attach(skel), "skel_attach"))9090+ return -1;9191+9292+ /* Let tracepoint trigger */9393+ syscall(__NR_getpgid);9494+9595+ test_map_init__detach(skel);9696+9797+ return 0;9898+}9999+100100+static int check_values_one_cpu(pcpu_map_value_t *value, map_value_t expected)101101+{102102+ int i, nzCnt = 0;103103+ map_value_t val;104104+105105+ for (i = 0; i < nr_cpus; i++) {106106+ val = bpf_percpu(value, i);107107+ if (val) {108108+ if (CHECK(val != expected, "map value",109109+ "unexpected for cpu %d: 0x%llx\n", i, val))110110+ return -1;111111+ nzCnt++;112112+ }113113+ }114114+115115+ if (CHECK(nzCnt != 1, "map value", "set for %d CPUs instead of 1!\n",116116+ nzCnt))117117+ return -1;118118+119119+ return 0;120120+}121121+122122+/* Add key=1 elem with values set for all CPUs123123+ * Delete elem key=1124124+ * Run bpf prog that inserts new key=1 elem with value=0x1234125125+ * (bpf prog can only set value for current CPU)126126+ * Lookup Key=1 and check value is as expected for all CPUs:127127+ * value set by bpf prog for one CPU, 0 for all others128128+ */129129+static void test_pcpu_map_init(void)130130+{131131+ pcpu_map_value_t value[nr_cpus];132132+ struct test_map_init *skel;133133+ int map_fd, err;134134+ map_key_t key;135135+136136+ /* max 1 elem in map so insertion is forced to reuse freed entry */137137+ skel = setup(BPF_MAP_TYPE_PERCPU_HASH, 1, &map_fd, 1);138138+ if (!ASSERT_OK_PTR(skel, "prog_setup"))139139+ return;140140+141141+ /* delete element so the entry can be re-used*/142142+ key = 1;143143+ err = bpf_map_delete_elem(map_fd, &key);144144+ if (!ASSERT_OK(err, "bpf_map_delete_elem"))145145+ goto cleanup;146146+147147+ /* run bpf prog that inserts new elem, re-using the slot just freed */148148+ err = prog_run_insert_elem(skel, key, TEST_VALUE);149149+ if (!ASSERT_OK(err, "prog_run_insert_elem"))150150+ goto cleanup;151151+152152+ /* check that key=1 was re-created by bpf prog */153153+ err = bpf_map_lookup_elem(map_fd, &key, value);154154+ if (!ASSERT_OK(err, "bpf_map_lookup_elem"))155155+ goto cleanup;156156+157157+ /* and has expected values */158158+ check_values_one_cpu(value, TEST_VALUE);159159+160160+cleanup:161161+ test_map_init__destroy(skel);162162+}163163+164164+/* Add key=1 and key=2 elems with values set for all CPUs165165+ * Run bpf prog that inserts new key=3 elem166166+ * (only for current cpu; other cpus should have initial value = 0)167167+ * Lookup Key=1 and check value is as expected for all CPUs168168+ */169169+static void test_pcpu_lru_map_init(void)170170+{171171+ pcpu_map_value_t value[nr_cpus];172172+ struct test_map_init *skel;173173+ int map_fd, err;174174+ map_key_t key;175175+176176+ /* Set up LRU map with 2 elements, values filled for all CPUs.177177+ * With these 2 elements, the LRU map is full178178+ */179179+ skel = setup(BPF_MAP_TYPE_LRU_PERCPU_HASH, 2, &map_fd, 2);180180+ if (!ASSERT_OK_PTR(skel, "prog_setup"))181181+ return;182182+183183+ /* run bpf prog that inserts new key=3 element, re-using LRU slot */184184+ key = 3;185185+ err = prog_run_insert_elem(skel, key, TEST_VALUE);186186+ if (!ASSERT_OK(err, "prog_run_insert_elem"))187187+ goto cleanup;188188+189189+ /* check that key=3 replaced one of earlier elements */190190+ err = bpf_map_lookup_elem(map_fd, &key, value);191191+ if (!ASSERT_OK(err, "bpf_map_lookup_elem"))192192+ goto cleanup;193193+194194+ /* and has expected values */195195+ check_values_one_cpu(value, TEST_VALUE);196196+197197+cleanup:198198+ test_map_init__destroy(skel);199199+}200200+201201+void test_map_init(void)202202+{203203+ nr_cpus = bpf_num_possible_cpus();204204+ if (nr_cpus <= 1) {205205+ printf("%s:SKIP: >1 cpu needed for this test\n", __func__);206206+ test__skip();207207+ return;208208+ }209209+210210+ if (test__start_subtest("pcpu_map_init"))211211+ test_pcpu_map_init();212212+ if (test__start_subtest("pcpu_lru_map_init"))213213+ test_pcpu_lru_map_init();214214+}
···11+// SPDX-License-Identifier: GPL-2.022+/* Copyright (c) 2020 Tessares SA <http://www.tessares.net> */33+44+#include "vmlinux.h"55+#include <bpf/bpf_helpers.h>66+77+__u64 inKey = 0;88+__u64 inValue = 0;99+__u32 inPid = 0;1010+1111+struct {1212+ __uint(type, BPF_MAP_TYPE_PERCPU_HASH);1313+ __uint(max_entries, 2);1414+ __type(key, __u64);1515+ __type(value, __u64);1616+} hashmap1 SEC(".maps");1717+1818+1919+SEC("tp/syscalls/sys_enter_getpgid")2020+int sysenter_getpgid(const void *ctx)2121+{2222+ /* Just do it for once, when called from our own test prog. This2323+ * ensures the map value is only updated for a single CPU.2424+ */2525+ int cur_pid = bpf_get_current_pid_tgid() >> 32;2626+2727+ if (cur_pid == inPid)2828+ bpf_map_update_elem(&hashmap1, &inKey, &inValue, BPF_NOEXIST);2929+3030+ return 0;3131+}3232+3333+char _license[] SEC("license") = "GPL";
···145145 test_clone3_supported();146146147147 EXPECT_EQ(getuid(), 0)148148- XFAIL(return, "Skipping all tests as non-root\n");148148+ SKIP(return, "Skipping all tests as non-root");149149150150 memset(&set_tid, 0, sizeof(set_tid));151151
+4-4
tools/testing/selftests/core/close_range_test.c
···4444 fd = open("/dev/null", O_RDONLY | O_CLOEXEC);4545 ASSERT_GE(fd, 0) {4646 if (errno == ENOENT)4747- XFAIL(return, "Skipping test since /dev/null does not exist");4747+ SKIP(return, "Skipping test since /dev/null does not exist");4848 }49495050 open_fds[i] = fd;···52525353 EXPECT_EQ(-1, sys_close_range(open_fds[0], open_fds[100], -1)) {5454 if (errno == ENOSYS)5555- XFAIL(return, "close_range() syscall not supported");5555+ SKIP(return, "close_range() syscall not supported");5656 }57575858 EXPECT_EQ(0, sys_close_range(open_fds[0], open_fds[50], 0));···108108 fd = open("/dev/null", O_RDONLY | O_CLOEXEC);109109 ASSERT_GE(fd, 0) {110110 if (errno == ENOENT)111111- XFAIL(return, "Skipping test since /dev/null does not exist");111111+ SKIP(return, "Skipping test since /dev/null does not exist");112112 }113113114114 open_fds[i] = fd;···197197 fd = open("/dev/null", O_RDONLY | O_CLOEXEC);198198 ASSERT_GE(fd, 0) {199199 if (errno == ENOENT)200200- XFAIL(return, "Skipping test since /dev/null does not exist");200200+ SKIP(return, "Skipping test since /dev/null does not exist");201201 }202202203203 open_fds[i] = fd;
···7474 ret = mount(NULL, binderfs_mntpt, "binder", 0, 0);7575 EXPECT_EQ(ret, 0) {7676 if (errno == ENODEV)7777- XFAIL(goto out, "binderfs missing");7777+ SKIP(goto out, "binderfs missing");7878 TH_LOG("%s - Failed to mount binderfs", strerror(errno));7979 goto rmdir;8080 }···475475TEST(binderfs_test_privileged)476476{477477 if (geteuid() != 0)478478- XFAIL(return, "Tests are not run as root. Skipping privileged tests");478478+ SKIP(return, "Tests are not run as root. Skipping privileged tests");479479480480 if (__do_binderfs_test(_metadata))481481- XFAIL(return, "The Android binderfs filesystem is not available");481481+ SKIP(return, "The Android binderfs filesystem is not available");482482}483483484484TEST(binderfs_test_unprivileged)···511511 ret = wait_for_pid(pid);512512 if (ret) {513513 if (ret == 2)514514- XFAIL(return, "The Android binderfs filesystem is not available");514514+ SKIP(return, "The Android binderfs filesystem is not available");515515 ASSERT_EQ(ret, 0) {516516 TH_LOG("wait_for_pid() failed");517517 }
···133133 ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1134134}135135136136+# The fork function in the kernel was renamed from "_do_fork" to137137+# "kernel_fork". As older tests should still work with older kernels138138+# as well as newer kernels, check which version of fork is used on this139139+# kernel so that the tests can use the fork function for the running kernel.140140+FUNCTION_FORK=`(if grep '\bkernel_clone\b' /proc/kallsyms > /dev/null; then141141+ echo kernel_clone; else echo '_do_fork'; fi)`142142+136143# Since probe event command may include backslash, explicitly use printf "%s"137144# to NOT interpret it.138145ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
···330330 ksft_exit_fail_msg("%s test: Failed to recycle pid %d\n",331331 test_name, PID_RECYCLE);332332 case PIDFD_SKIP:333333- ksft_print_msg("%s test: Skipping test\n", test_name);333333+ ksft_test_result_skip("%s test: Skipping test\n", test_name);334334 ret = 0;335335 break;336336 case PIDFD_XFAIL:
-1
tools/testing/selftests/proc/proc-loadavg-001.c
···1414 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.1515 */1616/* Test that /proc/loadavg correctly reports last pid in pid namespace. */1717-#define _GNU_SOURCE1817#include <errno.h>1918#include <sched.h>2019#include <sys/types.h>
-1
tools/testing/selftests/proc/proc-self-syscall.c
···1313 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF1414 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.1515 */1616-#define _GNU_SOURCE1716#include <unistd.h>1817#include <sys/syscall.h>1918#include <sys/types.h>
-1
tools/testing/selftests/proc/proc-uptime-002.c
···1515 */1616// Test that values in /proc/uptime increment monotonically1717// while shifting across CPUs.1818-#define _GNU_SOURCE1918#undef NDEBUG2019#include <assert.h>2120#include <unistd.h>