···467467 instead falls back to using huge pages with lower orders or468468 small pages even though the allocation was successful.469469470470-anon_swpout470470+swpout471471 is incremented every time a huge page is swapped out in one472472 piece without splitting.473473474474-anon_swpout_fallback474474+swpout_fallback475475 is incremented if a huge page has to be split before swapout.476476 Usually because failed to allocate some continuous swap space477477 for the huge page.
+2-2
Documentation/cdrom/cdrom-standard.rst
···217217 int (*media_changed)(struct cdrom_device_info *, int);218218 int (*tray_move)(struct cdrom_device_info *, int);219219 int (*lock_door)(struct cdrom_device_info *, int);220220- int (*select_speed)(struct cdrom_device_info *, int);220220+ int (*select_speed)(struct cdrom_device_info *, unsigned long);221221 int (*get_last_session) (struct cdrom_device_info *,222222 struct cdrom_multisession *);223223 int (*get_mcn)(struct cdrom_device_info *, struct cdrom_mcn *);···396396397397::398398399399- int select_speed(struct cdrom_device_info *cdi, int speed)399399+ int select_speed(struct cdrom_device_info *cdi, unsigned long speed)400400401401Some CD-ROM drives are capable of changing their head-speed. There402402are several reasons for changing the speed of a CD-ROM drive. Badly
···18181919properties:2020 compatible:2121- enum:2222- - elan,ekth69152323- - ilitek,ili29012121+ oneOf:2222+ - items:2323+ - enum:2424+ - elan,ekth5015m2525+ - const: elan,ekth69152626+ - const: elan,ekth691524272528 reg:2629 const: 0x10···35323633 reset-gpios:3734 description: Reset GPIO; not all touchscreens using eKTH6915 hook this up.3535+3636+ no-reset-on-power-off:3737+ type: boolean3838+ description:3939+ Reset line is wired so that it can (and should) be left deasserted when4040+ the power supply is off.38413942 vcc33-supply:4043 description: The 3.3V supply to the touchscreen.···6758 #address-cells = <1>;6859 #size-cells = <0>;69607070- ap_ts: touchscreen@10 {7171- compatible = "elan,ekth6915";6161+ touchscreen@10 {6262+ compatible = "elan,ekth5015m", "elan,ekth6915";7263 reg = <0x10>;73647465 interrupt-parent = <&tlmm>;
···150150 That will limit the usefulness but on the other hand avoid151151 the illegal configurations all over.152152153153+ If "select" <symbol> is followed by "if" <expr>, <symbol> will be154154+ selected by the logical AND of the value of the current menu symbol155155+ and <expr>. This means, the lower limit can be downgraded due to the156156+ presence of "if" <expr>. This behavior may seem weird, but we rely on157157+ it. (The future of this behavior is undecided.)158158+153159- weak reverse dependencies: "imply" <symbol> ["if" <expr>]154160155161 This is similar to "select" as it enforces a lower limit on another···190184 ability to hook into a secondary subsystem while allowing the user to191185 configure that subsystem out without also having to unset these drivers.192186193193- Note: If the combination of FOO=y and BAR=m causes a link error,187187+ Note: If the combination of FOO=y and BAZ=m causes a link error,194188 you can guard the function call with IS_REACHABLE()::195189196190 foo_init()···207201 tristate "foo"208202 imply BAR209203 imply BAZ204204+205205+ Note: If "imply" <symbol> is followed by "if" <expr>, the default of <symbol>206206+ will be the logical AND of the value of the current menu symbol and <expr>.207207+ (The future of this behavior is undecided.)210208211209- limiting menu display: "visible if" <expr>212210
···582582Devices generating the streams may allow enabling and disabling some of the583583routes or have a fixed routing configuration. If the routes can be disabled, not584584declaring the routes (or declaring them without585585-``VIDIOC_SUBDEV_STREAM_FL_ACTIVE`` flag set) in ``VIDIOC_SUBDEV_S_ROUTING`` will585585+``V4L2_SUBDEV_STREAM_FL_ACTIVE`` flag set) in ``VIDIOC_SUBDEV_S_ROUTING`` will586586disable the routes. ``VIDIOC_SUBDEV_S_ROUTING`` will still return such routes587587back to the user in the routes array, with the ``V4L2_SUBDEV_STREAM_FL_ACTIVE``588588flag unset.
+1-1
MAINTAINERS
···1582515825F: tools/testing/selftests/nci/15826158261582715827NFS, SUNRPC, AND LOCKD CLIENTS1582815828-M: Trond Myklebust <trond.myklebust@hammerspace.com>1582815828+M: Trond Myklebust <trondmy@kernel.org>1582915829M: Anna Schumaker <anna@kernel.org>1583015830L: linux-nfs@vger.kernel.org1583115831S: Maintained
···232232 unsigned long old;233233234234 if (unlikely(atomic_read(¤t->tracing_graph_pause)))235235+err_out:235236 return;236237237238 if (IS_ENABLED(CONFIG_UNWINDER_FRAME_POINTER)) {238238- /* FP points one word below parent's top of stack */239239- frame_pointer += 4;239239+ /*240240+ * Usually, the stack frames are contiguous in memory but cases241241+ * have been observed where the next stack frame does not live242242+ * at 'frame_pointer + 4' as this code used to assume.243243+ *244244+ * Instead, dereference the field in the stack frame that245245+ * stores the SP of the calling frame: to avoid unbounded246246+ * recursion, this cannot involve any ftrace instrumented247247+ * functions, so use the __get_kernel_nofault() primitive248248+ * directly.249249+ */250250+ __get_kernel_nofault(&frame_pointer,251251+ (unsigned long *)(frame_pointer - 8),252252+ unsigned long, err_out);240253 } else {241254 struct stackframe frame = {242255 .fp = frame_pointer,
···462462 for (int i = 0; i < ARRAY_SIZE(insn_emulations); i++) {463463 struct insn_emulation *insn = insn_emulations[i];464464 bool enable = READ_ONCE(insn->current_mode) == INSN_HW;465465+ if (insn->status == INSN_UNAVAILABLE)466466+ continue;467467+465468 if (insn->set_hw_mode && insn->set_hw_mode(enable)) {466469 pr_warn("CPU[%u] cannot support the emulation of %s",467470 cpu, insn->name);
+2-2
arch/arm64/mm/contpte.c
···376376 * clearing access/dirty for the whole block.377377 */378378 unsigned long start = addr;379379- unsigned long end = start + nr;379379+ unsigned long end = start + nr * PAGE_SIZE;380380381381 if (pte_cont(__ptep_get(ptep + nr - 1)))382382 end = ALIGN(end, CONT_PTE_SIZE);···386386 ptep = contpte_align_down(ptep);387387 }388388389389- __clear_young_dirty_ptes(vma, start, ptep, end - start, flags);389389+ __clear_young_dirty_ptes(vma, start, ptep, (end - start) / PAGE_SIZE, flags);390390}391391EXPORT_SYMBOL_GPL(contpte_clear_young_dirty_ptes);392392
···250250 kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base;251251252252 /*253253- * memblock allocator is not aware of the fact that last 4K bytes of254254- * the addressable memory can not be mapped because of IS_ERR_VALUE255255- * macro. Make sure that last 4k bytes are not usable by memblock256256- * if end of dram is equal to maximum addressable memory. For 64-bit257257- * kernel, this problem can't happen here as the end of the virtual258258- * address space is occupied by the kernel mapping then this check must259259- * be done as soon as the kernel mapping base address is determined.253253+ * Reserve physical address space that would be mapped to virtual254254+ * addresses greater than (void *)(-PAGE_SIZE) because:255255+ * - This memory would overlap with ERR_PTR256256+ * - This memory belongs to high memory, which is not supported257257+ *258258+ * This is not applicable to 64-bit kernel, because virtual addresses259259+ * after (void *)(-PAGE_SIZE) are not linearly mapped: they are260260+ * occupied by kernel mapping. Also it is unrealistic for high memory261261+ * to exist on 64-bit platforms.260262 */261263 if (!IS_ENABLED(CONFIG_64BIT)) {262262- max_mapped_addr = __pa(~(ulong)0);263263- if (max_mapped_addr == (phys_ram_end - 1))264264- memblock_set_current_limit(max_mapped_addr - 4096);264264+ max_mapped_addr = __va_to_pa_nodebug(-PAGE_SIZE);265265+ memblock_reserve(max_mapped_addr, (phys_addr_t)-max_mapped_addr);265266 }266267267268 min_low_pfn = PFN_UP(phys_ram_base);
+30-24
arch/s390/kernel/crash_dump.c
···451451/*452452 * Initialize ELF header (new kernel)453453 */454454-static void *ehdr_init(Elf64_Ehdr *ehdr, int mem_chunk_cnt)454454+static void *ehdr_init(Elf64_Ehdr *ehdr, int phdr_count)455455{456456 memset(ehdr, 0, sizeof(*ehdr));457457 memcpy(ehdr->e_ident, ELFMAG, SELFMAG);···465465 ehdr->e_phoff = sizeof(Elf64_Ehdr);466466 ehdr->e_ehsize = sizeof(Elf64_Ehdr);467467 ehdr->e_phentsize = sizeof(Elf64_Phdr);468468- /*469469- * Number of memory chunk PT_LOAD program headers plus one kernel470470- * image PT_LOAD program header plus one PT_NOTE program header.471471- */472472- ehdr->e_phnum = mem_chunk_cnt + 1 + 1;468468+ /* Number of PT_LOAD program headers plus PT_NOTE program header */469469+ ehdr->e_phnum = phdr_count + 1;473470 return ehdr + 1;474471}475472···500503/*501504 * Initialize ELF loads (new kernel)502505 */503503-static void loads_init(Elf64_Phdr *phdr)506506+static void loads_init(Elf64_Phdr *phdr, bool os_info_has_vm)504507{505505- unsigned long old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);508508+ unsigned long old_identity_base = 0;506509 phys_addr_t start, end;507510 u64 idx;508511512512+ if (os_info_has_vm)513513+ old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);509514 for_each_physmem_range(idx, &oldmem_type, &start, &end) {510515 phdr->p_type = PT_LOAD;511516 phdr->p_vaddr = old_identity_base + start;···519520 phdr->p_align = PAGE_SIZE;520521 phdr++;521522 }523523+}524524+525525+static bool os_info_has_vm(void)526526+{527527+ return os_info_old_value(OS_INFO_KASLR_OFFSET);522528}523529524530/*···570566 return ptr;571567}572568573573-static size_t get_elfcorehdr_size(int mem_chunk_cnt)569569+static size_t get_elfcorehdr_size(int phdr_count)574570{575571 size_t size;576572···585581 size += nt_vmcoreinfo_size();586582 /* nt_final */587583 size += sizeof(Elf64_Nhdr);588588- /* PT_LOAD type program header for kernel text region */589589- size += sizeof(Elf64_Phdr);590584 /* PT_LOADS */591591- size += mem_chunk_cnt * sizeof(Elf64_Phdr);585585+ size += phdr_count * sizeof(Elf64_Phdr);592586593587 return size;594588}···597595int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)598596{599597 Elf64_Phdr *phdr_notes, *phdr_loads, *phdr_text;598598+ int mem_chunk_cnt, phdr_text_cnt;600599 size_t alloc_size;601601- int mem_chunk_cnt;602600 void *ptr, *hdr;603601 u64 hdr_off;604602···617615 }618616619617 mem_chunk_cnt = get_mem_chunk_cnt();618618+ phdr_text_cnt = os_info_has_vm() ? 1 : 0;620619621621- alloc_size = get_elfcorehdr_size(mem_chunk_cnt);620620+ alloc_size = get_elfcorehdr_size(mem_chunk_cnt + phdr_text_cnt);622621623622 hdr = kzalloc(alloc_size, GFP_KERNEL);624623625625- /* Without elfcorehdr /proc/vmcore cannot be created. Thus creating624624+ /*625625+ * Without elfcorehdr /proc/vmcore cannot be created. Thus creating626626 * a dump with this crash kernel will fail. Panic now to allow other627627 * dump mechanisms to take over.628628 */···632628 panic("s390 kdump allocating elfcorehdr failed");633629634630 /* Init elf header */635635- ptr = ehdr_init(hdr, mem_chunk_cnt);631631+ phdr_notes = ehdr_init(hdr, mem_chunk_cnt + phdr_text_cnt);636632 /* Init program headers */637637- phdr_notes = ptr;638638- ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr));639639- phdr_text = ptr;640640- ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr));641641- phdr_loads = ptr;642642- ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr) * mem_chunk_cnt);633633+ if (phdr_text_cnt) {634634+ phdr_text = phdr_notes + 1;635635+ phdr_loads = phdr_text + 1;636636+ } else {637637+ phdr_loads = phdr_notes + 1;638638+ }639639+ ptr = PTR_ADD(phdr_loads, sizeof(Elf64_Phdr) * mem_chunk_cnt);643640 /* Init notes */644641 hdr_off = PTR_DIFF(ptr, hdr);645642 ptr = notes_init(phdr_notes, ptr, ((unsigned long) hdr) + hdr_off);646643 /* Init kernel text program header */647647- text_init(phdr_text);644644+ if (phdr_text_cnt)645645+ text_init(phdr_text);648646 /* Init loads */649649- loads_init(phdr_loads);647647+ loads_init(phdr_loads, phdr_text_cnt);650648 /* Finalize program headers */651649 hdr_off = PTR_DIFF(ptr, hdr);652650 *addr = (unsigned long long) hdr;
···295295void machine_kexec(struct kimage *image)296296{297297 unsigned long page_list[PAGES_NR];298298- void *control_page;298298+ unsigned int host_mem_enc_active;299299 int save_ftrace_enabled;300300+ void *control_page;301301+302302+ /*303303+ * This must be done before load_segments() since if call depth tracking304304+ * is used then GS must be valid to make any function calls.305305+ */306306+ host_mem_enc_active = cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT);300307301308#ifdef CONFIG_KEXEC_JUMP302309 if (image->preserve_context)···365358 (unsigned long)page_list,366359 image->start,367360 image->preserve_context,368368- cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT));361361+ host_mem_enc_active);369362370363#ifdef CONFIG_KEXEC_JUMP371364 if (image->preserve_context)
+3-3
arch/x86/mm/numa.c
···493493 for_each_reserved_mem_region(mb_region) {494494 int nid = memblock_get_region_node(mb_region);495495496496- if (nid != MAX_NUMNODES)496496+ if (nid != NUMA_NO_NODE)497497 node_set(nid, reserved_nodemask);498498 }499499···614614 nodes_clear(node_online_map);615615 memset(&numa_meminfo, 0, sizeof(numa_meminfo));616616 WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory,617617- MAX_NUMNODES));617617+ NUMA_NO_NODE));618618 WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved,619619- MAX_NUMNODES));619619+ NUMA_NO_NODE));620620 /* In case that parsing SRAT failed. */621621 WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX));622622 numa_reset_distance();
+6-3
drivers/ata/pata_macio.c
···915915 .sg_tablesize = MAX_DCMDS,916916 /* We may not need that strict one */917917 .dma_boundary = ATA_DMA_BOUNDARY,918918- /* Not sure what the real max is but we know it's less than 64K, let's919919- * use 64K minus 256918918+ /*919919+ * The SCSI core requires the segment size to cover at least a page, so920920+ * for 64K page size kernels this must be at least 64K. However the921921+ * hardware can't handle 64K, so pata_macio_qc_prep() will split large922922+ * requests.920923 */921921- .max_segment_size = MAX_DBDMA_SEG,924924+ .max_segment_size = SZ_64K,922925 .device_configure = pata_macio_device_configure,923926 .sdev_groups = ata_common_sdev_groups,924927 .can_queue = ATA_DEF_QUEUE,
+2-2
drivers/block/null_blk/main.c
···18241824 dev->queue_mode = NULL_Q_MQ;18251825 }1826182618271827- dev->blocksize = round_down(dev->blocksize, 512);18281828- dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);18271827+ if (blk_validate_block_size(dev->blocksize))18281828+ return -EINVAL;1829182918301830 if (dev->use_per_node_hctx) {18311831 if (dev->submit_queues != nr_online_nodes)
+9-2
drivers/clk/clkdev.c
···204204 pr_err("%pV:%s: %s ID is greater than %zu\n",205205 &vaf, con_id, failure, max_size);206206 va_end(ap_copy);207207- kfree(cla);208208- return NULL;207207+208208+ /*209209+ * Don't fail in this case, but as the entry won't ever match just210210+ * fill it with something that also won't match.211211+ */212212+ strscpy(cla->con_id, "bad", sizeof(cla->con_id));213213+ strscpy(cla->dev_id, "bad", sizeof(cla->dev_id));214214+215215+ return &cla->cl;209216}210217211218static struct clk_lookup *
-8
drivers/clk/sifive/sifive-prci.c
···44 * Copyright (C) 2020 Zong Li55 */6677-#include <linux/clkdev.h>87#include <linux/delay.h>98#include <linux/io.h>109#include <linux/module.h>···532533 r = devm_clk_hw_register(dev, &pic->hw);533534 if (r) {534535 dev_warn(dev, "Failed to register clock %s: %d\n",535535- init.name, r);536536- return r;537537- }538538-539539- r = clk_hw_register_clkdev(&pic->hw, pic->name, dev_name(dev));540540- if (r) {541541- dev_warn(dev, "Failed to register clkdev for %s: %d\n",542536 init.name, r);543537 return r;544538 }
+5-3
drivers/edac/amd64_edac.c
···8181 amd64_warn("%s: error reading F%dx%03x.\n",8282 func, PCI_FUNC(pdev->devfn), offset);83838484- return err;8484+ return pcibios_err_to_errno(err);8585}86868787int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset,···9494 amd64_warn("%s: error writing to F%dx%03x.\n",9595 func, PCI_FUNC(pdev->devfn), offset);96969797- return err;9797+ return pcibios_err_to_errno(err);9898}9999100100/*···10251025 }1026102610271027 ret = pci_read_config_dword(pdev, REG_LOCAL_NODE_TYPE_MAP, &tmp);10281028- if (ret)10281028+ if (ret) {10291029+ ret = pcibios_err_to_errno(ret);10291030 goto out;10311031+ }1030103210311033 gpu_node_map.node_count = FIELD_GET(LNTM_NODE_COUNT, tmp);10321034 gpu_node_map.base_node_id = FIELD_GET(LNTM_BASE_NODE_ID, tmp);
···438438}439439module_exit(pcf857x_exit);440440441441+MODULE_DESCRIPTION("Driver for pcf857x, pca857x, and pca967x I2C GPIO expanders");441442MODULE_LICENSE("GPL");442443MODULE_AUTHOR("David Brownell");
+1
drivers/gpio/gpio-pl061.c
···438438};439439module_amba_driver(pl061_gpio_driver);440440441441+MODULE_DESCRIPTION("Driver for the ARM PrimeCell(tm) General Purpose Input/Output (PL061)");441442MODULE_LICENSE("GPL v2");
+80-30
drivers/gpio/gpio-tqmx86.c
···66 * Vadim V.Vlasov <vvlasov@dev.rtsoft.ru>77 */8899+#include <linux/bitmap.h>910#include <linux/bitops.h>1011#include <linux/errno.h>1112#include <linux/gpio/driver.h>···2928#define TQMX86_GPIIC 3 /* GPI Interrupt Configuration Register */3029#define TQMX86_GPIIS 4 /* GPI Interrupt Status Register */31303131+#define TQMX86_GPII_NONE 03232#define TQMX86_GPII_FALLING BIT(0)3333#define TQMX86_GPII_RISING BIT(1)3434+/* Stored in irq_type as a trigger type, but not actually valid as a register3535+ * value, so the name doesn't use "GPII"3636+ */3737+#define TQMX86_INT_BOTH (BIT(0) | BIT(1))3438#define TQMX86_GPII_MASK (BIT(0) | BIT(1))3539#define TQMX86_GPII_BITS 24040+/* Stored in irq_type with GPII bits */4141+#define TQMX86_INT_UNMASKED BIT(2)36423743struct tqmx86_gpio_data {3844 struct gpio_chip chip;3945 void __iomem *io_base;4046 int irq;4747+ /* Lock must be held for accessing output and irq_type fields */4148 raw_spinlock_t spinlock;4949+ DECLARE_BITMAP(output, TQMX86_NGPIO);4250 u8 irq_type[TQMX86_NGPI];4351};4452···7464{7565 struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);7666 unsigned long flags;7777- u8 val;78677968 raw_spin_lock_irqsave(&gpio->spinlock, flags);8080- val = tqmx86_gpio_read(gpio, TQMX86_GPIOD);8181- if (value)8282- val |= BIT(offset);8383- else8484- val &= ~BIT(offset);8585- tqmx86_gpio_write(gpio, val, TQMX86_GPIOD);6969+ __assign_bit(offset, gpio->output, value);7070+ tqmx86_gpio_write(gpio, bitmap_get_value8(gpio->output, 0), TQMX86_GPIOD);8671 raw_spin_unlock_irqrestore(&gpio->spinlock, flags);8772}8873···112107 return GPIO_LINE_DIRECTION_OUT;113108}114109110110+static void tqmx86_gpio_irq_config(struct tqmx86_gpio_data *gpio, int offset)111111+ __must_hold(&gpio->spinlock)112112+{113113+ u8 type = TQMX86_GPII_NONE, gpiic;114114+115115+ if (gpio->irq_type[offset] & TQMX86_INT_UNMASKED) {116116+ type = gpio->irq_type[offset] & TQMX86_GPII_MASK;117117+118118+ if (type == TQMX86_INT_BOTH)119119+ type = tqmx86_gpio_get(&gpio->chip, offset + TQMX86_NGPO)120120+ ? TQMX86_GPII_FALLING121121+ : TQMX86_GPII_RISING;122122+ }123123+124124+ gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);125125+ gpiic &= ~(TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS));126126+ gpiic |= type << (offset * TQMX86_GPII_BITS);127127+ tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);128128+}129129+115130static void tqmx86_gpio_irq_mask(struct irq_data *data)116131{117132 unsigned int offset = (data->hwirq - TQMX86_NGPO);118133 struct tqmx86_gpio_data *gpio = gpiochip_get_data(119134 irq_data_get_irq_chip_data(data));120135 unsigned long flags;121121- u8 gpiic, mask;122122-123123- mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS);124136125137 raw_spin_lock_irqsave(&gpio->spinlock, flags);126126- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);127127- gpiic &= ~mask;128128- tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);138138+ gpio->irq_type[offset] &= ~TQMX86_INT_UNMASKED;139139+ tqmx86_gpio_irq_config(gpio, offset);129140 raw_spin_unlock_irqrestore(&gpio->spinlock, flags);141141+130142 gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data));131143}132144···153131 struct tqmx86_gpio_data *gpio = gpiochip_get_data(154132 irq_data_get_irq_chip_data(data));155133 unsigned long flags;156156- u8 gpiic, mask;157157-158158- mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS);159134160135 gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data));136136+161137 raw_spin_lock_irqsave(&gpio->spinlock, flags);162162- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);163163- gpiic &= ~mask;164164- gpiic |= gpio->irq_type[offset] << (offset * TQMX86_GPII_BITS);165165- tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);138138+ gpio->irq_type[offset] |= TQMX86_INT_UNMASKED;139139+ tqmx86_gpio_irq_config(gpio, offset);166140 raw_spin_unlock_irqrestore(&gpio->spinlock, flags);167141}168142···169151 unsigned int offset = (data->hwirq - TQMX86_NGPO);170152 unsigned int edge_type = type & IRQF_TRIGGER_MASK;171153 unsigned long flags;172172- u8 new_type, gpiic;154154+ u8 new_type;173155174156 switch (edge_type) {175157 case IRQ_TYPE_EDGE_RISING:···179161 new_type = TQMX86_GPII_FALLING;180162 break;181163 case IRQ_TYPE_EDGE_BOTH:182182- new_type = TQMX86_GPII_FALLING | TQMX86_GPII_RISING;164164+ new_type = TQMX86_INT_BOTH;183165 break;184166 default:185167 return -EINVAL; /* not supported */186168 }187169188188- gpio->irq_type[offset] = new_type;189189-190170 raw_spin_lock_irqsave(&gpio->spinlock, flags);191191- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);192192- gpiic &= ~((TQMX86_GPII_MASK) << (offset * TQMX86_GPII_BITS));193193- gpiic |= new_type << (offset * TQMX86_GPII_BITS);194194- tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);171171+ gpio->irq_type[offset] &= ~TQMX86_GPII_MASK;172172+ gpio->irq_type[offset] |= new_type;173173+ tqmx86_gpio_irq_config(gpio, offset);195174 raw_spin_unlock_irqrestore(&gpio->spinlock, flags);196175197176 return 0;···199184 struct gpio_chip *chip = irq_desc_get_handler_data(desc);200185 struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);201186 struct irq_chip *irq_chip = irq_desc_get_chip(desc);202202- unsigned long irq_bits;203203- int i = 0;187187+ unsigned long irq_bits, flags;188188+ int i;204189 u8 irq_status;205190206191 chained_irq_enter(irq_chip, desc);···209194 tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS);210195211196 irq_bits = irq_status;197197+198198+ raw_spin_lock_irqsave(&gpio->spinlock, flags);199199+ for_each_set_bit(i, &irq_bits, TQMX86_NGPI) {200200+ /*201201+ * Edge-both triggers are implemented by flipping the edge202202+ * trigger after each interrupt, as the controller only supports203203+ * either rising or falling edge triggers, but not both.204204+ *205205+ * Internally, the TQMx86 GPIO controller has separate status206206+ * registers for rising and falling edge interrupts. GPIIC207207+ * configures which bits from which register are visible in the208208+ * interrupt status register GPIIS and defines what triggers the209209+ * parent IRQ line. Writing to GPIIS always clears both rising210210+ * and falling interrupt flags internally, regardless of the211211+ * currently configured trigger.212212+ *213213+ * In consequence, we can cleanly implement the edge-both214214+ * trigger in software by first clearing the interrupt and then215215+ * setting the new trigger based on the current GPIO input in216216+ * tqmx86_gpio_irq_config() - even if an edge arrives between217217+ * reading the input and setting the trigger, we will have a new218218+ * interrupt pending.219219+ */220220+ if ((gpio->irq_type[i] & TQMX86_GPII_MASK) == TQMX86_INT_BOTH)221221+ tqmx86_gpio_irq_config(gpio, i);222222+ }223223+ raw_spin_unlock_irqrestore(&gpio->spinlock, flags);224224+212225 for_each_set_bit(i, &irq_bits, TQMX86_NGPI)213226 generic_handle_domain_irq(gpio->chip.irq.domain,214227 i + TQMX86_NGPO);···319276 gpio->io_base = io_base;320277321278 tqmx86_gpio_write(gpio, (u8)~TQMX86_DIR_INPUT_MASK, TQMX86_GPIODD);279279+280280+ /*281281+ * Reading the previous output state is not possible with TQMx86 hardware.282282+ * Initialize all outputs to 0 to have a defined state that matches the283283+ * shadow register.284284+ */285285+ tqmx86_gpio_write(gpio, 0, TQMX86_GPIOD);322286323287 chip = &gpio->chip;324288 chip->label = "gpio-tqmx86";
+49-42
drivers/gpu/drm/amd/include/pptable.h
···477477} ATOM_PPLIB_STATE_V2;478478479479typedef struct _StateArray{480480- //how many states we have 481481- UCHAR ucNumEntries;482482-483483- ATOM_PPLIB_STATE_V2 states[1];480480+ //how many states we have481481+ UCHAR ucNumEntries;482482+483483+ ATOM_PPLIB_STATE_V2 states[] /* __counted_by(ucNumEntries) */;484484}StateArray;485485486486487487typedef struct _ClockInfoArray{488488- //how many clock levels we have489489- UCHAR ucNumEntries;490490-491491- //sizeof(ATOM_PPLIB_CLOCK_INFO)492492- UCHAR ucEntrySize;493493-494494- UCHAR clockInfo[];488488+ //how many clock levels we have489489+ UCHAR ucNumEntries;490490+491491+ //sizeof(ATOM_PPLIB_CLOCK_INFO)492492+ UCHAR ucEntrySize;493493+494494+ UCHAR clockInfo[];495495}ClockInfoArray;496496497497typedef struct _NonClockInfoArray{498498+ //how many non-clock levels we have. normally should be same as number of states499499+ UCHAR ucNumEntries;500500+ //sizeof(ATOM_PPLIB_NONCLOCK_INFO)501501+ UCHAR ucEntrySize;498502499499- //how many non-clock levels we have. normally should be same as number of states500500- UCHAR ucNumEntries;501501- //sizeof(ATOM_PPLIB_NONCLOCK_INFO)502502- UCHAR ucEntrySize;503503-504504- ATOM_PPLIB_NONCLOCK_INFO nonClockInfo[];503503+ ATOM_PPLIB_NONCLOCK_INFO nonClockInfo[] __counted_by(ucNumEntries);505504}NonClockInfoArray;506505507506typedef struct _ATOM_PPLIB_Clock_Voltage_Dependency_Record···512513513514typedef struct _ATOM_PPLIB_Clock_Voltage_Dependency_Table514515{515515- UCHAR ucNumEntries; // Number of entries.516516- ATOM_PPLIB_Clock_Voltage_Dependency_Record entries[1]; // Dynamically allocate entries.516516+ // Number of entries.517517+ UCHAR ucNumEntries;518518+ // Dynamically allocate entries.519519+ ATOM_PPLIB_Clock_Voltage_Dependency_Record entries[] __counted_by(ucNumEntries);517520}ATOM_PPLIB_Clock_Voltage_Dependency_Table;518521519522typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Record···530529531530typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Table532531{533533- UCHAR ucNumEntries; // Number of entries.534534- ATOM_PPLIB_Clock_Voltage_Limit_Record entries[1]; // Dynamically allocate entries.532532+ // Number of entries.533533+ UCHAR ucNumEntries;534534+ // Dynamically allocate entries.535535+ ATOM_PPLIB_Clock_Voltage_Limit_Record entries[] __counted_by(ucNumEntries);535536}ATOM_PPLIB_Clock_Voltage_Limit_Table;536537537538union _ATOM_PPLIB_CAC_Leakage_Record···556553557554typedef struct _ATOM_PPLIB_CAC_Leakage_Table558555{559559- UCHAR ucNumEntries; // Number of entries.560560- ATOM_PPLIB_CAC_Leakage_Record entries[1]; // Dynamically allocate entries.556556+ // Number of entries.557557+ UCHAR ucNumEntries;558558+ // Dynamically allocate entries.559559+ ATOM_PPLIB_CAC_Leakage_Record entries[] __counted_by(ucNumEntries);561560}ATOM_PPLIB_CAC_Leakage_Table;562561563562typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Record···573568574569typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Table575570{576576- UCHAR ucNumEntries; // Number of entries.577577- ATOM_PPLIB_PhaseSheddingLimits_Record entries[1]; // Dynamically allocate entries.571571+ // Number of entries.572572+ UCHAR ucNumEntries;573573+ // Dynamically allocate entries.574574+ ATOM_PPLIB_PhaseSheddingLimits_Record entries[] __counted_by(ucNumEntries);578575}ATOM_PPLIB_PhaseSheddingLimits_Table;579576580577typedef struct _VCEClockInfo{···587580}VCEClockInfo;588581589582typedef struct _VCEClockInfoArray{590590- UCHAR ucNumEntries;591591- VCEClockInfo entries[1];583583+ UCHAR ucNumEntries;584584+ VCEClockInfo entries[] __counted_by(ucNumEntries);592585}VCEClockInfoArray;593586594587typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record···599592600593typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table601594{602602- UCHAR numEntries;603603- ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record entries[1];595595+ UCHAR numEntries;596596+ ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record entries[] __counted_by(numEntries);604597}ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table;605598606599typedef struct _ATOM_PPLIB_VCE_State_Record···611604612605typedef struct _ATOM_PPLIB_VCE_State_Table613606{614614- UCHAR numEntries;615615- ATOM_PPLIB_VCE_State_Record entries[1];607607+ UCHAR numEntries;608608+ ATOM_PPLIB_VCE_State_Record entries[] __counted_by(numEntries);616609}ATOM_PPLIB_VCE_State_Table;617610618611···633626}UVDClockInfo;634627635628typedef struct _UVDClockInfoArray{636636- UCHAR ucNumEntries;637637- UVDClockInfo entries[1];629629+ UCHAR ucNumEntries;630630+ UVDClockInfo entries[] __counted_by(ucNumEntries);638631}UVDClockInfoArray;639632640633typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record···645638646639typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table647640{648648- UCHAR numEntries;649649- ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record entries[1];641641+ UCHAR numEntries;642642+ ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record entries[] __counted_by(numEntries);650643}ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table;651644652645typedef struct _ATOM_PPLIB_UVD_Table···664657}ATOM_PPLIB_SAMClk_Voltage_Limit_Record;665658666659typedef struct _ATOM_PPLIB_SAMClk_Voltage_Limit_Table{667667- UCHAR numEntries;668668- ATOM_PPLIB_SAMClk_Voltage_Limit_Record entries[];660660+ UCHAR numEntries;661661+ ATOM_PPLIB_SAMClk_Voltage_Limit_Record entries[] __counted_by(numEntries);669662}ATOM_PPLIB_SAMClk_Voltage_Limit_Table;670663671664typedef struct _ATOM_PPLIB_SAMU_Table···682675}ATOM_PPLIB_ACPClk_Voltage_Limit_Record;683676684677typedef struct _ATOM_PPLIB_ACPClk_Voltage_Limit_Table{685685- UCHAR numEntries;686686- ATOM_PPLIB_ACPClk_Voltage_Limit_Record entries[1];678678+ UCHAR numEntries;679679+ ATOM_PPLIB_ACPClk_Voltage_Limit_Record entries[] __counted_by(numEntries);687680}ATOM_PPLIB_ACPClk_Voltage_Limit_Table;688681689682typedef struct _ATOM_PPLIB_ACP_Table···750743} ATOM_PPLIB_VQ_Budgeting_Record;751744752745typedef struct ATOM_PPLIB_VQ_Budgeting_Table {753753- UCHAR revid;754754- UCHAR numEntries;755755- ATOM_PPLIB_VQ_Budgeting_Record entries[1];746746+ UCHAR revid;747747+ UCHAR numEntries;748748+ ATOM_PPLIB_VQ_Budgeting_Record entries[] __counted_by(numEntries);756749} ATOM_PPLIB_VQ_Budgeting_Table;757750758751#pragma pack()
···226226 struct amdgpu_device *adev = smu->adev;227227 int ret = 0;228228229229- if (!en && adev->in_s4) {230230- /* Adds a GFX reset as workaround just before sending the231231- * MP1_UNLOAD message to prevent GC/RLC/PMFW from entering232232- * an invalid state.233233- */234234- ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset,235235- SMU_RESET_MODE_2, NULL);236236- if (ret)237237- return ret;229229+ if (!en && !adev->in_s0ix) {230230+ if (adev->in_s4) {231231+ /* Adds a GFX reset as workaround just before sending the232232+ * MP1_UNLOAD message to prevent GC/RLC/PMFW from entering233233+ * an invalid state.234234+ */235235+ ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset,236236+ SMU_RESET_MODE_2, NULL);237237+ if (ret)238238+ return ret;239239+ }238240239241 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);240242 }
···643643 if (ret)644644 return dev_err_probe(dev, ret, "Failed to get backlight\n");645645646646- of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation);646646+ ret = of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation);647647+ if (ret)648648+ return dev_err_probe(&spi->dev, ret, "Failed to get orientation\n");647649648650 drm_panel_add(&ctx->panel);649651
+6-13
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
···746746 dev->vram_size = pci_resource_len(pdev, 2);747747748748 drm_info(&dev->drm,749749- "Register MMIO at 0x%pa size is %llu kiB\n",749749+ "Register MMIO at 0x%pa size is %llu KiB\n",750750 &rmmio_start, (uint64_t)rmmio_size / 1024);751751 dev->rmmio = devm_ioremap(dev->drm.dev,752752 rmmio_start,···765765 fifo_size = pci_resource_len(pdev, 2);766766767767 drm_info(&dev->drm,768768- "FIFO at %pa size is %llu kiB\n",768768+ "FIFO at %pa size is %llu KiB\n",769769 &fifo_start, (uint64_t)fifo_size / 1024);770770 dev->fifo_mem = devm_memremap(dev->drm.dev,771771 fifo_start,···790790 * SVGA_REG_VRAM_SIZE.791791 */792792 drm_info(&dev->drm,793793- "VRAM at %pa size is %llu kiB\n",793793+ "VRAM at %pa size is %llu KiB\n",794794 &dev->vram_start, (uint64_t)dev->vram_size / 1024);795795796796 return 0;···960960 vmw_read(dev_priv,961961 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB);962962963963- /*964964- * Workaround for low memory 2D VMs to compensate for the965965- * allocation taken by fbdev966966- */967967- if (!(dev_priv->capabilities & SVGA_CAP_3D))968968- mem_size *= 3;969969-970963 dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE;971964 dev_priv->max_primary_mem =972965 vmw_read(dev_priv, SVGA_REG_MAX_PRIMARY_MEM);···984991 dev_priv->max_primary_mem = dev_priv->vram_size;985992 }986993 drm_info(&dev_priv->drm,987987- "Legacy memory limits: VRAM = %llu kB, FIFO = %llu kB, surface = %u kB\n",994994+ "Legacy memory limits: VRAM = %llu KiB, FIFO = %llu KiB, surface = %u KiB\n",988995 (u64)dev_priv->vram_size / 1024,989996 (u64)dev_priv->fifo_mem_size / 1024,990997 dev_priv->memory_size / 1024);991998992999 drm_info(&dev_priv->drm,993993- "MOB limits: max mob size = %u kB, max mob pages = %u\n",10001000+ "MOB limits: max mob size = %u KiB, max mob pages = %u\n",9941001 dev_priv->max_mob_size / 1024, dev_priv->max_mob_pages);99510029961003 ret = vmw_dma_masks(dev_priv);···10081015 (unsigned)dev_priv->max_gmr_pages);10091016 }10101017 drm_info(&dev_priv->drm,10111011- "Maximum display memory size is %llu kiB\n",10181018+ "Maximum display memory size is %llu KiB\n",10121019 (uint64_t)dev_priv->max_primary_mem / 1024);1013102010141021 /* Need mmio memory to check for fifo pitchlock cap. */
···2727#include "usbhid/usbhid.h"2828#include "hid-ids.h"29293030+MODULE_DESCRIPTION("Support for Logitech devices relying on the HID++ specification");3031MODULE_LICENSE("GPL");3132MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");3233MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");
+4-2
drivers/hid/hid-nintendo.c
···27252725 ret = joycon_power_supply_create(ctlr);27262726 if (ret) {27272727 hid_err(hdev, "Failed to create power_supply; ret=%d\n", ret);27282728- goto err_close;27282728+ goto err_ida;27292729 }2730273027312731 ret = joycon_input_create(ctlr);27322732 if (ret) {27332733 hid_err(hdev, "Failed to create input device; ret=%d\n", ret);27342734- goto err_close;27342734+ goto err_ida;27352735 }2736273627372737 ctlr->ctlr_state = JOYCON_CTLR_STATE_READ;···27392739 hid_dbg(hdev, "probe - success\n");27402740 return 0;2741274127422742+err_ida:27432743+ ida_free(&nintendo_player_id_allocator, ctlr->player_id);27422744err_close:27432745 hid_hw_close(hdev);27442746err_stop:
+3-1
drivers/hid/hid-nvidia-shield.c
···283283 return haptics;284284285285 input_set_capability(haptics, EV_FF, FF_RUMBLE);286286- input_ff_create_memless(haptics, NULL, play_effect);286286+ ret = input_ff_create_memless(haptics, NULL, play_effect);287287+ if (ret)288288+ goto err;287289288290 ret = input_register_device(haptics);289291 if (ret)
+47-12
drivers/hid/i2c-hid/i2c-hid-of-elan.c
···3131 struct regulator *vcc33;3232 struct regulator *vccio;3333 struct gpio_desc *reset_gpio;3434+ bool no_reset_on_power_off;3435 const struct elan_i2c_hid_chip_data *chip_data;3536};3637···4140 container_of(ops, struct i2c_hid_of_elan, ops);4241 int ret;43424343+ gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);4444+4445 if (ihid_elan->vcc33) {4546 ret = regulator_enable(ihid_elan->vcc33);4647 if (ret)4747- return ret;4848+ goto err_deassert_reset;4849 }49505051 ret = regulator_enable(ihid_elan->vccio);5151- if (ret) {5252- regulator_disable(ihid_elan->vcc33);5353- return ret;5454- }5252+ if (ret)5353+ goto err_disable_vcc33;55545655 if (ihid_elan->chip_data->post_power_delay_ms)5756 msleep(ihid_elan->chip_data->post_power_delay_ms);···6160 msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);62616362 return 0;6363+6464+err_disable_vcc33:6565+ if (ihid_elan->vcc33)6666+ regulator_disable(ihid_elan->vcc33);6767+err_deassert_reset:6868+ if (ihid_elan->no_reset_on_power_off)6969+ gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);7070+7171+ return ret;6472}65736674static void elan_i2c_hid_power_down(struct i2chid_ops *ops)···7767 struct i2c_hid_of_elan *ihid_elan =7868 container_of(ops, struct i2c_hid_of_elan, ops);79698080- gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);7070+ /*7171+ * Do not assert reset when the hardware allows for it to remain7272+ * deasserted regardless of the state of the (shared) power supply to7373+ * avoid wasting power when the supply is left on.7474+ */7575+ if (!ihid_elan->no_reset_on_power_off)7676+ gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);7777+8178 if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)8279 msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);8380···9679static int i2c_hid_of_elan_probe(struct i2c_client *client)9780{9881 struct i2c_hid_of_elan *ihid_elan;8282+ int ret;998310084 ihid_elan = devm_kzalloc(&client->dev, sizeof(*ihid_elan), GFP_KERNEL);10185 if (!ihid_elan)···11193 if (IS_ERR(ihid_elan->reset_gpio))11294 return PTR_ERR(ihid_elan->reset_gpio);113959696+ ihid_elan->no_reset_on_power_off = of_property_read_bool(client->dev.of_node,9797+ "no-reset-on-power-off");9898+11499 ihid_elan->vccio = devm_regulator_get(&client->dev, "vccio");115115- if (IS_ERR(ihid_elan->vccio))116116- return PTR_ERR(ihid_elan->vccio);100100+ if (IS_ERR(ihid_elan->vccio)) {101101+ ret = PTR_ERR(ihid_elan->vccio);102102+ goto err_deassert_reset;103103+ }117104118105 ihid_elan->chip_data = device_get_match_data(&client->dev);119106120107 if (ihid_elan->chip_data->main_supply_name) {121108 ihid_elan->vcc33 = devm_regulator_get(&client->dev,122109 ihid_elan->chip_data->main_supply_name);123123- if (IS_ERR(ihid_elan->vcc33))124124- return PTR_ERR(ihid_elan->vcc33);110110+ if (IS_ERR(ihid_elan->vcc33)) {111111+ ret = PTR_ERR(ihid_elan->vcc33);112112+ goto err_deassert_reset;113113+ }125114 }126115127127- return i2c_hid_core_probe(client, &ihid_elan->ops,128128- ihid_elan->chip_data->hid_descriptor_address, 0);116116+ ret = i2c_hid_core_probe(client, &ihid_elan->ops,117117+ ihid_elan->chip_data->hid_descriptor_address, 0);118118+ if (ret)119119+ goto err_deassert_reset;120120+121121+ return 0;122122+123123+err_deassert_reset:124124+ if (ihid_elan->no_reset_on_power_off)125125+ gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);126126+127127+ return ret;129128}130129131130static const struct elan_i2c_hid_chip_data elan_ekth6915_chip_data = {
+44-35
drivers/hid/intel-ish-hid/ishtp/loader.c
···8484static int loader_xfer_cmd(struct ishtp_device *dev, void *req, int req_len,8585 void *resp, int resp_len)8686{8787- struct loader_msg_header *req_hdr = req;8888- struct loader_msg_header *resp_hdr = resp;8787+ union loader_msg_header req_hdr;8888+ union loader_msg_header resp_hdr;8989 struct device *devc = dev->devc;9090 int rv;9191···9393 dev->fw_loader_rx_size = resp_len;94949595 rv = loader_write_message(dev, req, req_len);9696+ req_hdr.val32 = le32_to_cpup(req);9797+9698 if (rv < 0) {9797- dev_err(devc, "write cmd %u failed:%d\n", req_hdr->command, rv);9999+ dev_err(devc, "write cmd %u failed:%d\n", req_hdr.command, rv);98100 return rv;99101 }100102101103 /* Wait the ACK */102104 wait_event_interruptible_timeout(dev->wait_loader_recvd_msg, dev->fw_loader_received,103105 ISHTP_LOADER_TIMEOUT);106106+ resp_hdr.val32 = le32_to_cpup(resp);104107 dev->fw_loader_rx_size = 0;105108 dev->fw_loader_rx_buf = NULL;106109 if (!dev->fw_loader_received) {107107- dev_err(devc, "wait response of cmd %u timeout\n", req_hdr->command);110110+ dev_err(devc, "wait response of cmd %u timeout\n", req_hdr.command);108111 return -ETIMEDOUT;109112 }110113111111- if (!resp_hdr->is_response) {112112- dev_err(devc, "not a response for %u\n", req_hdr->command);114114+ if (!resp_hdr.is_response) {115115+ dev_err(devc, "not a response for %u\n", req_hdr.command);113116 return -EBADMSG;114117 }115118116116- if (req_hdr->command != resp_hdr->command) {117117- dev_err(devc, "unexpected cmd response %u:%u\n", req_hdr->command,118118- resp_hdr->command);119119+ if (req_hdr.command != resp_hdr.command) {120120+ dev_err(devc, "unexpected cmd response %u:%u\n", req_hdr.command,121121+ resp_hdr.command);119122 return -EBADMSG;120123 }121124122122- if (resp_hdr->status) {123123- dev_err(devc, "cmd %u failed %u\n", req_hdr->command, resp_hdr->status);125125+ if (resp_hdr.status) {126126+ dev_err(devc, "cmd %u failed %u\n", req_hdr.command, resp_hdr.status);124127 return -EIO;125128 }126129···141138 struct loader_xfer_dma_fragment *fragment,142139 void **dma_bufs, u32 fragment_size)143140{141141+ dma_addr_t dma_addr;144142 int i;145143146144 for (i = 0; i < FRAGMENT_MAX_NUM; i++) {147145 if (dma_bufs[i]) {148148- dma_free_coherent(dev->devc, fragment_size, dma_bufs[i],149149- fragment->fragment_tbl[i].ddr_adrs);146146+ dma_addr = le64_to_cpu(fragment->fragment_tbl[i].ddr_adrs);147147+ dma_free_coherent(dev->devc, fragment_size, dma_bufs[i], dma_addr);150148 dma_bufs[i] = NULL;151149 }152150 }···160156 * @fragment: The ISHTP firmware fragment descriptor161157 * @dma_bufs: The array of DMA fragment buffers162158 * @fragment_size: The size of a single DMA fragment159159+ * @fragment_count: Number of fragments163160 *164161 * Return: 0 on success, negative error code on failure165162 */166163static int prepare_dma_bufs(struct ishtp_device *dev,167164 const struct firmware *ish_fw,168165 struct loader_xfer_dma_fragment *fragment,169169- void **dma_bufs, u32 fragment_size)166166+ void **dma_bufs, u32 fragment_size, u32 fragment_count)170167{168168+ dma_addr_t dma_addr;171169 u32 offset = 0;170170+ u32 length;172171 int i;173172174174- for (i = 0; i < fragment->fragment_cnt && offset < ish_fw->size; i++) {175175- dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size,176176- &fragment->fragment_tbl[i].ddr_adrs, GFP_KERNEL);173173+ for (i = 0; i < fragment_count && offset < ish_fw->size; i++) {174174+ dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);177175 if (!dma_bufs[i])178176 return -ENOMEM;179177180180- fragment->fragment_tbl[i].length = clamp(ish_fw->size - offset, 0, fragment_size);181181- fragment->fragment_tbl[i].fw_off = offset;182182- memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length);178178+ fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);179179+ length = clamp(ish_fw->size - offset, 0, fragment_size);180180+ fragment->fragment_tbl[i].length = cpu_to_le32(length);181181+ fragment->fragment_tbl[i].fw_off = cpu_to_le32(offset);182182+ memcpy(dma_bufs[i], ish_fw->data + offset, length);183183 clflush_cache_range(dma_bufs[i], fragment_size);184184185185- offset += fragment->fragment_tbl[i].length;185185+ offset += length;186186 }187187188188 return 0;···214206{215207 DEFINE_RAW_FLEX(struct loader_xfer_dma_fragment, fragment, fragment_tbl, FRAGMENT_MAX_NUM);216208 struct ishtp_device *dev = container_of(work, struct ishtp_device, work_fw_loader);217217- struct loader_xfer_query query = {218218- .header.command = LOADER_CMD_XFER_QUERY,219219- };220220- struct loader_start start = {221221- .header.command = LOADER_CMD_START,222222- };209209+ union loader_msg_header query_hdr = { .command = LOADER_CMD_XFER_QUERY, };210210+ union loader_msg_header start_hdr = { .command = LOADER_CMD_START, };211211+ union loader_msg_header fragment_hdr = { .command = LOADER_CMD_XFER_FRAGMENT, };212212+ struct loader_xfer_query query = { .header = cpu_to_le32(query_hdr.val32), };213213+ struct loader_start start = { .header = cpu_to_le32(start_hdr.val32), };223214 union loader_recv_message recv_msg;224215 char *filename = dev->driver_data->fw_filename;225216 const struct firmware *ish_fw;226217 void *dma_bufs[FRAGMENT_MAX_NUM] = {};227218 u32 fragment_size;219219+ u32 fragment_count;228220 int retry = ISHTP_LOADER_RETRY_TIMES;229221 int rv;230222···234226 return;235227 }236228237237- fragment->fragment.header.command = LOADER_CMD_XFER_FRAGMENT;238238- fragment->fragment.xfer_mode = LOADER_XFER_MODE_DMA;239239- fragment->fragment.is_last = 1;240240- fragment->fragment.size = ish_fw->size;229229+ fragment->fragment.header = cpu_to_le32(fragment_hdr.val32);230230+ fragment->fragment.xfer_mode = cpu_to_le32(LOADER_XFER_MODE_DMA);231231+ fragment->fragment.is_last = cpu_to_le32(1);232232+ fragment->fragment.size = cpu_to_le32(ish_fw->size);241233 /* Calculate the size of a single DMA fragment */242234 fragment_size = PFN_ALIGN(DIV_ROUND_UP(ish_fw->size, FRAGMENT_MAX_NUM));243235 /* Calculate the count of DMA fragments */244244- fragment->fragment_cnt = DIV_ROUND_UP(ish_fw->size, fragment_size);236236+ fragment_count = DIV_ROUND_UP(ish_fw->size, fragment_size);237237+ fragment->fragment_cnt = cpu_to_le32(fragment_count);245238246246- rv = prepare_dma_bufs(dev, ish_fw, fragment, dma_bufs, fragment_size);239239+ rv = prepare_dma_bufs(dev, ish_fw, fragment, dma_bufs, fragment_size, fragment_count);247240 if (rv) {248241 dev_err(dev->devc, "prepare DMA buffer failed.\n");249242 goto out;250243 }251244252245 do {253253- query.image_size = ish_fw->size;246246+ query.image_size = cpu_to_le32(ish_fw->size);254247 rv = loader_xfer_cmd(dev, &query, sizeof(query), recv_msg.raw_data,255248 sizeof(struct loader_xfer_query_ack));256249 if (rv)···264255 recv_msg.query_ack.version_build);265256266257 rv = loader_xfer_cmd(dev, fragment,267267- struct_size(fragment, fragment_tbl, fragment->fragment_cnt),258258+ struct_size(fragment, fragment_tbl, fragment_count),268259 recv_msg.raw_data, sizeof(struct loader_xfer_fragment_ack));269260 if (rv)270261 continue; /* try again if failed */
+18-13
drivers/hid/intel-ish-hid/ishtp/loader.h
···3030#define LOADER_XFER_MODE_DMA BIT(0)31313232/**3333- * struct loader_msg_header - ISHTP firmware loader message header3333+ * union loader_msg_header - ISHTP firmware loader message header3434 * @command: Command type3535 * @is_response: Indicates if the message is a response3636 * @has_next: Indicates if there is a next message3737 * @reserved: Reserved for future use3838 * @status: Status of the message3939+ * @val32: entire header as a 32-bit value3940 */4040-struct loader_msg_header {4141- __le32 command:7;4242- __le32 is_response:1;4343- __le32 has_next:1;4444- __le32 reserved:15;4545- __le32 status:8;4141+union loader_msg_header {4242+ struct {4343+ __u32 command:7;4444+ __u32 is_response:1;4545+ __u32 has_next:1;4646+ __u32 reserved:15;4747+ __u32 status:8;4848+ };4949+ __u32 val32;4650};47514852/**···5551 * @image_size: Size of the image5652 */5753struct loader_xfer_query {5858- struct loader_msg_header header;5454+ __le32 header;5955 __le32 image_size;6056};6157···107103 * @capability: Loader capability108104 */109105struct loader_xfer_query_ack {110110- struct loader_msg_header header;106106+ __le32 header;111107 __le16 version_major;112108 __le16 version_minor;113109 __le16 version_hotfix;···126122 * @is_last: Is last127123 */128124struct loader_xfer_fragment {129129- struct loader_msg_header header;125125+ __le32 header;130126 __le32 xfer_mode;131127 __le32 offset;132128 __le32 size;···138134 * @header: Header of the message139135 */140136struct loader_xfer_fragment_ack {141141- struct loader_msg_header header;137137+ __le32 header;142138};143139144140/**···174170 * @header: Header of the message175171 */176172struct loader_start {177177- struct loader_msg_header header;173173+ __le32 header;178174};179175180176/**···182178 * @header: Header of the message183179 */184180struct loader_start_ack {185185- struct loader_msg_header header;181181+ __le32 header;186182};187183188184union loader_recv_message {185185+ __le32 header;189186 struct loader_xfer_query_ack query_ack;190187 struct loader_xfer_fragment_ack fragment_ack;191188 struct loader_start_ack start_ack;
···20322032 struct protection_domain *domain)20332033{20342034 struct amd_iommu *iommu = get_amd_iommu_from_dev_data(dev_data);20352035- struct pci_dev *pdev;20362035 int ret = 0;2037203620382037 /* Update data structures */···20462047 domain->dev_iommu[iommu->index] += 1;20472048 domain->dev_cnt += 1;2048204920492049- pdev = dev_is_pci(dev_data->dev) ? to_pci_dev(dev_data->dev) : NULL;20502050+ /* Setup GCR3 table */20502051 if (pdom_is_sva_capable(domain)) {20512052 ret = init_gcr3_table(dev_data, domain);20522053 if (ret)20532054 return ret;20542054-20552055- if (pdev) {20562056- pdev_enable_caps(pdev);20572057-20582058- /*20592059- * Device can continue to function even if IOPF20602060- * enablement failed. Hence in error path just20612061- * disable device PRI support.20622062- */20632063- if (amd_iommu_iopf_add_device(iommu, dev_data))20642064- pdev_disable_cap_pri(pdev);20652065- }20662066- } else if (pdev) {20672067- pdev_enable_cap_ats(pdev);20682055 }20692069-20702070- /* Update device table */20712071- amd_iommu_dev_update_dte(dev_data, true);2072205620732057 return ret;20742058}···2145216321462164 do_detach(dev_data);2147216521662166+out:21672167+ spin_unlock(&dev_data->lock);21682168+21692169+ spin_unlock_irqrestore(&domain->lock, flags);21702170+21482171 /* Remove IOPF handler */21492172 if (ppr)21502173 amd_iommu_iopf_remove_device(iommu, dev_data);···21572170 if (dev_is_pci(dev))21582171 pdev_disable_caps(to_pci_dev(dev));2159217221602160-out:21612161- spin_unlock(&dev_data->lock);21622162-21632163- spin_unlock_irqrestore(&domain->lock, flags);21642173}2165217421662175static struct iommu_device *amd_iommu_probe_device(struct device *dev)···24682485 struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);24692486 struct protection_domain *domain = to_pdomain(dom);24702487 struct amd_iommu *iommu = get_amd_iommu_from_dev(dev);24882488+ struct pci_dev *pdev;24712489 int ret;2472249024732491 /*···25012517 }25022518#endif2503251925042504- iommu_completion_wait(iommu);25202520+ pdev = dev_is_pci(dev_data->dev) ? to_pci_dev(dev_data->dev) : NULL;25212521+ if (pdev && pdom_is_sva_capable(domain)) {25222522+ pdev_enable_caps(pdev);25232523+25242524+ /*25252525+ * Device can continue to function even if IOPF25262526+ * enablement failed. Hence in error path just25272527+ * disable device PRI support.25282528+ */25292529+ if (amd_iommu_iopf_add_device(iommu, dev_data))25302530+ pdev_disable_cap_pri(pdev);25312531+ } else if (pdev) {25322532+ pdev_enable_cap_ats(pdev);25332533+ }25342534+25352535+ /* Update device table */25362536+ amd_iommu_dev_update_dte(dev_data, true);2505253725062538 return ret;25072539}
+5-20
drivers/iommu/amd/ppr.c
···222222 if (iommu->iopf_queue)223223 return ret;224224225225- snprintf(iommu->iopfq_name, sizeof(iommu->iopfq_name),226226- "amdiommu-%#x-iopfq",225225+ snprintf(iommu->iopfq_name, sizeof(iommu->iopfq_name), "amdvi-%#x",227226 PCI_SEG_DEVID_TO_SBDF(iommu->pci_seg->id, iommu->devid));228227229228 iommu->iopf_queue = iopf_queue_alloc(iommu->iopfq_name);···248249int amd_iommu_iopf_add_device(struct amd_iommu *iommu,249250 struct iommu_dev_data *dev_data)250251{251251- unsigned long flags;252252 int ret = 0;253253254254 if (!dev_data->pri_enabled)255255 return ret;256256257257- raw_spin_lock_irqsave(&iommu->lock, flags);258258-259259- if (!iommu->iopf_queue) {260260- ret = -EINVAL;261261- goto out_unlock;262262- }257257+ if (!iommu->iopf_queue)258258+ return -EINVAL;263259264260 ret = iopf_queue_add_device(iommu->iopf_queue, dev_data->dev);265261 if (ret)266266- goto out_unlock;262262+ return ret;267263268264 dev_data->ppr = true;269269-270270-out_unlock:271271- raw_spin_unlock_irqrestore(&iommu->lock, flags);272272- return ret;265265+ return 0;273266}274267275268/* Its assumed that caller has verified that device was added to iopf queue */276269void amd_iommu_iopf_remove_device(struct amd_iommu *iommu,277270 struct iommu_dev_data *dev_data)278271{279279- unsigned long flags;280280-281281- raw_spin_lock_irqsave(&iommu->lock, flags);282282-283272 iopf_queue_remove_device(iommu->iopf_queue, dev_data->dev);284273 dev_data->ppr = false;285285-286286- raw_spin_unlock_irqrestore(&iommu->lock, flags);287274}
+4-4
drivers/iommu/dma-iommu.c
···686686687687 /* Check the domain allows at least some access to the device... */688688 if (map) {689689- dma_addr_t base = dma_range_map_min(map);690690- if (base > domain->geometry.aperture_end ||689689+ if (dma_range_map_min(map) > domain->geometry.aperture_end ||691690 dma_range_map_max(map) < domain->geometry.aperture_start) {692691 pr_warn("specified DMA range outside IOMMU capability\n");693692 return -EFAULT;694693 }695695- /* ...then finally give it a kicking to make sure it fits */696696- base_pfn = max(base, domain->geometry.aperture_start) >> order;697694 }695695+ /* ...then finally give it a kicking to make sure it fits */696696+ base_pfn = max_t(unsigned long, base_pfn,697697+ domain->geometry.aperture_start >> order);698698699699 /* start_pfn is always nonzero for an already-initialised domain */700700 mutex_lock(&cookie->mutex);
+12-32
drivers/irqchip/irq-gic-v3-its.c
···18461846{18471847 struct its_device *its_dev = irq_data_get_irq_chip_data(d);18481848 u32 event = its_get_event_id(d);18491849- int ret = 0;1850184918511850 if (!info->map)18521851 return -EINVAL;18531853-18541854- raw_spin_lock(&its_dev->event_map.vlpi_lock);1855185218561853 if (!its_dev->event_map.vm) {18571854 struct its_vlpi_map *maps;1858185518591856 maps = kcalloc(its_dev->event_map.nr_lpis, sizeof(*maps),18601857 GFP_ATOMIC);18611861- if (!maps) {18621862- ret = -ENOMEM;18631863- goto out;18641864- }18581858+ if (!maps)18591859+ return -ENOMEM;1865186018661861 its_dev->event_map.vm = info->map->vm;18671862 its_dev->event_map.vlpi_maps = maps;18681863 } else if (its_dev->event_map.vm != info->map->vm) {18691869- ret = -EINVAL;18701870- goto out;18641864+ return -EINVAL;18711865 }1872186618731867 /* Get our private copy of the mapping information */···18931899 its_dev->event_map.nr_vlpis++;18941900 }1895190118961896-out:18971897- raw_spin_unlock(&its_dev->event_map.vlpi_lock);18981898- return ret;19021902+ return 0;18991903}1900190419011905static int its_vlpi_get(struct irq_data *d, struct its_cmd_info *info)19021906{19031907 struct its_device *its_dev = irq_data_get_irq_chip_data(d);19041908 struct its_vlpi_map *map;19051905- int ret = 0;19061906-19071907- raw_spin_lock(&its_dev->event_map.vlpi_lock);1908190919091910 map = get_vlpi_map(d);1910191119111911- if (!its_dev->event_map.vm || !map) {19121912- ret = -EINVAL;19131913- goto out;19141914- }19121912+ if (!its_dev->event_map.vm || !map)19131913+ return -EINVAL;1915191419161915 /* Copy our mapping information to the incoming request */19171916 *info->map = *map;1918191719191919-out:19201920- raw_spin_unlock(&its_dev->event_map.vlpi_lock);19211921- return ret;19181918+ return 0;19221919}1923192019241921static int its_vlpi_unmap(struct irq_data *d)19251922{19261923 struct its_device *its_dev = irq_data_get_irq_chip_data(d);19271924 u32 event = its_get_event_id(d);19281928- int ret = 0;1929192519301930- raw_spin_lock(&its_dev->event_map.vlpi_lock);19311931-19321932- if (!its_dev->event_map.vm || !irqd_is_forwarded_to_vcpu(d)) {19331933- ret = -EINVAL;19341934- goto out;19351935- }19261926+ if (!its_dev->event_map.vm || !irqd_is_forwarded_to_vcpu(d))19271927+ return -EINVAL;1936192819371929 /* Drop the virtual mapping */19381930 its_send_discard(its_dev, event);···19421962 kfree(its_dev->event_map.vlpi_maps);19431963 }1944196419451945-out:19461946- raw_spin_unlock(&its_dev->event_map.vlpi_lock);19471947- return ret;19651965+ return 0;19481966}1949196719501968static int its_vlpi_prop_update(struct irq_data *d, struct its_cmd_info *info)···19691991 /* Need a v4 ITS */19701992 if (!is_v4(its_dev->its))19711993 return -EINVAL;19941994+19951995+ guard(raw_spinlock_irq)(&its_dev->event_map.vlpi_lock);1972199619731997 /* Unmap request? */19741998 if (!info)
···8585 struct plic_priv *priv;8686};8787static int plic_parent_irq __ro_after_init;8888-static bool plic_cpuhp_setup_done __ro_after_init;8888+static bool plic_global_setup_done __ro_after_init;8989static DEFINE_PER_CPU(struct plic_handler, plic_handlers);90909191static int plic_irq_set_type(struct irq_data *d, unsigned int type);···487487 unsigned long plic_quirks = 0;488488 struct plic_handler *handler;489489 u32 nr_irqs, parent_hwirq;490490- struct irq_domain *domain;491490 struct plic_priv *priv;492491 irq_hw_number_t hwirq;493493- bool cpuhp_setup;494492495493 if (is_of_node(dev->fwnode)) {496494 const struct of_device_id *id;···547549 continue;548550 }549551550550- /* Find parent domain and register chained handler */551551- domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY);552552- if (!plic_parent_irq && domain) {553553- plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT);554554- if (plic_parent_irq)555555- irq_set_chained_handler(plic_parent_irq, plic_handle_irq);556556- }557557-558552 /*559553 * When running in M-mode we need to ignore the S-mode handler.560554 * Here we assume it always comes later, but that might be a···587597 goto fail_cleanup_contexts;588598589599 /*590590- * We can have multiple PLIC instances so setup cpuhp state600600+ * We can have multiple PLIC instances so setup global state591601 * and register syscore operations only once after context592602 * handlers of all online CPUs are initialized.593603 */594594- if (!plic_cpuhp_setup_done) {595595- cpuhp_setup = true;604604+ if (!plic_global_setup_done) {605605+ struct irq_domain *domain;606606+ bool global_setup = true;607607+596608 for_each_online_cpu(cpu) {597609 handler = per_cpu_ptr(&plic_handlers, cpu);598610 if (!handler->present) {599599- cpuhp_setup = false;611611+ global_setup = false;600612 break;601613 }602614 }603603- if (cpuhp_setup) {615615+616616+ if (global_setup) {617617+ /* Find parent domain and register chained handler */618618+ domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY);619619+ if (domain)620620+ plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT);621621+ if (plic_parent_irq)622622+ irq_set_chained_handler(plic_parent_irq, plic_handle_irq);623623+604624 cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING,605625 "irqchip/sifive/plic:starting",606626 plic_starting_cpu, plic_dying_cpu);607627 register_syscore_ops(&plic_irq_syscore_ops);608608- plic_cpuhp_setup_done = true;628628+ plic_global_setup_done = true;609629 }610630 }611631
···70327032 device_set_wakeup_enable(&adapter->pdev->dev,70337033 adapter->flags & IGC_FLAG_WOL_SUPPORTED);7034703470357035+ igc_ptp_init(adapter);70367036+70357037 igc_tsn_clear_schedule(adapter);7036703870377039 /* reset the hardware with the new settings */···7054705270557053 /* Check if Media Autosense is enabled */70567054 adapter->ei = *ei;70577057-70587058- /* do hw tstamp init after resetting */70597059- igc_ptp_init(adapter);7060705570617056 /* print pcie link status and MAC address */70627057 pcie_print_link_status(pdev);
+1-2
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
···4895489548964896 /* Verify if UDP port is being offloaded by HW */48974897 if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))48984898- return features;48984898+ return vxlan_features_check(skb, features);4899489949004900#if IS_ENABLED(CONFIG_GENEVE)49014901 /* Support Geneve offload for default UDP port */···49214921 struct mlx5e_priv *priv = netdev_priv(netdev);4922492249234923 features = vlan_features_check(skb, features);49244924- features = vxlan_features_check(skb, features);4925492449264925 /* Validate if the tunneled packet is being offloaded by HW */49274926 if (skb->encapsulation &&
+1-3
drivers/net/ethernet/pensando/ionic/ionic_lif.c
···304304 if (ret)305305 return ret;306306307307- if (qcq->napi.poll)308308- napi_enable(&qcq->napi);309309-310307 if (qcq->flags & IONIC_QCQ_F_INTR) {308308+ napi_enable(&qcq->napi);311309 irq_set_affinity_hint(qcq->intr.vector,312310 &qcq->intr.affinity_mask);313311 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
···136136config YT2_1380137137 tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"138138 depends on SERIAL_DEV_BUS139139+ depends on EXTCON139140 depends on ACPI140141 help141142 Say Y here to enable support for the custom fast charging protocol
+43-7
drivers/platform/x86/amd/hsmp.c
···907907 return ret;908908}909909910910+/*911911+ * This check is only needed for backward compatibility of previous platforms.912912+ * All new platforms are expected to support ACPI based probing.913913+ */914914+static bool legacy_hsmp_support(void)915915+{916916+ if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)917917+ return false;918918+919919+ switch (boot_cpu_data.x86) {920920+ case 0x19:921921+ switch (boot_cpu_data.x86_model) {922922+ case 0x00 ... 0x1F:923923+ case 0x30 ... 0x3F:924924+ case 0x90 ... 0x9F:925925+ case 0xA0 ... 0xAF:926926+ return true;927927+ default:928928+ return false;929929+ }930930+ case 0x1A:931931+ switch (boot_cpu_data.x86_model) {932932+ case 0x00 ... 0x1F:933933+ return true;934934+ default:935935+ return false;936936+ }937937+ default:938938+ return false;939939+ }940940+941941+ return false;942942+}943943+910944static int __init hsmp_plt_init(void)911945{912946 int ret = -ENODEV;913913-914914- if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD || boot_cpu_data.x86 < 0x19) {915915- pr_err("HSMP is not supported on Family:%x model:%x\n",916916- boot_cpu_data.x86, boot_cpu_data.x86_model);917917- return ret;918918- }919947920948 /*921949 * amd_nb_num() returns number of SMN/DF interfaces present in the system···958930 return ret;959931960932 if (!plat_dev.is_acpi_device) {961961- ret = hsmp_plat_dev_register();933933+ if (legacy_hsmp_support()) {934934+ /* Not ACPI device, but supports HSMP, register a plat_dev */935935+ ret = hsmp_plat_dev_register();936936+ } else {937937+ /* Not ACPI, Does not support HSMP */938938+ pr_info("HSMP is not supported on Family:%x model:%x\n",939939+ boot_cpu_data.x86, boot_cpu_data.x86_model);940940+ ret = -ENODEV;941941+ }962942 if (ret)963943 platform_driver_unregister(&amd_hsmp_driver);964944 }
+39-62
drivers/platform/x86/dell/dell-smbios-base.c
···1111 */1212#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt13131414+#include <linux/container_of.h>1415#include <linux/kernel.h>1516#include <linux/module.h>1617#include <linux/capability.h>···2625static int da_num_tokens;2726static struct platform_device *platform_device;2827static struct calling_interface_token *da_tokens;2929-static struct device_attribute *token_location_attrs;3030-static struct device_attribute *token_value_attrs;2828+static struct token_sysfs_data *token_entries;3129static struct attribute **token_attrs;3230static DEFINE_MUTEX(smbios_mutex);3131+3232+struct token_sysfs_data {3333+ struct device_attribute location_attr;3434+ struct device_attribute value_attr;3535+ struct calling_interface_token *token;3636+};33373438struct smbios_device {3539 struct list_head list;···422416 }423417}424418425425-static int match_attribute(struct device *dev,426426- struct device_attribute *attr)427427-{428428- int i;429429-430430- for (i = 0; i < da_num_tokens * 2; i++) {431431- if (!token_attrs[i])432432- continue;433433- if (strcmp(token_attrs[i]->name, attr->attr.name) == 0)434434- return i/2;435435- }436436- dev_dbg(dev, "couldn't match: %s\n", attr->attr.name);437437- return -EINVAL;438438-}439439-440419static ssize_t location_show(struct device *dev,441420 struct device_attribute *attr, char *buf)442421{443443- int i;422422+ struct token_sysfs_data *data = container_of(attr, struct token_sysfs_data, location_attr);444423445424 if (!capable(CAP_SYS_ADMIN))446425 return -EPERM;447426448448- i = match_attribute(dev, attr);449449- if (i > 0)450450- return sysfs_emit(buf, "%08x", da_tokens[i].location);451451- return 0;427427+ return sysfs_emit(buf, "%08x", data->token->location);452428}453429454430static ssize_t value_show(struct device *dev,455431 struct device_attribute *attr, char *buf)456432{457457- int i;433433+ struct token_sysfs_data *data = container_of(attr, struct token_sysfs_data, value_attr);458434459435 if (!capable(CAP_SYS_ADMIN))460436 return -EPERM;461437462462- i = match_attribute(dev, attr);463463- if (i > 0)464464- return sysfs_emit(buf, "%08x", da_tokens[i].value);465465- return 0;438438+ return sysfs_emit(buf, "%08x", data->token->value);466439}467440468441static struct attribute_group smbios_attribute_group = {···458473{459474 char *location_name;460475 char *value_name;461461- size_t size;462476 int ret;463477 int i, j;464478465465- /* (number of tokens + 1 for null terminated */466466- size = sizeof(struct device_attribute) * (da_num_tokens + 1);467467- token_location_attrs = kzalloc(size, GFP_KERNEL);468468- if (!token_location_attrs)479479+ token_entries = kcalloc(da_num_tokens, sizeof(*token_entries), GFP_KERNEL);480480+ if (!token_entries)469481 return -ENOMEM;470470- token_value_attrs = kzalloc(size, GFP_KERNEL);471471- if (!token_value_attrs)472472- goto out_allocate_value;473482474483 /* need to store both location and value + terminator*/475475- size = sizeof(struct attribute *) * ((2 * da_num_tokens) + 1);476476- token_attrs = kzalloc(size, GFP_KERNEL);484484+ token_attrs = kcalloc((2 * da_num_tokens) + 1, sizeof(*token_attrs), GFP_KERNEL);477485 if (!token_attrs)478486 goto out_allocate_attrs;479487···474496 /* skip empty */475497 if (da_tokens[i].tokenID == 0)476498 continue;499499+500500+ token_entries[i].token = &da_tokens[i];501501+477502 /* add location */478503 location_name = kasprintf(GFP_KERNEL, "%04x_location",479504 da_tokens[i].tokenID);480505 if (location_name == NULL)481506 goto out_unwind_strings;482482- sysfs_attr_init(&token_location_attrs[i].attr);483483- token_location_attrs[i].attr.name = location_name;484484- token_location_attrs[i].attr.mode = 0444;485485- token_location_attrs[i].show = location_show;486486- token_attrs[j++] = &token_location_attrs[i].attr;507507+508508+ sysfs_attr_init(&token_entries[i].location_attr.attr);509509+ token_entries[i].location_attr.attr.name = location_name;510510+ token_entries[i].location_attr.attr.mode = 0444;511511+ token_entries[i].location_attr.show = location_show;512512+ token_attrs[j++] = &token_entries[i].location_attr.attr;487513488514 /* add value */489515 value_name = kasprintf(GFP_KERNEL, "%04x_value",490516 da_tokens[i].tokenID);491491- if (value_name == NULL)492492- goto loop_fail_create_value;493493- sysfs_attr_init(&token_value_attrs[i].attr);494494- token_value_attrs[i].attr.name = value_name;495495- token_value_attrs[i].attr.mode = 0444;496496- token_value_attrs[i].show = value_show;497497- token_attrs[j++] = &token_value_attrs[i].attr;498498- continue;517517+ if (!value_name) {518518+ kfree(location_name);519519+ goto out_unwind_strings;520520+ }499521500500-loop_fail_create_value:501501- kfree(location_name);502502- goto out_unwind_strings;522522+ sysfs_attr_init(&token_entries[i].value_attr.attr);523523+ token_entries[i].value_attr.attr.name = value_name;524524+ token_entries[i].value_attr.attr.mode = 0444;525525+ token_entries[i].value_attr.show = value_show;526526+ token_attrs[j++] = &token_entries[i].value_attr.attr;503527 }504528 smbios_attribute_group.attrs = token_attrs;505529···512532513533out_unwind_strings:514534 while (i--) {515515- kfree(token_location_attrs[i].attr.name);516516- kfree(token_value_attrs[i].attr.name);535535+ kfree(token_entries[i].location_attr.attr.name);536536+ kfree(token_entries[i].value_attr.attr.name);517537 }518538 kfree(token_attrs);519539out_allocate_attrs:520520- kfree(token_value_attrs);521521-out_allocate_value:522522- kfree(token_location_attrs);540540+ kfree(token_entries);523541524542 return -ENOMEM;525543}···529551 sysfs_remove_group(&pdev->dev.kobj,530552 &smbios_attribute_group);531553 for (i = 0; i < da_num_tokens; i++) {532532- kfree(token_location_attrs[i].attr.name);533533- kfree(token_value_attrs[i].attr.name);554554+ kfree(token_entries[i].location_attr.attr.name);555555+ kfree(token_entries[i].value_attr.attr.name);534556 }535557 kfree(token_attrs);536536- kfree(token_value_attrs);537537- kfree(token_location_attrs);558558+ kfree(token_entries);538559}539560540561static int __init dell_smbios_init(void)
···414414 }415415}416416417417-static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,418418- struct scsi_sense_hdr *sense_hdr)417417+static void alua_handle_state_transition(struct scsi_device *sdev)419418{420419 struct alua_dh_data *h = sdev->handler_data;421420 struct alua_port_group *pg;422421422422+ rcu_read_lock();423423+ pg = rcu_dereference(h->pg);424424+ if (pg)425425+ pg->state = SCSI_ACCESS_STATE_TRANSITIONING;426426+ rcu_read_unlock();427427+ alua_check(sdev, false);428428+}429429+430430+static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,431431+ struct scsi_sense_hdr *sense_hdr)432432+{423433 switch (sense_hdr->sense_key) {424434 case NOT_READY:425435 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {426436 /*427437 * LUN Not Accessible - ALUA state transition428438 */429429- rcu_read_lock();430430- pg = rcu_dereference(h->pg);431431- if (pg)432432- pg->state = SCSI_ACCESS_STATE_TRANSITIONING;433433- rcu_read_unlock();434434- alua_check(sdev, false);439439+ alua_handle_state_transition(sdev);435440 return NEEDS_RETRY;436441 }437442 break;438443 case UNIT_ATTENTION:444444+ if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {445445+ /*446446+ * LUN Not Accessible - ALUA state transition447447+ */448448+ alua_handle_state_transition(sdev);449449+ return NEEDS_RETRY;450450+ }439451 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) {440452 /*441453 * Power On, Reset, or Bus Device Reset.···514502515503 retval = scsi_test_unit_ready(sdev, ALUA_FAILOVER_TIMEOUT * HZ,516504 ALUA_FAILOVER_RETRIES, &sense_hdr);517517- if (sense_hdr.sense_key == NOT_READY &&505505+ if ((sense_hdr.sense_key == NOT_READY ||506506+ sense_hdr.sense_key == UNIT_ATTENTION) &&518507 sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)519508 return SCSI_DH_RETRY;520509 else if (retval)
+1-1
drivers/scsi/mpi3mr/mpi3mr_transport.c
···13641364 continue;1365136513661366 if (i > sizeof(mr_sas_port->phy_mask) * 8) {13671367- ioc_warn(mrioc, "skipping port %u, max allowed value is %lu\n",13671367+ ioc_warn(mrioc, "skipping port %u, max allowed value is %zu\n",13681368 i, sizeof(mr_sas_port->phy_mask) * 8);13691369 goto out_fail;13701370 }
+2-2
drivers/scsi/mpt3sas/mpt3sas_scsih.c
···302302303303/**304304 * _scsih_set_debug_level - global setting of ioc->logging_level.305305- * @val: ?306306- * @kp: ?305305+ * @val: value of the parameter to be set306306+ * @kp: pointer to kernel_param structure307307 *308308 * Note: The logging levels are defined in mpt3sas_debug.h.309309 */
+1
drivers/scsi/qedf/qedf.h
···363363#define QEDF_IN_RECOVERY 5364364#define QEDF_DBG_STOP_IO 6365365#define QEDF_PROBING 8366366+#define QEDF_STAG_IN_PROGRESS 9366367 unsigned long flags; /* Miscellaneous state flags */367368 int fipvlan_retries;368369 u8 num_queues;
+44-3
drivers/scsi/qedf/qedf_main.c
···318318 */319319 if (resp == fc_lport_flogi_resp) {320320 qedf->flogi_cnt++;321321+ qedf->flogi_pending++;322322+323323+ if (test_bit(QEDF_UNLOADING, &qedf->flags)) {324324+ QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");325325+ qedf->flogi_pending = 0;326326+ }327327+321328 if (qedf->flogi_pending >= QEDF_FLOGI_RETRY_CNT) {322329 schedule_delayed_work(&qedf->stag_work, 2);323330 return NULL;324331 }325325- qedf->flogi_pending++;332332+326333 return fc_elsct_send(lport, did, fp, op, qedf_flogi_resp,327334 arg, timeout);328335 }···919912 struct qedf_ctx *qedf;920913 struct qed_link_output if_link;921914915915+ qedf = lport_priv(lport);916916+922917 if (lport->vport) {918918+ clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);923919 printk_ratelimited("Cannot issue host reset on NPIV port.\n");924920 return;925921 }926926-927927- qedf = lport_priv(lport);928922929923 qedf->flogi_pending = 0;930924 /* For host reset, essentially do a soft link up/down */···946938 if (!if_link.link_up) {947939 QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,948940 "Physical link is not up.\n");941941+ clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);949942 return;950943 }951944 /* Flush and wait to make sure link down is processed */···959950 "Queue link up work.\n");960951 queue_delayed_work(qedf->link_update_wq, &qedf->link_update,961952 0);953953+ clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);962954}963955964956/* Reset the host by gracefully logging out and then logging back in */···34733463 }3474346434753465 /* Start the Slowpath-process */34663466+ memset(&slowpath_params, 0, sizeof(struct qed_slowpath_params));34763467 slowpath_params.int_mode = QED_INT_MODE_MSIX;34773468 slowpath_params.drv_major = QEDF_DRIVER_MAJOR_VER;34783469 slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;···37323721{37333722 struct qedf_ctx *qedf;37343723 int rc;37243724+ int cnt = 0;3735372537363726 if (!pdev) {37373727 QEDF_ERR(NULL, "pdev is NULL.\n");···37483736 if (test_bit(QEDF_UNLOADING, &qedf->flags)) {37493737 QEDF_ERR(&qedf->dbg_ctx, "Already removing PCI function.\n");37503738 return;37393739+ }37403740+37413741+stag_in_prog:37423742+ if (test_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags)) {37433743+ QEDF_ERR(&qedf->dbg_ctx, "Stag in progress, cnt=%d.\n", cnt);37443744+ cnt++;37453745+37463746+ if (cnt < 5) {37473747+ msleep(500);37483748+ goto stag_in_prog;37493749+ }37513750 }3752375137533752 if (mode != QEDF_MODE_RECOVERY)···40193996{40203997 struct qedf_ctx *qedf =40213998 container_of(work, struct qedf_ctx, stag_work.work);39993999+40004000+ if (!qedf) {40014001+ QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");40024002+ return;40034003+ }40044004+40054005+ if (test_bit(QEDF_IN_RECOVERY, &qedf->flags)) {40064006+ QEDF_ERR(&qedf->dbg_ctx,40074007+ "Already is in recovery, hence not calling software context reset.\n");40084008+ return;40094009+ }40104010+40114011+ if (test_bit(QEDF_UNLOADING, &qedf->flags)) {40124012+ QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");40134013+ return;40144014+ }40154015+40164016+ set_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);4022401740234018 printk_ratelimited("[%s]:[%s:%d]:%d: Performing software context reset.",40244019 dev_name(&qedf->pdev->dev), __func__, __LINE__,
+7
drivers/scsi/scsi.c
···350350 if (result < SCSI_VPD_HEADER_SIZE)351351 return 0;352352353353+ if (result > sizeof(vpd)) {354354+ dev_warn_once(&sdev->sdev_gendev,355355+ "%s: long VPD page 0 length: %d bytes\n",356356+ __func__, result);357357+ result = sizeof(vpd);358358+ }359359+353360 result -= SCSI_VPD_HEADER_SIZE;354361 if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))355362 return 0;
···221221 struct btree_path *path)222222{223223 struct bch_fs *c = trans->c;224224- unsigned i;225224226226- EBUG_ON(path->btree_id >= BTREE_ID_NR);227227-228228- for (i = 0; i < (!path->cached ? BTREE_MAX_DEPTH : 1); i++) {225225+ for (unsigned i = 0; i < (!path->cached ? BTREE_MAX_DEPTH : 1); i++) {229226 if (!path->l[i].b) {230227 BUG_ON(!path->cached &&231228 bch2_btree_id_root(c, path->btree_id)->b->c.level > i);···247250static void bch2_btree_iter_verify(struct btree_iter *iter)248251{249252 struct btree_trans *trans = iter->trans;250250-251251- BUG_ON(iter->btree_id >= BTREE_ID_NR);252253253254 BUG_ON(!!(iter->flags & BTREE_ITER_cached) != btree_iter_path(trans, iter)->cached);254255···34013406 bch2_time_stats_exit(&s->lock_hold_times);34023407 }3403340834043404- if (c->btree_trans_barrier_initialized)34093409+ if (c->btree_trans_barrier_initialized) {34103410+ synchronize_srcu_expedited(&c->btree_trans_barrier);34053411 cleanup_srcu_struct(&c->btree_trans_barrier);34123412+ }34063413 mempool_exit(&c->btree_trans_mem_pool);34073414 mempool_exit(&c->btree_trans_pool);34083415}
+20-13
fs/bcachefs/btree_key_cache.c
···3232}33333434static const struct rhashtable_params bch2_btree_key_cache_params = {3535- .head_offset = offsetof(struct bkey_cached, hash),3636- .key_offset = offsetof(struct bkey_cached, key),3737- .key_len = sizeof(struct bkey_cached_key),3838- .obj_cmpfn = bch2_btree_key_cache_cmp_fn,3535+ .head_offset = offsetof(struct bkey_cached, hash),3636+ .key_offset = offsetof(struct bkey_cached, key),3737+ .key_len = sizeof(struct bkey_cached_key),3838+ .obj_cmpfn = bch2_btree_key_cache_cmp_fn,3939+ .automatic_shrinking = true,3940};40414142__flatten···841840 six_lock_exit(&ck->c.lock);842841 kmem_cache_free(bch2_key_cache, ck);843842 atomic_long_dec(&bc->nr_freed);844844- freed++;845843 bc->nr_freed_nonpcpu--;846844 bc->freed++;847845 }···854854 six_lock_exit(&ck->c.lock);855855 kmem_cache_free(bch2_key_cache, ck);856856 atomic_long_dec(&bc->nr_freed);857857- freed++;858857 bc->nr_freed_pcpu--;859858 bc->freed++;860859 }···875876876877 if (test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {877878 bc->skipped_dirty++;878878- goto next;879879 } else if (test_bit(BKEY_CACHED_ACCESSED, &ck->flags)) {880880 clear_bit(BKEY_CACHED_ACCESSED, &ck->flags);881881 bc->skipped_accessed++;882882- goto next;883883- } else if (bkey_cached_lock_for_evict(ck)) {882882+ } else if (!bkey_cached_lock_for_evict(ck)) {883883+ bc->skipped_lock_fail++;884884+ } else {884885 bkey_cached_evict(bc, ck);885886 bkey_cached_free(bc, ck);886887 bc->moved_to_freelist++;887887- } else {888888- bc->skipped_lock_fail++;888888+ freed++;889889 }890890891891 scanned++;892892 if (scanned >= nr)893893 break;894894-next:894894+895895 pos = next;896896 }897897···914916 struct btree_key_cache *bc = &c->btree_key_cache;915917 long nr = atomic_long_read(&bc->nr_keys) -916918 atomic_long_read(&bc->nr_dirty);919919+920920+ /*921921+ * Avoid hammering our shrinker too much if it's nearly empty - the922922+ * shrinker code doesn't take into account how big our cache is, if it's923923+ * mostly empty but the system is under memory pressure it causes nasty924924+ * lock contention:925925+ */926926+ nr -= 128;917927918928 return max(0L, nr);919929}···10311025 if (!shrink)10321026 return -BCH_ERR_ENOMEM_fs_btree_cache_init;10331027 bc->shrink = shrink;10341034- shrink->seeks = 0;10351028 shrink->count_objects = bch2_btree_key_cache_count;10361029 shrink->scan_objects = bch2_btree_key_cache_scan;10301030+ shrink->batch = 1 << 14;10311031+ shrink->seeks = 0;10371032 shrink->private_data = c;10381033 shrinker_register(shrink);10391034 return 0;
+5-4
fs/bcachefs/btree_node_scan.c
···72727373 struct btree *b = bch2_btree_node_get_noiter(trans, &k.k, f->btree_id, f->level, false);7474 bool ret = !IS_ERR_OR_NULL(b);7575- if (ret) {7676- f->sectors_written = b->written;7777- six_unlock_read(&b->c.lock);7878- }7575+ if (!ret)7676+ return ret;7777+7878+ f->sectors_written = b->written;7979+ six_unlock_read(&b->c.lock);79808081 /*8182 * We might update this node's range; if that happens, we need the node
+173-134
fs/bcachefs/buckets.c
···465465 return bch2_update_replicas_list(trans, &r.e, sectors);466466}467467468468+static int bch2_check_fix_ptr(struct btree_trans *trans,469469+ struct bkey_s_c k,470470+ struct extent_ptr_decoded p,471471+ const union bch_extent_entry *entry,472472+ bool *do_update)473473+{474474+ struct bch_fs *c = trans->c;475475+ struct printbuf buf = PRINTBUF;476476+ int ret = 0;477477+478478+ struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);479479+ if (!ca) {480480+ if (fsck_err(c, ptr_to_invalid_device,481481+ "pointer to missing device %u\n"482482+ "while marking %s",483483+ p.ptr.dev,484484+ (printbuf_reset(&buf),485485+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))486486+ *do_update = true;487487+ return 0;488488+ }489489+490490+ struct bucket *g = PTR_GC_BUCKET(ca, &p.ptr);491491+ if (!g) {492492+ if (fsck_err(c, ptr_to_invalid_device,493493+ "pointer to invalid bucket on device %u\n"494494+ "while marking %s",495495+ p.ptr.dev,496496+ (printbuf_reset(&buf),497497+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))498498+ *do_update = true;499499+ goto out;500500+ }501501+502502+ enum bch_data_type data_type = bch2_bkey_ptr_data_type(k, p, entry);503503+504504+ if (fsck_err_on(!g->gen_valid,505505+ c, ptr_to_missing_alloc_key,506506+ "bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n"507507+ "while marking %s",508508+ p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),509509+ bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),510510+ p.ptr.gen,511511+ (printbuf_reset(&buf),512512+ bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {513513+ if (!p.ptr.cached) {514514+ g->gen_valid = true;515515+ g->gen = p.ptr.gen;516516+ } else {517517+ *do_update = true;518518+ }519519+ }520520+521521+ if (fsck_err_on(gen_cmp(p.ptr.gen, g->gen) > 0,522522+ c, ptr_gen_newer_than_bucket_gen,523523+ "bucket %u:%zu data type %s ptr gen in the future: %u > %u\n"524524+ "while marking %s",525525+ p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),526526+ bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),527527+ p.ptr.gen, g->gen,528528+ (printbuf_reset(&buf),529529+ bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {530530+ if (!p.ptr.cached &&531531+ (g->data_type != BCH_DATA_btree ||532532+ data_type == BCH_DATA_btree)) {533533+ g->gen_valid = true;534534+ g->gen = p.ptr.gen;535535+ g->data_type = 0;536536+ g->dirty_sectors = 0;537537+ g->cached_sectors = 0;538538+ } else {539539+ *do_update = true;540540+ }541541+ }542542+543543+ if (fsck_err_on(gen_cmp(g->gen, p.ptr.gen) > BUCKET_GC_GEN_MAX,544544+ c, ptr_gen_newer_than_bucket_gen,545545+ "bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n"546546+ "while marking %s",547547+ p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,548548+ bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),549549+ p.ptr.gen,550550+ (printbuf_reset(&buf),551551+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))552552+ *do_update = true;553553+554554+ if (fsck_err_on(!p.ptr.cached && gen_cmp(p.ptr.gen, g->gen) < 0,555555+ c, stale_dirty_ptr,556556+ "bucket %u:%zu data type %s stale dirty ptr: %u < %u\n"557557+ "while marking %s",558558+ p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),559559+ bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),560560+ p.ptr.gen, g->gen,561561+ (printbuf_reset(&buf),562562+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))563563+ *do_update = true;564564+565565+ if (data_type != BCH_DATA_btree && p.ptr.gen != g->gen)566566+ goto out;567567+568568+ if (fsck_err_on(bucket_data_type_mismatch(g->data_type, data_type),569569+ c, ptr_bucket_data_type_mismatch,570570+ "bucket %u:%zu gen %u different types of data in same bucket: %s, %s\n"571571+ "while marking %s",572572+ p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,573573+ bch2_data_type_str(g->data_type),574574+ bch2_data_type_str(data_type),575575+ (printbuf_reset(&buf),576576+ bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {577577+ if (data_type == BCH_DATA_btree) {578578+ g->gen_valid = true;579579+ g->gen = p.ptr.gen;580580+ g->data_type = data_type;581581+ g->dirty_sectors = 0;582582+ g->cached_sectors = 0;583583+ } else {584584+ *do_update = true;585585+ }586586+ }587587+588588+ if (p.has_ec) {589589+ struct gc_stripe *m = genradix_ptr(&c->gc_stripes, p.ec.idx);590590+591591+ if (fsck_err_on(!m || !m->alive,592592+ c, ptr_to_missing_stripe,593593+ "pointer to nonexistent stripe %llu\n"594594+ "while marking %s",595595+ (u64) p.ec.idx,596596+ (printbuf_reset(&buf),597597+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))598598+ *do_update = true;599599+600600+ if (fsck_err_on(m && m->alive && !bch2_ptr_matches_stripe_m(m, p),601601+ c, ptr_to_incorrect_stripe,602602+ "pointer does not match stripe %llu\n"603603+ "while marking %s",604604+ (u64) p.ec.idx,605605+ (printbuf_reset(&buf),606606+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))607607+ *do_update = true;608608+ }609609+out:610610+fsck_err:611611+ bch2_dev_put(ca);612612+ printbuf_exit(&buf);613613+ return ret;614614+}615615+468616int bch2_check_fix_ptrs(struct btree_trans *trans,469617 enum btree_id btree, unsigned level, struct bkey_s_c k,470618 enum btree_iter_update_trigger_flags flags)···628480 percpu_down_read(&c->mark_lock);629481630482 bkey_for_each_ptr_decode(k.k, ptrs_c, p, entry_c) {631631- struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);632632- if (!ca) {633633- if (fsck_err(c, ptr_to_invalid_device,634634- "pointer to missing device %u\n"635635- "while marking %s",636636- p.ptr.dev,637637- (printbuf_reset(&buf),638638- bch2_bkey_val_to_text(&buf, c, k), buf.buf)))639639- do_update = true;640640- continue;641641- }642642-643643- struct bucket *g = PTR_GC_BUCKET(ca, &p.ptr);644644- enum bch_data_type data_type = bch2_bkey_ptr_data_type(k, p, entry_c);645645-646646- if (fsck_err_on(!g->gen_valid,647647- c, ptr_to_missing_alloc_key,648648- "bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n"649649- "while marking %s",650650- p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),651651- bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),652652- p.ptr.gen,653653- (printbuf_reset(&buf),654654- bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {655655- if (!p.ptr.cached) {656656- g->gen_valid = true;657657- g->gen = p.ptr.gen;658658- } else {659659- do_update = true;660660- }661661- }662662-663663- if (fsck_err_on(gen_cmp(p.ptr.gen, g->gen) > 0,664664- c, ptr_gen_newer_than_bucket_gen,665665- "bucket %u:%zu data type %s ptr gen in the future: %u > %u\n"666666- "while marking %s",667667- p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),668668- bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),669669- p.ptr.gen, g->gen,670670- (printbuf_reset(&buf),671671- bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {672672- if (!p.ptr.cached &&673673- (g->data_type != BCH_DATA_btree ||674674- data_type == BCH_DATA_btree)) {675675- g->gen_valid = true;676676- g->gen = p.ptr.gen;677677- g->data_type = 0;678678- g->dirty_sectors = 0;679679- g->cached_sectors = 0;680680- } else {681681- do_update = true;682682- }683683- }684684-685685- if (fsck_err_on(gen_cmp(g->gen, p.ptr.gen) > BUCKET_GC_GEN_MAX,686686- c, ptr_gen_newer_than_bucket_gen,687687- "bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n"688688- "while marking %s",689689- p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,690690- bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),691691- p.ptr.gen,692692- (printbuf_reset(&buf),693693- bch2_bkey_val_to_text(&buf, c, k), buf.buf)))694694- do_update = true;695695-696696- if (fsck_err_on(!p.ptr.cached && gen_cmp(p.ptr.gen, g->gen) < 0,697697- c, stale_dirty_ptr,698698- "bucket %u:%zu data type %s stale dirty ptr: %u < %u\n"699699- "while marking %s",700700- p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),701701- bch2_data_type_str(ptr_data_type(k.k, &p.ptr)),702702- p.ptr.gen, g->gen,703703- (printbuf_reset(&buf),704704- bch2_bkey_val_to_text(&buf, c, k), buf.buf)))705705- do_update = true;706706-707707- if (data_type != BCH_DATA_btree && p.ptr.gen != g->gen)708708- goto next;709709-710710- if (fsck_err_on(bucket_data_type_mismatch(g->data_type, data_type),711711- c, ptr_bucket_data_type_mismatch,712712- "bucket %u:%zu gen %u different types of data in same bucket: %s, %s\n"713713- "while marking %s",714714- p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,715715- bch2_data_type_str(g->data_type),716716- bch2_data_type_str(data_type),717717- (printbuf_reset(&buf),718718- bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {719719- if (data_type == BCH_DATA_btree) {720720- g->gen_valid = true;721721- g->gen = p.ptr.gen;722722- g->data_type = data_type;723723- g->dirty_sectors = 0;724724- g->cached_sectors = 0;725725- } else {726726- do_update = true;727727- }728728- }729729-730730- if (p.has_ec) {731731- struct gc_stripe *m = genradix_ptr(&c->gc_stripes, p.ec.idx);732732-733733- if (fsck_err_on(!m || !m->alive, c,734734- ptr_to_missing_stripe,735735- "pointer to nonexistent stripe %llu\n"736736- "while marking %s",737737- (u64) p.ec.idx,738738- (printbuf_reset(&buf),739739- bch2_bkey_val_to_text(&buf, c, k), buf.buf)))740740- do_update = true;741741-742742- if (fsck_err_on(m && m->alive && !bch2_ptr_matches_stripe_m(m, p), c,743743- ptr_to_incorrect_stripe,744744- "pointer does not match stripe %llu\n"745745- "while marking %s",746746- (u64) p.ec.idx,747747- (printbuf_reset(&buf),748748- bch2_bkey_val_to_text(&buf, c, k), buf.buf)))749749- do_update = true;750750- }751751-next:752752- bch2_dev_put(ca);483483+ ret = bch2_check_fix_ptr(trans, k, p, entry_c, &do_update);484484+ if (ret)485485+ goto err;753486 }754487755488 if (do_update) {···745716 bch2_btree_node_update_key_early(trans, btree, level - 1, k, new);746717 }747718err:748748-fsck_err:749719 percpu_up_read(&c->mark_lock);750720 printbuf_exit(&buf);751721 return ret;···1015987 enum btree_iter_update_trigger_flags flags)1016988{1017989 bool insert = !(flags & BTREE_TRIGGER_overwrite);990990+ struct printbuf buf = PRINTBUF;1018991 int ret = 0;10199921020993 struct bch_fs *c = trans->c;···10481019 if (flags & BTREE_TRIGGER_gc) {10491020 percpu_down_read(&c->mark_lock);10501021 struct bucket *g = gc_bucket(ca, bucket.offset);10221022+ if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u\n %s",10231023+ p.ptr.dev,10241024+ (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {10251025+ ret = -EIO;10261026+ goto err_unlock;10271027+ }10281028+10511029 bucket_lock(g);10521030 struct bch_alloc_v4 old = bucket_m_to_alloc(*g), new = old;10531031 ret = __mark_pointer(trans, ca, k, &p.ptr, *sectors, bp.data_type, &new);···10631027 bch2_dev_usage_update(c, ca, &old, &new, 0, true);10641028 }10651029 bucket_unlock(g);10301030+err_unlock:10661031 percpu_up_read(&c->mark_lock);10671032 }10681033err:10691034 bch2_dev_put(ca);10351035+ printbuf_exit(&buf);10701036 return ret;10711037}10721038···13561318 u64 b, enum bch_data_type data_type, unsigned sectors,13571319 enum btree_iter_update_trigger_flags flags)13581320{13591359- int ret = 0;13601360-13611321 percpu_down_read(&c->mark_lock);13621322 struct bucket *g = gc_bucket(ca, b);13231323+ if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u when marking metadata type %s",13241324+ ca->dev_idx, bch2_data_type_str(data_type)))13251325+ goto err_unlock;1363132613641327 bucket_lock(g);13651328 struct bch_alloc_v4 old = bucket_m_to_alloc(*g);···13691330 g->data_type != data_type, c,13701331 "different types of data in same bucket: %s, %s",13711332 bch2_data_type_str(g->data_type),13721372- bch2_data_type_str(data_type))) {13731373- ret = -EIO;13331333+ bch2_data_type_str(data_type)))13741334 goto err;13751375- }1376133513771336 if (bch2_fs_inconsistent_on((u64) g->dirty_sectors + sectors > ca->mi.bucket_size, c,13781337 "bucket %u:%llu gen %u data type %s sector count overflow: %u + %u > bucket size",13791338 ca->dev_idx, b, g->gen,13801339 bch2_data_type_str(g->data_type ?: data_type),13811381- g->dirty_sectors, sectors)) {13821382- ret = -EIO;13401340+ g->dirty_sectors, sectors))13831341 goto err;13841384- }1385134213861343 g->data_type = data_type;13871344 g->dirty_sectors += sectors;13881345 struct bch_alloc_v4 new = bucket_m_to_alloc(*g);13461346+ bch2_dev_usage_update(c, ca, &old, &new, 0, true);13471347+ percpu_up_read(&c->mark_lock);13481348+ return 0;13891349err:13901350 bucket_unlock(g);13911391- if (!ret)13921392- bch2_dev_usage_update(c, ca, &old, &new, 0, true);13511351+err_unlock:13931352 percpu_up_read(&c->mark_lock);13941394- return ret;13531353+ return -EIO;13951354}1396135513971356int bch2_trans_mark_metadata_bucket(struct btree_trans *trans,···1632159516331596 bucket_gens->first_bucket = ca->mi.first_bucket;16341597 bucket_gens->nbuckets = nbuckets;15981598+ bucket_gens->nbuckets_minus_first =15991599+ bucket_gens->nbuckets - bucket_gens->first_bucket;1635160016361601 if (resize) {16371602 down_write(&c->gc_lock);
+11-6
fs/bcachefs/buckets.h
···9393{9494 struct bucket_array *buckets = gc_bucket_array(ca);95959696- BUG_ON(!bucket_valid(ca, b));9696+ if (b - buckets->first_bucket >= buckets->nbuckets_minus_first)9797+ return NULL;9798 return buckets->b + b;9899}99100···111110{112111 struct bucket_gens *gens = bucket_gens(ca);113112114114- BUG_ON(!bucket_valid(ca, b));113113+ if (b - gens->first_bucket >= gens->nbuckets_minus_first)114114+ return NULL;115115 return gens->b + b;116116}117117···172170 return r > 0 ? r : 0;173171}174172175175-static inline u8 dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr)173173+static inline int dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr)176174{177177- return gen_after(*bucket_gen(ca, PTR_BUCKET_NR(ca, ptr)), ptr->gen);175175+ u8 *gen = bucket_gen(ca, PTR_BUCKET_NR(ca, ptr));176176+ if (!gen)177177+ return -1;178178+ return gen_after(*gen, ptr->gen);178179}179180180181/**181182 * dev_ptr_stale() - check if a pointer points into a bucket that has been182183 * invalidated.183184 */184184-static inline u8 dev_ptr_stale(struct bch_dev *ca, const struct bch_extent_ptr *ptr)185185+static inline int dev_ptr_stale(struct bch_dev *ca, const struct bch_extent_ptr *ptr)185186{186187 rcu_read_lock();187187- u8 ret = dev_ptr_stale_rcu(ca, ptr);188188+ int ret = dev_ptr_stale_rcu(ca, ptr);188189 rcu_read_unlock();189190190191 return ret;
···36893689 struct folio *folio = page_folio(page);36903690 struct extent_buffer *exists;3691369136923692+ lockdep_assert_held(&page->mapping->i_private_lock);36933693+36923694 /*36933695 * For subpage case, we completely rely on radix tree to ensure we36943696 * don't try to insert two ebs for the same bytenr. So here we always···37583756 * The caller needs to free the existing folios and retry using the same order.37593757 */37603758static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,37593759+ struct btrfs_subpage *prealloc,37613760 struct extent_buffer **found_eb_ret)37623761{3763376237643763 struct btrfs_fs_info *fs_info = eb->fs_info;37653764 struct address_space *mapping = fs_info->btree_inode->i_mapping;37663765 const unsigned long index = eb->start >> PAGE_SHIFT;37673767- struct folio *existing_folio;37663766+ struct folio *existing_folio = NULL;37683767 int ret;3769376837703769 ASSERT(found_eb_ret);···37773774 ret = filemap_add_folio(mapping, eb->folios[i], index + i,37783775 GFP_NOFS | __GFP_NOFAIL);37793776 if (!ret)37803780- return 0;37773777+ goto finish;3781377837823779 existing_folio = filemap_lock_folio(mapping, index + i);37833780 /* The page cache only exists for a very short time, just retry. */37843784- if (IS_ERR(existing_folio))37813781+ if (IS_ERR(existing_folio)) {37823782+ existing_folio = NULL;37853783 goto retry;37843784+ }3786378537873786 /* For now, we should only have single-page folios for btree inode. */37883787 ASSERT(folio_nr_pages(existing_folio) == 1);···37953790 return -EAGAIN;37963791 }3797379237983798- if (fs_info->nodesize < PAGE_SIZE) {37993799- /*38003800- * We're going to reuse the existing page, can drop our page38013801- * and subpage structure now.38023802- */37933793+finish:37943794+ spin_lock(&mapping->i_private_lock);37953795+ if (existing_folio && fs_info->nodesize < PAGE_SIZE) {37963796+ /* We're going to reuse the existing page, can drop our folio now. */38033797 __free_page(folio_page(eb->folios[i], 0));38043798 eb->folios[i] = existing_folio;38053805- } else {37993799+ } else if (existing_folio) {38063800 struct extent_buffer *existing_eb;3807380138083802 existing_eb = grab_extent_buffer(fs_info,···38093805 if (existing_eb) {38103806 /* The extent buffer still exists, we can use it directly. */38113807 *found_eb_ret = existing_eb;38083808+ spin_unlock(&mapping->i_private_lock);38123809 folio_unlock(existing_folio);38133810 folio_put(existing_folio);38143811 return 1;···38183813 __free_page(folio_page(eb->folios[i], 0));38193814 eb->folios[i] = existing_folio;38203815 }38163816+ eb->folio_size = folio_size(eb->folios[i]);38173817+ eb->folio_shift = folio_shift(eb->folios[i]);38183818+ /* Should not fail, as we have preallocated the memory. */38193819+ ret = attach_extent_buffer_folio(eb, eb->folios[i], prealloc);38203820+ ASSERT(!ret);38213821+ /*38223822+ * To inform we have an extra eb under allocation, so that38233823+ * detach_extent_buffer_page() won't release the folio private when the38243824+ * eb hasn't been inserted into radix tree yet.38253825+ *38263826+ * The ref will be decreased when the eb releases the page, in38273827+ * detach_extent_buffer_page(). Thus needs no special handling in the38283828+ * error path.38293829+ */38303830+ btrfs_folio_inc_eb_refs(fs_info, eb->folios[i]);38313831+ spin_unlock(&mapping->i_private_lock);38213832 return 0;38223833}38233834···38453824 int attached = 0;38463825 struct extent_buffer *eb;38473826 struct extent_buffer *existing_eb = NULL;38483848- struct address_space *mapping = fs_info->btree_inode->i_mapping;38493827 struct btrfs_subpage *prealloc = NULL;38503828 u64 lockdep_owner = owner_root;38513829 bool page_contig = true;···39103890 for (int i = 0; i < num_folios; i++) {39113891 struct folio *folio;3912389239133913- ret = attach_eb_folio_to_filemap(eb, i, &existing_eb);38933893+ ret = attach_eb_folio_to_filemap(eb, i, prealloc, &existing_eb);39143894 if (ret > 0) {39153895 ASSERT(existing_eb);39163896 goto out;···39473927 * and free the allocated page.39483928 */39493929 folio = eb->folios[i];39503950- eb->folio_size = folio_size(folio);39513951- eb->folio_shift = folio_shift(folio);39523952- spin_lock(&mapping->i_private_lock);39533953- /* Should not fail, as we have preallocated the memory */39543954- ret = attach_extent_buffer_folio(eb, folio, prealloc);39553955- ASSERT(!ret);39563956- /*39573957- * To inform we have extra eb under allocation, so that39583958- * detach_extent_buffer_page() won't release the folio private39593959- * when the eb hasn't yet been inserted into radix tree.39603960- *39613961- * The ref will be decreased when the eb released the page, in39623962- * detach_extent_buffer_page().39633963- * Thus needs no special handling in error path.39643964- */39653965- btrfs_folio_inc_eb_refs(fs_info, folio);39663966- spin_unlock(&mapping->i_private_lock);39673967-39683930 WARN_ON(btrfs_folio_test_dirty(fs_info, folio, eb->start, eb->len));3969393139703932 /*
+11-6
fs/btrfs/tree-log.c
···48604860 path->slots[0]++;48614861 continue;48624862 }48634863- if (!dropped_extents) {48644864- /*48654865- * Avoid logging extent items logged in past fsync calls48664866- * and leading to duplicate keys in the log tree.48674867- */48634863+ /*48644864+ * Avoid overlapping items in the log tree. The first time we48654865+ * get here, get rid of everything from a past fsync. After48664866+ * that, if the current extent starts before the end of the last48674867+ * extent we copied, truncate the last one. This can happen if48684868+ * an ordered extent completion modifies the subvolume tree48694869+ * while btrfs_next_leaf() has the tree unlocked.48704870+ */48714871+ if (!dropped_extents || key.offset < truncate_offset) {48684872 ret = truncate_inode_items(trans, root->log_root, inode,48694869- truncate_offset,48734873+ min(key.offset, truncate_offset),48704874 BTRFS_EXTENT_DATA_KEY);48714875 if (ret)48724876 goto out;48734877 dropped_extents = true;48744878 }48794879+ truncate_offset = btrfs_file_extent_end(path);48754880 if (ins_nr == 0)48764881 start_slot = slot;48774882 ins_nr++;
···11// SPDX-License-Identifier: GPL-2.0-or-later22-#include <linux/fdtable.h>32#include <linux/anon_inodes.h>43#include <linux/uio.h>54#include "internal.h"55+66+struct ondemand_anon_file {77+ struct file *file;88+ int fd;99+};1010+1111+static inline void cachefiles_req_put(struct cachefiles_req *req)1212+{1313+ if (refcount_dec_and_test(&req->ref))1414+ kfree(req);1515+}616717static int cachefiles_ondemand_fd_release(struct inode *inode,818 struct file *file)919{1020 struct cachefiles_object *object = file->private_data;1111- struct cachefiles_cache *cache = object->volume->cache;1212- struct cachefiles_ondemand_info *info = object->ondemand;1313- int object_id = info->ondemand_id;2121+ struct cachefiles_cache *cache;2222+ struct cachefiles_ondemand_info *info;2323+ int object_id;1424 struct cachefiles_req *req;1515- XA_STATE(xas, &cache->reqs, 0);2525+ XA_STATE(xas, NULL, 0);2626+2727+ if (!object)2828+ return 0;2929+3030+ info = object->ondemand;3131+ cache = object->volume->cache;3232+ xas.xa = &cache->reqs;16331734 xa_lock(&cache->reqs);3535+ spin_lock(&info->lock);3636+ object_id = info->ondemand_id;1837 info->ondemand_id = CACHEFILES_ONDEMAND_ID_CLOSED;1938 cachefiles_ondemand_set_object_close(object);3939+ spin_unlock(&info->lock);20402141 /* Only flush CACHEFILES_REQ_NEW marked req to avoid race with daemon_read */2242 xas_for_each_marked(&xas, req, ULONG_MAX, CACHEFILES_REQ_NEW) {···9676}97779878static long cachefiles_ondemand_fd_ioctl(struct file *filp, unsigned int ioctl,9999- unsigned long arg)7979+ unsigned long id)10080{10181 struct cachefiles_object *object = filp->private_data;10282 struct cachefiles_cache *cache = object->volume->cache;10383 struct cachefiles_req *req;104104- unsigned long id;8484+ XA_STATE(xas, &cache->reqs, id);1058510686 if (ioctl != CACHEFILES_IOC_READ_COMPLETE)10787 return -EINVAL;···10989 if (!test_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags))11090 return -EOPNOTSUPP;11191112112- id = arg;113113- req = xa_erase(&cache->reqs, id);114114- if (!req)9292+ xa_lock(&cache->reqs);9393+ req = xas_load(&xas);9494+ if (!req || req->msg.opcode != CACHEFILES_OP_READ ||9595+ req->object != object) {9696+ xa_unlock(&cache->reqs);11597 return -EINVAL;9898+ }9999+ xas_store(&xas, NULL);100100+ xa_unlock(&cache->reqs);116101117102 trace_cachefiles_ondemand_cread(object, id);118103 complete(&req->done);···141116{142117 struct cachefiles_req *req;143118 struct fscache_cookie *cookie;119119+ struct cachefiles_ondemand_info *info;144120 char *pid, *psize;145121 unsigned long id;146122 long size;147123 int ret;124124+ XA_STATE(xas, &cache->reqs, 0);148125149126 if (!test_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags))150127 return -EOPNOTSUPP;···170143 if (ret)171144 return ret;172145173173- req = xa_erase(&cache->reqs, id);174174- if (!req)146146+ xa_lock(&cache->reqs);147147+ xas.xa_index = id;148148+ req = xas_load(&xas);149149+ if (!req || req->msg.opcode != CACHEFILES_OP_OPEN ||150150+ !req->object->ondemand->ondemand_id) {151151+ xa_unlock(&cache->reqs);175152 return -EINVAL;153153+ }154154+ xas_store(&xas, NULL);155155+ xa_unlock(&cache->reqs);176156157157+ info = req->object->ondemand;177158 /* fail OPEN request if copen format is invalid */178159 ret = kstrtol(psize, 0, &size);179160 if (ret) {···201166 goto out;202167 }203168169169+ spin_lock(&info->lock);170170+ /*171171+ * The anonymous fd was closed before copen ? Fail the request.172172+ *173173+ * t1 | t2174174+ * ---------------------------------------------------------175175+ * cachefiles_ondemand_copen176176+ * req = xa_erase(&cache->reqs, id)177177+ * // Anon fd is maliciously closed.178178+ * cachefiles_ondemand_fd_release179179+ * xa_lock(&cache->reqs)180180+ * cachefiles_ondemand_set_object_close(object)181181+ * xa_unlock(&cache->reqs)182182+ * cachefiles_ondemand_set_object_open183183+ * // No one will ever close it again.184184+ * cachefiles_ondemand_daemon_read185185+ * cachefiles_ondemand_select_req186186+ *187187+ * Get a read req but its fd is already closed. The daemon can't188188+ * issue a cread ioctl with an closed fd, then hung.189189+ */190190+ if (info->ondemand_id == CACHEFILES_ONDEMAND_ID_CLOSED) {191191+ spin_unlock(&info->lock);192192+ req->error = -EBADFD;193193+ goto out;194194+ }204195 cookie = req->object->cookie;205196 cookie->object_size = size;206197 if (size)···236175 trace_cachefiles_ondemand_copen(req->object, id, size);237176238177 cachefiles_ondemand_set_object_open(req->object);178178+ spin_unlock(&info->lock);239179 wake_up_all(&cache->daemon_pollwq);240180241181out:182182+ spin_lock(&info->lock);183183+ /* Need to set object close to avoid reopen status continuing */184184+ if (info->ondemand_id == CACHEFILES_ONDEMAND_ID_CLOSED)185185+ cachefiles_ondemand_set_object_close(req->object);186186+ spin_unlock(&info->lock);242187 complete(&req->done);243188 return ret;244189}···272205 return 0;273206}274207275275-static int cachefiles_ondemand_get_fd(struct cachefiles_req *req)208208+static int cachefiles_ondemand_get_fd(struct cachefiles_req *req,209209+ struct ondemand_anon_file *anon_file)276210{277211 struct cachefiles_object *object;278212 struct cachefiles_cache *cache;279213 struct cachefiles_open *load;280280- struct file *file;281214 u32 object_id;282282- int ret, fd;215215+ int ret;283216284217 object = cachefiles_grab_object(req->object,285218 cachefiles_obj_get_ondemand_fd);···291224 if (ret < 0)292225 goto err;293226294294- fd = get_unused_fd_flags(O_WRONLY);295295- if (fd < 0) {296296- ret = fd;227227+ anon_file->fd = get_unused_fd_flags(O_WRONLY);228228+ if (anon_file->fd < 0) {229229+ ret = anon_file->fd;297230 goto err_free_id;298231 }299232300300- file = anon_inode_getfile("[cachefiles]", &cachefiles_ondemand_fd_fops,301301- object, O_WRONLY);302302- if (IS_ERR(file)) {303303- ret = PTR_ERR(file);233233+ anon_file->file = anon_inode_getfile("[cachefiles]",234234+ &cachefiles_ondemand_fd_fops, object, O_WRONLY);235235+ if (IS_ERR(anon_file->file)) {236236+ ret = PTR_ERR(anon_file->file);304237 goto err_put_fd;305238 }306239307307- file->f_mode |= FMODE_PWRITE | FMODE_LSEEK;308308- fd_install(fd, file);240240+ spin_lock(&object->ondemand->lock);241241+ if (object->ondemand->ondemand_id > 0) {242242+ spin_unlock(&object->ondemand->lock);243243+ /* Pair with check in cachefiles_ondemand_fd_release(). */244244+ anon_file->file->private_data = NULL;245245+ ret = -EEXIST;246246+ goto err_put_file;247247+ }248248+249249+ anon_file->file->f_mode |= FMODE_PWRITE | FMODE_LSEEK;309250310251 load = (void *)req->msg.data;311311- load->fd = fd;252252+ load->fd = anon_file->fd;312253 object->ondemand->ondemand_id = object_id;254254+ spin_unlock(&object->ondemand->lock);313255314256 cachefiles_get_unbind_pincount(cache);315257 trace_cachefiles_ondemand_open(object, &req->msg, load);316258 return 0;317259260260+err_put_file:261261+ fput(anon_file->file);262262+ anon_file->file = NULL;318263err_put_fd:319319- put_unused_fd(fd);264264+ put_unused_fd(anon_file->fd);265265+ anon_file->fd = ret;320266err_free_id:321267 xa_erase(&cache->ondemand_ids, object_id);322268err:269269+ spin_lock(&object->ondemand->lock);270270+ /* Avoid marking an opened object as closed. */271271+ if (object->ondemand->ondemand_id <= 0)272272+ cachefiles_ondemand_set_object_close(object);273273+ spin_unlock(&object->ondemand->lock);323274 cachefiles_put_object(object, cachefiles_obj_put_ondemand_fd);324275 return ret;325276}···379294 return NULL;380295}381296297297+static inline bool cachefiles_ondemand_finish_req(struct cachefiles_req *req,298298+ struct xa_state *xas, int err)299299+{300300+ if (unlikely(!xas || !req))301301+ return false;302302+303303+ if (xa_cmpxchg(xas->xa, xas->xa_index, req, NULL, 0) != req)304304+ return false;305305+306306+ req->error = err;307307+ complete(&req->done);308308+ return true;309309+}310310+382311ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,383312 char __user *_buffer, size_t buflen)384313{385314 struct cachefiles_req *req;386315 struct cachefiles_msg *msg;387387- unsigned long id = 0;388316 size_t n;389317 int ret = 0;318318+ struct ondemand_anon_file anon_file;390319 XA_STATE(xas, &cache->reqs, cache->req_id_next);391320392321 xa_lock(&cache->reqs);···429330430331 xas_clear_mark(&xas, CACHEFILES_REQ_NEW);431332 cache->req_id_next = xas.xa_index + 1;333333+ refcount_inc(&req->ref);334334+ cachefiles_grab_object(req->object, cachefiles_obj_get_read_req);432335 xa_unlock(&cache->reqs);433336434434- id = xas.xa_index;435435-436337 if (msg->opcode == CACHEFILES_OP_OPEN) {437437- ret = cachefiles_ondemand_get_fd(req);438438- if (ret) {439439- cachefiles_ondemand_set_object_close(req->object);440440- goto error;441441- }338338+ ret = cachefiles_ondemand_get_fd(req, &anon_file);339339+ if (ret)340340+ goto out;442341 }443342444444- msg->msg_id = id;343343+ msg->msg_id = xas.xa_index;445344 msg->object_id = req->object->ondemand->ondemand_id;446345447447- if (copy_to_user(_buffer, msg, n) != 0) {346346+ if (copy_to_user(_buffer, msg, n) != 0)448347 ret = -EFAULT;449449- goto err_put_fd;348348+349349+ if (msg->opcode == CACHEFILES_OP_OPEN) {350350+ if (ret < 0) {351351+ fput(anon_file.file);352352+ put_unused_fd(anon_file.fd);353353+ goto out;354354+ }355355+ fd_install(anon_file.fd, anon_file.file);450356 }451451-452452- /* CLOSE request has no reply */453453- if (msg->opcode == CACHEFILES_OP_CLOSE) {454454- xa_erase(&cache->reqs, id);455455- complete(&req->done);456456- }457457-458458- return n;459459-460460-err_put_fd:461461- if (msg->opcode == CACHEFILES_OP_OPEN)462462- close_fd(((struct cachefiles_open *)msg->data)->fd);463463-error:464464- xa_erase(&cache->reqs, id);465465- req->error = ret;466466- complete(&req->done);467467- return ret;357357+out:358358+ cachefiles_put_object(req->object, cachefiles_obj_put_read_req);359359+ /* Remove error request and CLOSE request has no reply */360360+ if (ret || msg->opcode == CACHEFILES_OP_CLOSE)361361+ cachefiles_ondemand_finish_req(req, &xas, ret);362362+ cachefiles_req_put(req);363363+ return ret ? ret : n;468364}469365470366typedef int (*init_req_fn)(struct cachefiles_req *req, void *private);···489395 goto out;490396 }491397398398+ refcount_set(&req->ref, 1);492399 req->object = object;493400 init_completion(&req->done);494401 req->msg.opcode = opcode;···549454 goto out;550455551456 wake_up_all(&cache->daemon_pollwq);552552- wait_for_completion(&req->done);553553- ret = req->error;554554- kfree(req);457457+wait:458458+ ret = wait_for_completion_killable(&req->done);459459+ if (!ret) {460460+ ret = req->error;461461+ } else {462462+ ret = -EINTR;463463+ if (!cachefiles_ondemand_finish_req(req, &xas, ret)) {464464+ /* Someone will complete it soon. */465465+ cpu_relax();466466+ goto wait;467467+ }468468+ }469469+ cachefiles_req_put(req);555470 return ret;556471out:557472 /* Reset the object to close state in error handling path.···683578 return -ENOMEM;684579685580 object->ondemand->object = object;581581+ spin_lock_init(&object->ondemand->lock);686582 INIT_WORK(&object->ondemand->ondemand_work, ondemand_object_worker);687583 return 0;688584}
+9-1
fs/debugfs/inode.c
···107107 int opt;108108109109 opt = fs_parse(fc, debugfs_param_specs, param, &result);110110- if (opt < 0)110110+ if (opt < 0) {111111+ /*112112+ * We might like to report bad mount options here; but113113+ * traditionally debugfs has ignored all mount options114114+ */115115+ if (opt == -ENOPARAM)116116+ return 0;117117+111118 return opt;119119+ }112120113121 switch (opt) {114122 case Opt_uid:
+2-2
fs/file.c
···486486487487static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)488488{489489- unsigned int maxfd = fdt->max_fds;489489+ unsigned int maxfd = fdt->max_fds; /* always multiple of BITS_PER_LONG */490490 unsigned int maxbit = maxfd / BITS_PER_LONG;491491 unsigned int bitbit = start / BITS_PER_LONG;492492493493 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG;494494- if (bitbit > maxfd)494494+ if (bitbit >= maxfd)495495 return maxfd;496496 if (bitbit > start)497497 start = bitbit;
+27-31
fs/iomap/buffered-io.c
···241241 unsigned block_size = (1 << block_bits);242242 size_t poff = offset_in_folio(folio, *pos);243243 size_t plen = min_t(loff_t, folio_size(folio) - poff, length);244244+ size_t orig_plen = plen;244245 unsigned first = poff >> block_bits;245246 unsigned last = (poff + plen - 1) >> block_bits;246247···278277 * handle both halves separately so that we properly zero data in the279278 * page cache for blocks that are entirely outside of i_size.280279 */281281- if (orig_pos <= isize && orig_pos + length > isize) {280280+ if (orig_pos <= isize && orig_pos + orig_plen > isize) {282281 unsigned end = offset_in_folio(folio, isize - 1) >> block_bits;283282284283 if (first <= end && last > end)···878877 size_t copied, struct folio *folio)879878{880879 const struct iomap *srcmap = iomap_iter_srcmap(iter);880880+ loff_t old_size = iter->inode->i_size;881881+ size_t written;881882882883 if (srcmap->type == IOMAP_INLINE) {883884 iomap_write_end_inline(iter, folio, pos, copied);884884- return true;885885- }886886-887887- if (srcmap->flags & IOMAP_F_BUFFER_HEAD) {888888- size_t bh_written;889889-890890- bh_written = block_write_end(NULL, iter->inode->i_mapping, pos,885885+ written = copied;886886+ } else if (srcmap->flags & IOMAP_F_BUFFER_HEAD) {887887+ written = block_write_end(NULL, iter->inode->i_mapping, pos,891888 len, copied, &folio->page, NULL);892892- WARN_ON_ONCE(bh_written != copied && bh_written != 0);893893- return bh_written == copied;889889+ WARN_ON_ONCE(written != copied && written != 0);890890+ } else {891891+ written = __iomap_write_end(iter->inode, pos, len, copied,892892+ folio) ? copied : 0;894893 }895894896896- return __iomap_write_end(iter->inode, pos, len, copied, folio);895895+ /*896896+ * Update the in-memory inode size after copying the data into the page897897+ * cache. It's up to the file system to write the updated size to disk,898898+ * preferably after I/O completion so that no stale data is exposed.899899+ * Only once that's done can we unlock and release the folio.900900+ */901901+ if (pos + written > old_size) {902902+ i_size_write(iter->inode, pos + written);903903+ iter->iomap.flags |= IOMAP_F_SIZE_CHANGED;904904+ }905905+ __iomap_put_folio(iter, pos, written, folio);906906+907907+ if (old_size < pos)908908+ pagecache_isize_extended(iter->inode, old_size, pos);909909+910910+ return written == copied;897911}898912899913static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)···923907924908 do {925909 struct folio *folio;926926- loff_t old_size;927910 size_t offset; /* Offset into folio */928911 size_t bytes; /* Bytes to write to folio */929912 size_t copied; /* Bytes copied from user */···973958 copied = copy_folio_from_iter_atomic(folio, offset, bytes, i);974959 written = iomap_write_end(iter, pos, bytes, copied, folio) ?975960 copied : 0;976976-977977- /*978978- * Update the in-memory inode size after copying the data into979979- * the page cache. It's up to the file system to write the980980- * updated size to disk, preferably after I/O completion so that981981- * no stale data is exposed. Only once that's done can we982982- * unlock and release the folio.983983- */984984- old_size = iter->inode->i_size;985985- if (pos + written > old_size) {986986- i_size_write(iter->inode, pos + written);987987- iter->iomap.flags |= IOMAP_F_SIZE_CHANGED;988988- }989989- __iomap_put_folio(iter, pos, written, folio);990990-991991- if (old_size < pos)992992- pagecache_isize_extended(iter->inode, old_size, pos);993961994962 cond_resched();995963 if (unlikely(written == 0)) {···13441346 bytes = folio_size(folio) - offset;1345134713461348 ret = iomap_write_end(iter, pos, bytes, bytes, folio);13471347- __iomap_put_folio(iter, pos, bytes, folio);13481349 if (WARN_ON_ONCE(!ret))13491350 return -EIO;13501351···14091412 folio_mark_accessed(folio);1410141314111414 ret = iomap_write_end(iter, pos, bytes, bytes, folio);14121412- __iomap_put_folio(iter, pos, bytes, folio);14131415 if (WARN_ON_ONCE(!ret))14141416 return -EIO;14151417
+48-29
fs/nfs/dir.c
···16271627 switch (error) {16281628 case 1:16291629 break;16301630- case 0:16301630+ case -ETIMEDOUT:16311631+ if (inode && (IS_ROOT(dentry) ||16321632+ NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL))16331633+ error = 1;16341634+ break;16351635+ case -ESTALE:16361636+ case -ENOENT:16371637+ error = 0;16381638+ fallthrough;16391639+ default:16311640 /*16321641 * We can't d_drop the root of a disconnected tree:16331642 * its d_hash is on the s_anon list and d_drop() would hide···1691168216921683 dir_verifier = nfs_save_change_attribute(dir);16931684 ret = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr);16941694- if (ret < 0) {16951695- switch (ret) {16961696- case -ESTALE:16971697- case -ENOENT:16981698- ret = 0;16991699- break;17001700- case -ETIMEDOUT:17011701- if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL)17021702- ret = 1;17031703- }16851685+ if (ret < 0)17041686 goto out;17051705- }1706168717071688 /* Request help from readdirplus */17081689 nfs_lookup_advise_force_readdirplus(dir, flags);···17361737 unsigned int flags)17371738{17381739 struct inode *inode;17391739- int error;17401740+ int error = 0;1740174117411742 nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE);17421743 inode = d_inode(dentry);···17811782out_bad:17821783 if (flags & LOOKUP_RCU)17831784 return -ECHILD;17841784- return nfs_lookup_revalidate_done(dir, dentry, inode, 0);17851785+ return nfs_lookup_revalidate_done(dir, dentry, inode, error);17851786}1786178717871788static int···18031804 if (parent != READ_ONCE(dentry->d_parent))18041805 return -ECHILD;18051806 } else {18061806- /* Wait for unlink to complete */18071807+ /* Wait for unlink to complete - see unblock_revalidate() */18071808 wait_var_event(&dentry->d_fsdata,18081808- dentry->d_fsdata != NFS_FSDATA_BLOCKED);18091809+ smp_load_acquire(&dentry->d_fsdata)18101810+ != NFS_FSDATA_BLOCKED);18091811 parent = dget_parent(dentry);18101812 ret = reval(d_inode(parent), dentry, flags);18111813 dput(parent);···18171817static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)18181818{18191819 return __nfs_lookup_revalidate(dentry, flags, nfs_do_lookup_revalidate);18201820+}18211821+18221822+static void block_revalidate(struct dentry *dentry)18231823+{18241824+ /* old devname - just in case */18251825+ kfree(dentry->d_fsdata);18261826+18271827+ /* Any new reference that could lead to an open18281828+ * will take ->d_lock in lookup_open() -> d_lookup().18291829+ * Holding this lock ensures we cannot race with18301830+ * __nfs_lookup_revalidate() and removes and need18311831+ * for further barriers.18321832+ */18331833+ lockdep_assert_held(&dentry->d_lock);18341834+18351835+ dentry->d_fsdata = NFS_FSDATA_BLOCKED;18361836+}18371837+18381838+static void unblock_revalidate(struct dentry *dentry)18391839+{18401840+ /* store_release ensures wait_var_event() sees the update */18411841+ smp_store_release(&dentry->d_fsdata, NULL);18421842+ wake_up_var(&dentry->d_fsdata);18201843}1821184418221845/*···22782255 */22792256 int error = 0;2280225722582258+ if (dentry->d_name.len > NFS_SERVER(dir)->namelen)22592259+ return -ENAMETOOLONG;22602260+22812261 if (open_flags & O_CREAT) {22822262 file->f_mode |= FMODE_CREATED;22832263 error = nfs_do_create(dir, dentry, mode, open_flags);···25752549 spin_unlock(&dentry->d_lock);25762550 goto out;25772551 }25782578- /* old devname */25792579- kfree(dentry->d_fsdata);25802580- dentry->d_fsdata = NFS_FSDATA_BLOCKED;25522552+ block_revalidate(dentry);2581255325822554 spin_unlock(&dentry->d_lock);25832555 error = nfs_safe_remove(dentry);25842556 nfs_dentry_remove_handle_error(dir, dentry, error);25852585- dentry->d_fsdata = NULL;25862586- wake_up_var(&dentry->d_fsdata);25572557+ unblock_revalidate(dentry);25872558out:25882559 trace_nfs_unlink_exit(dir, dentry, error);25892560 return error;···26872664{26882665 struct dentry *new_dentry = data->new_dentry;2689266626902690- new_dentry->d_fsdata = NULL;26912691- wake_up_var(&new_dentry->d_fsdata);26672667+ unblock_revalidate(new_dentry);26922668}2693266926942670/*···27492727 if (WARN_ON(new_dentry->d_flags & DCACHE_NFSFS_RENAMED) ||27502728 WARN_ON(new_dentry->d_fsdata == NFS_FSDATA_BLOCKED))27512729 goto out;27522752- if (new_dentry->d_fsdata) {27532753- /* old devname */27542754- kfree(new_dentry->d_fsdata);27552755- new_dentry->d_fsdata = NULL;27562756- }2757273027582731 spin_lock(&new_dentry->d_lock);27592732 if (d_count(new_dentry) > 2) {···27702753 new_dentry = dentry;27712754 new_inode = NULL;27722755 } else {27732773- new_dentry->d_fsdata = NFS_FSDATA_BLOCKED;27562756+ block_revalidate(new_dentry);27742757 must_unblock = true;27752758 spin_unlock(&new_dentry->d_lock);27762759 }···27822765 task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry,27832766 must_unblock ? nfs_unblock_rename : NULL);27842767 if (IS_ERR(task)) {27682768+ if (must_unblock)27692769+ unblock_revalidate(new_dentry);27852770 error = PTR_ERR(task);27862771 goto out;27872772 }
+23-1
fs/nfs/nfs4proc.c
···40234023 }40244024}4025402540264026+static bool _is_same_nfs4_pathname(struct nfs4_pathname *path1,40274027+ struct nfs4_pathname *path2)40284028+{40294029+ int i;40304030+40314031+ if (path1->ncomponents != path2->ncomponents)40324032+ return false;40334033+ for (i = 0; i < path1->ncomponents; i++) {40344034+ if (path1->components[i].len != path2->components[i].len)40354035+ return false;40364036+ if (memcmp(path1->components[i].data, path2->components[i].data,40374037+ path1->components[i].len))40384038+ return false;40394039+ }40404040+ return true;40414041+}40424042+40264043static int _nfs4_discover_trunking(struct nfs_server *server,40274044 struct nfs_fh *fhandle)40284045{···40734056 if (status)40744057 goto out_free_3;4075405840764076- for (i = 0; i < locations->nlocations; i++)40594059+ for (i = 0; i < locations->nlocations; i++) {40604060+ if (!_is_same_nfs4_pathname(&locations->fs_path,40614061+ &locations->locations[i].rootpath))40624062+ continue;40774063 test_fs_location_for_trunking(&locations->locations[i], clp,40784064 server);40654065+ }40794066out_free_3:40804067 kfree(locations->fattr);40814068out_free_2:···62896268 if (status == 0)62906269 nfs_setsecurity(inode, fattr);6291627062716271+ nfs_free_fattr(fattr);62926272 return status;62936273}62946274#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
+5
fs/nfs/pagelist.c
···15451545 continue;15461546 } else if (index == prev->wb_index + 1)15471547 continue;15481548+ /*15491549+ * We will submit more requests after these. Indicate15501550+ * this to the underlying layers.15511551+ */15521552+ desc->pg_moreio = 1;15481553 nfs_pageio_complete(desc);15491554 break;15501555 }
···11-/* SPDX-License-Identifier: GPL-2.0-only */11+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */22/*33 * Device Tree constants for the Texas Instruments DP83867 PHY44 *55 * Author: Dan Murphy <dmurphy@ti.com>66 *77- * Copyright: (C) 2015 Texas Instruments, Inc.77+ * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/88 */991010#ifndef _DT_BINDINGS_TI_DP83867_H
+2-2
include/dt-bindings/net/ti-dp83869.h
···11-/* SPDX-License-Identifier: GPL-2.0-only */11+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */22/*33 * Device Tree constants for the Texas Instruments DP83869 PHY44 *55 * Author: Dan Murphy <dmurphy@ti.com>66 *77- * Copyright: (C) 2019 Texas Instruments, Inc.77+ * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/88 */991010#ifndef _DT_BINDINGS_TI_DP83869_H
+3-3
include/linux/atomic/atomic-arch-fallback.h
···2242224222432243/**22442244 * raw_atomic_sub_and_test() - atomic subtract and test if zero with full ordering22452245- * @i: int value to add22452245+ * @i: int value to subtract22462246 * @v: pointer to atomic_t22472247 *22482248 * Atomically updates @v to (@v - @i) with full ordering.···4368436843694369/**43704370 * raw_atomic64_sub_and_test() - atomic subtract and test if zero with full ordering43714371- * @i: s64 value to add43714371+ * @i: s64 value to subtract43724372 * @v: pointer to atomic64_t43734373 *43744374 * Atomically updates @v to (@v - @i) with full ordering.···46904690}4691469146924692#endif /* _LINUX_ATOMIC_FALLBACK_H */46934693-// 14850c0b0db20c62fdc78ccd1d42b98b88d7633146934693+// b565db590afeeff0d7c9485ccbca5bb6e155749f
+4-4
include/linux/atomic/atomic-instrumented.h
···1349134913501350/**13511351 * atomic_sub_and_test() - atomic subtract and test if zero with full ordering13521352- * @i: int value to add13521352+ * @i: int value to subtract13531353 * @v: pointer to atomic_t13541354 *13551355 * Atomically updates @v to (@v - @i) with full ordering.···2927292729282928/**29292929 * atomic64_sub_and_test() - atomic subtract and test if zero with full ordering29302930- * @i: s64 value to add29302930+ * @i: s64 value to subtract29312931 * @v: pointer to atomic64_t29322932 *29332933 * Atomically updates @v to (@v - @i) with full ordering.···4505450545064506/**45074507 * atomic_long_sub_and_test() - atomic subtract and test if zero with full ordering45084508- * @i: long value to add45084508+ * @i: long value to subtract45094509 * @v: pointer to atomic_long_t45104510 *45114511 * Atomically updates @v to (@v - @i) with full ordering.···505050505051505150525052#endif /* _LINUX_ATOMIC_INSTRUMENTED_H */50535053-// ce5b65e0f1f8a276268b667194581d24bed219d450535053+// 8829b337928e9508259079d32581775ececd415b
+2-2
include/linux/atomic/atomic-long.h
···1535153515361536/**15371537 * raw_atomic_long_sub_and_test() - atomic subtract and test if zero with full ordering15381538- * @i: long value to add15381538+ * @i: long value to subtract15391539 * @v: pointer to atomic_long_t15401540 *15411541 * Atomically updates @v to (@v - @i) with full ordering.···18091809}1810181018111811#endif /* _LINUX_ATOMIC_LONG_H */18121812-// 1c4a26fc77f345342953770ebe3c4d08e7ce2f9a18121812+// eadf183c3600b8b92b91839dd3be6bcc560c752d
+1-1
include/linux/cdrom.h
···7777 unsigned int clearing, int slot);7878 int (*tray_move) (struct cdrom_device_info *, int);7979 int (*lock_door) (struct cdrom_device_info *, int);8080- int (*select_speed) (struct cdrom_device_info *, int);8080+ int (*select_speed) (struct cdrom_device_info *, unsigned long);8181 int (*get_last_session) (struct cdrom_device_info *,8282 struct cdrom_multisession *);8383 int (*get_mcn) (struct cdrom_device_info *,
···985985 * Represent how many empty pages are merged with kernel zero986986 * pages when enabling KSM use_zero_pages.987987 */988988- unsigned long ksm_zero_pages;988988+ atomic_long_t ksm_zero_pages;989989#endif /* CONFIG_KSM */990990#ifdef CONFIG_LRU_GEN_WALKS_MMU991991 struct {
+1-1
include/linux/netfs.h
···521521522522/**523523 * netfs_wait_for_outstanding_io - Wait for outstanding I/O to complete524524- * @ctx: The netfs inode to wait on524524+ * @inode: The netfs inode to wait on525525 *526526 * Wait for outstanding I/O requests of any type to complete. This is intended527527 * to be called from inode eviction routines. This makes sure that any
···473473474474/* Variant of pskb_inet_may_pull().475475 */476476-static inline bool skb_vlan_inet_prepare(struct sk_buff *skb)476476+static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,477477+ bool inner_proto_inherit)477478{478478- int nhlen = 0, maclen = ETH_HLEN;479479+ int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;479480 __be16 type = skb->protocol;480481481482 /* Essentially this is skb_protocol(skb, true)
+7-1
include/trace/events/cachefiles.h
···3333 cachefiles_obj_see_withdrawal,3434 cachefiles_obj_get_ondemand_fd,3535 cachefiles_obj_put_ondemand_fd,3636+ cachefiles_obj_get_read_req,3737+ cachefiles_obj_put_read_req,3638};37393840enum fscache_why_object_killed {···129127 EM(cachefiles_obj_see_lookup_cookie, "SEE lookup_cookie") \130128 EM(cachefiles_obj_see_lookup_failed, "SEE lookup_failed") \131129 EM(cachefiles_obj_see_withdraw_cookie, "SEE withdraw_cookie") \132132- E_(cachefiles_obj_see_withdrawal, "SEE withdrawal")130130+ EM(cachefiles_obj_see_withdrawal, "SEE withdrawal") \131131+ EM(cachefiles_obj_get_ondemand_fd, "GET ondemand_fd") \132132+ EM(cachefiles_obj_put_ondemand_fd, "PUT ondemand_fd") \133133+ EM(cachefiles_obj_get_read_req, "GET read_req") \134134+ E_(cachefiles_obj_put_read_req, "PUT read_req")133135134136#define cachefiles_coherency_traces \135137 EM(cachefiles_coherency_check_aux, "BAD aux ") \
+2
include/uapi/linux/input-event-codes.h
···618618#define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */619619#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */620620#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */621621+#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */622622+#define KEY_DO_NOT_DISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/621623622624#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */623625#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
+1-1
include/uapi/linux/stat.h
···126126 __u64 stx_mnt_id;127127 __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */128128 __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */129129- __u64 stx_subvol; /* Subvolume identifier */130129 /* 0xa0 */130130+ __u64 stx_subvol; /* Subvolume identifier */131131 __u64 __spare3[11]; /* Spare space for future expansion */132132 /* 0x100 */133133};
···433433{434434 if (req->flags & REQ_F_CAN_POLL)435435 return true;436436- if (file_can_poll(req->file)) {436436+ if (req->file && file_can_poll(req->file)) {437437 req->flags |= REQ_F_CAN_POLL;438438 return true;439439 }
+12-10
io_uring/napi.c
···261261}262262263263/*264264- * __io_napi_adjust_timeout() - Add napi id to the busy poll list264264+ * __io_napi_adjust_timeout() - adjust busy loop timeout265265 * @ctx: pointer to io-uring context structure266266 * @iowq: pointer to io wait queue267267 * @ts: pointer to timespec or NULL268268 *269269 * Adjust the busy loop timeout according to timespec and busy poll timeout.270270+ * If the specified NAPI timeout is bigger than the wait timeout, then adjust271271+ * the NAPI timeout accordingly.270272 */271273void __io_napi_adjust_timeout(struct io_ring_ctx *ctx, struct io_wait_queue *iowq,272274 struct timespec64 *ts)···276274 unsigned int poll_to = READ_ONCE(ctx->napi_busy_poll_to);277275278276 if (ts) {279279- struct timespec64 poll_to_ts = ns_to_timespec64(1000 * (s64)poll_to);277277+ struct timespec64 poll_to_ts;280278281281- if (timespec64_compare(ts, &poll_to_ts) > 0) {282282- *ts = timespec64_sub(*ts, poll_to_ts);283283- } else {284284- u64 to = timespec64_to_ns(ts);285285-286286- do_div(to, 1000);287287- ts->tv_sec = 0;288288- ts->tv_nsec = 0;279279+ poll_to_ts = ns_to_timespec64(1000 * (s64)poll_to);280280+ if (timespec64_compare(ts, &poll_to_ts) < 0) {281281+ s64 poll_to_ns = timespec64_to_ns(ts);282282+ if (poll_to_ns > 0) {283283+ u64 val = poll_to_ns + 999;284284+ do_div(val, (s64) 1000);285285+ poll_to = val;286286+ }289287 }290288 }291289
+4
io_uring/register.c
···355355 }356356357357 if (sqd) {358358+ mutex_unlock(&ctx->uring_lock);358359 mutex_unlock(&sqd->lock);359360 io_put_sq_data(sqd);361361+ mutex_lock(&ctx->uring_lock);360362 }361363362364 if (copy_to_user(arg, new_count, sizeof(new_count)))···382380 return 0;383381err:384382 if (sqd) {383383+ mutex_unlock(&ctx->uring_lock);385384 mutex_unlock(&sqd->lock);386385 io_put_sq_data(sqd);386386+ mutex_lock(&ctx->uring_lock);387387 }388388 return ret;389389}
+13
kernel/events/core.c
···53845384again:53855385 mutex_lock(&event->child_mutex);53865386 list_for_each_entry(child, &event->child_list, child_list) {53875387+ void *var = NULL;5387538853885389 /*53895390 * Cannot change, child events are not migrated, see the···54255424 * this can't be the last reference.54265425 */54275426 put_event(event);54275427+ } else {54285428+ var = &ctx->refcount;54285429 }5429543054305431 mutex_unlock(&event->child_mutex);54315432 mutex_unlock(&ctx->mutex);54325433 put_ctx(ctx);54345434+54355435+ if (var) {54365436+ /*54375437+ * If perf_event_free_task() has deleted all events from the54385438+ * ctx while the child_mutex got released above, make sure to54395439+ * notify about the preceding put_ctx().54405440+ */54415441+ smp_mb(); /* pairs with wait_var_event() */54425442+ wake_up_var(var);54435443+ }54335444 goto again;54345445 }54355446 mutex_unlock(&event->child_mutex);
+1-1
mm/filemap.c
···10001000 do {10011001 cpuset_mems_cookie = read_mems_allowed_begin();10021002 n = cpuset_mem_spread_node();10031003- folio = __folio_alloc_node(gfp, order, n);10031003+ folio = __folio_alloc_node_noprof(gfp, order, n);10041004 } while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));1005100510061006 return folio;
···57685768 * do_exit() will not see it, and will keep the reservation57695769 * forever.57705770 */57715771- if (adjust_reservation && vma_needs_reservation(h, vma, address))57725772- vma_add_reservation(h, vma, address);57715771+ if (adjust_reservation) {57725772+ int rc = vma_needs_reservation(h, vma, address);57735773+57745774+ if (rc < 0)57755775+ /* Pressumably allocate_file_region_entries failed57765776+ * to allocate a file_region struct. Clear57775777+ * hugetlb_restore_reserve so that global reserve57785778+ * count will not be incremented by free_huge_folio.57795779+ * Act as if we consumed the reservation.57805780+ */57815781+ folio_clear_hugetlb_restore_reserve(page_folio(page));57825782+ else if (rc)57835783+ vma_add_reservation(h, vma, address);57845784+ }5773578557745786 tlb_remove_page_size(tlb, page, huge_page_size(h));57755787 /*
+11-4
mm/kmsan/core.c
···196196 u32 origin, bool checked)197197{198198 u64 address = (u64)addr;199199- void *shadow_start;200200- u32 *origin_start;199199+ u32 *shadow_start, *origin_start;201200 size_t pad = 0;202201203202 KMSAN_WARN_ON(!kmsan_metadata_is_contiguous(addr, size));···224225 origin_start =225226 (u32 *)kmsan_get_metadata((void *)address, KMSAN_META_ORIGIN);226227227227- for (int i = 0; i < size / KMSAN_ORIGIN_SIZE; i++)228228- origin_start[i] = origin;228228+ /*229229+ * If the new origin is non-zero, assume that the shadow byte is also non-zero,230230+ * and unconditionally overwrite the old origin slot.231231+ * If the new origin is zero, overwrite the old origin slot iff the232232+ * corresponding shadow slot is zero.233233+ */234234+ for (int i = 0; i < size / KMSAN_ORIGIN_SIZE; i++) {235235+ if (origin || !shadow_start[i])236236+ origin_start[i] = origin;237237+ }229238}230239231240struct page *kmsan_vmalloc_to_page_or_null(void *vaddr)
+7-10
mm/ksm.c
···296296static bool ksm_smart_scan = true;297297298298/* The number of zero pages which is placed by KSM */299299-unsigned long ksm_zero_pages;299299+atomic_long_t ksm_zero_pages = ATOMIC_LONG_INIT(0);300300301301/* The number of pages that have been skipped due to "smart scanning" */302302static unsigned long ksm_pages_skipped;···14291429 * the dirty bit in zero page's PTE is set.14301430 */14311431 newpte = pte_mkdirty(pte_mkspecial(pfn_pte(page_to_pfn(kpage), vma->vm_page_prot)));14321432- ksm_zero_pages++;14331433- mm->ksm_zero_pages++;14321432+ ksm_map_zero_page(mm);14341433 /*14351434 * We're replacing an anonymous page with a zero page, which is14361435 * not anonymous. We need to do proper accounting otherwise we···27532754{27542755 struct ksm_rmap_item *rmap_item;27552756 struct page *page;27562756- unsigned int npages = scan_npages;2757275727582758- while (npages-- && likely(!freezing(current))) {27582758+ while (scan_npages-- && likely(!freezing(current))) {27592759 cond_resched();27602760 rmap_item = scan_get_next_rmap_item(&page);27612761 if (!rmap_item)27622762 return;27632763 cmp_and_merge_page(page, rmap_item);27642764 put_page(page);27652765+ ksm_pages_scanned++;27652766 }27662766-27672767- ksm_pages_scanned += scan_npages - npages;27682767}2769276827702769static int ksmd_should_run(void)···33733376#ifdef CONFIG_PROC_FS33743377long ksm_process_profit(struct mm_struct *mm)33753378{33763376- return (long)(mm->ksm_merging_pages + mm->ksm_zero_pages) * PAGE_SIZE -33793379+ return (long)(mm->ksm_merging_pages + mm_ksm_zero_pages(mm)) * PAGE_SIZE -33773380 mm->ksm_rmap_items * sizeof(struct ksm_rmap_item);33783381}33793382#endif /* CONFIG_PROC_FS */···36623665static ssize_t ksm_zero_pages_show(struct kobject *kobj,36633666 struct kobj_attribute *attr, char *buf)36643667{36653665- return sysfs_emit(buf, "%ld\n", ksm_zero_pages);36683668+ return sysfs_emit(buf, "%ld\n", atomic_long_read(&ksm_zero_pages));36663669}36673670KSM_ATTR_RO(ksm_zero_pages);36683671···36713674{36723675 long general_profit;3673367636743674- general_profit = (ksm_pages_sharing + ksm_zero_pages) * PAGE_SIZE -36773677+ general_profit = (ksm_pages_sharing + atomic_long_read(&ksm_zero_pages)) * PAGE_SIZE -36753678 ksm_rmap_items * sizeof(struct ksm_rmap_item);3676367936773680 return sysfs_emit(buf, "%ld\n", general_profit);
+4
mm/memblock.c
···13391339 int start_rgn, end_rgn;13401340 int i, ret;1341134113421342+ if (WARN_ONCE(nid == MAX_NUMNODES,13431343+ "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))13441344+ nid = NUMA_NO_NODE;13451345+13421346 ret = memblock_isolate_range(type, base, size, &start_rgn, &end_rgn);13431347 if (ret)13441348 return ret;
···273273{274274 mempool_t *pool;275275276276- pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id);276276+ pool = kmalloc_node_noprof(sizeof(*pool), gfp_mask | __GFP_ZERO, node_id);277277 if (!pool)278278 return NULL;279279
+34-16
mm/page_alloc.c
···19551955}1956195619571957/*19581958- * Reserve a pageblock for exclusive use of high-order atomic allocations if19591959- * there are no empty page blocks that contain a page with a suitable order19581958+ * Reserve the pageblock(s) surrounding an allocation request for19591959+ * exclusive use of high-order atomic allocations if there are no19601960+ * empty page blocks that contain a page with a suitable order19601961 */19611961-static void reserve_highatomic_pageblock(struct page *page, struct zone *zone)19621962+static void reserve_highatomic_pageblock(struct page *page, int order,19631963+ struct zone *zone)19621964{19631965 int mt;19641966 unsigned long max_managed, flags;···19861984 /* Yoink! */19871985 mt = get_pageblock_migratetype(page);19881986 /* Only reserve normal pageblocks (i.e., they can merge with others) */19891989- if (migratetype_is_mergeable(mt))19901990- if (move_freepages_block(zone, page, mt,19911991- MIGRATE_HIGHATOMIC) != -1)19921992- zone->nr_reserved_highatomic += pageblock_nr_pages;19871987+ if (!migratetype_is_mergeable(mt))19881988+ goto out_unlock;19891989+19901990+ if (order < pageblock_order) {19911991+ if (move_freepages_block(zone, page, mt, MIGRATE_HIGHATOMIC) == -1)19921992+ goto out_unlock;19931993+ zone->nr_reserved_highatomic += pageblock_nr_pages;19941994+ } else {19951995+ change_pageblock_range(page, order, MIGRATE_HIGHATOMIC);19961996+ zone->nr_reserved_highatomic += 1 << order;19971997+ }1993199819941999out_unlock:19952000 spin_unlock_irqrestore(&zone->lock, flags);···20081999 * intense memory pressure but failed atomic allocations should be easier20092000 * to recover from than an OOM.20102001 *20112011- * If @force is true, try to unreserve a pageblock even though highatomic20022002+ * If @force is true, try to unreserve pageblocks even though highatomic20122003 * pageblock is exhausted.20132004 */20142005static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,···20502041 * adjust the count once.20512042 */20522043 if (is_migrate_highatomic(mt)) {20442044+ unsigned long size;20532045 /*20542046 * It should never happen but changes to20552047 * locking could inadvertently allow a per-cpu···20582048 * while unreserving so be safe and watch for20592049 * underflows.20602050 */20612061- zone->nr_reserved_highatomic -= min(20622062- pageblock_nr_pages,20632063- zone->nr_reserved_highatomic);20512051+ size = max(pageblock_nr_pages, 1UL << order);20522052+ size = min(size, zone->nr_reserved_highatomic);20532053+ zone->nr_reserved_highatomic -= size;20642054 }2065205520662056 /*···20722062 * of pageblocks that cannot be completely freed20732063 * may increase.20742064 */20752075- ret = move_freepages_block(zone, page, mt,20762076- ac->migratetype);20652065+ if (order < pageblock_order)20662066+ ret = move_freepages_block(zone, page, mt,20672067+ ac->migratetype);20682068+ else {20692069+ move_to_free_list(page, zone, order, mt,20702070+ ac->migratetype);20712071+ change_pageblock_range(page, order,20722072+ ac->migratetype);20732073+ ret = 1;20742074+ }20772075 /*20782078- * Reserving this block already succeeded, so this should20792079- * not fail on zone boundaries.20762076+ * Reserving the block(s) already succeeded,20772077+ * so this should not fail on zone boundaries.20802078 */20812079 WARN_ON_ONCE(ret == -1);20822080 if (ret > 0) {···34243406 * if the pageblock should be reserved for the future34253407 */34263408 if (unlikely(alloc_flags & ALLOC_HIGHATOMIC))34273427- reserve_highatomic_pageblock(page, zone);34093409+ reserve_highatomic_pageblock(page, order, zone);3428341034293411 return page;34303412 } else {
···722722 * and fall back on vmalloc() if that fails. Others723723 * just put it in the vmalloc space.724724 */725725-#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)725725+#if defined(CONFIG_EXECMEM) && defined(MODULES_VADDR)726726 unsigned long addr = (unsigned long)kasan_reset_tag(x);727727 if (addr >= MODULES_VADDR && addr < MODULES_END)728728 return 1;
···40114011 status = L2CAP_CS_AUTHOR_PEND;40124012 chan->ops->defer(chan);40134013 } else {40144014- l2cap_state_change(chan, BT_CONNECT2);40154015- result = L2CAP_CR_PEND;40144014+ l2cap_state_change(chan, BT_CONFIG);40154015+ result = L2CAP_CR_SUCCESS;40164016 status = L2CAP_CS_NO_INFO;40174017 }40184018 } else {···4647464746484648 memset(&rsp, 0, sizeof(rsp));4649464946504650- if (max > hcon->le_conn_max_interval) {46514651- BT_DBG("requested connection interval exceeds current bounds.");46524652- err = -EINVAL;46534653- } else {46544654- err = hci_check_conn_params(min, max, latency, to_multiplier);46554655- }46564656-46504650+ err = hci_check_conn_params(min, max, latency, to_multiplier);46574651 if (err)46584652 rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);46594653 else
+6-7
net/bridge/br_mst.c
···7373}7474EXPORT_SYMBOL_GPL(br_mst_get_state);75757676-static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,7676+static void br_mst_vlan_set_state(struct net_bridge_vlan_group *vg,7777+ struct net_bridge_vlan *v,7778 u8 state)7879{7979- struct net_bridge_vlan_group *vg = nbp_vlan_group(p);8080-8180 if (br_vlan_get_state(v) == state)8281 return;8382···102103 int err = 0;103104104105 rcu_read_lock();105105- vg = nbp_vlan_group(p);106106+ vg = nbp_vlan_group_rcu(p);106107 if (!vg)107108 goto out;108109···120121 if (v->brvlan->msti != msti)121122 continue;122123123123- br_mst_vlan_set_state(p, v, state);124124+ br_mst_vlan_set_state(vg, v, state);124125 }125126126127out:···139140 * it.140141 */141142 if (v != pv && v->brvlan->msti == msti) {142142- br_mst_vlan_set_state(pv->port, pv, v->state);143143+ br_mst_vlan_set_state(vg, pv, v->state);143144 return;144145 }145146 }146147147148 /* Otherwise, start out in a new MSTI with all ports disabled. */148148- return br_mst_vlan_set_state(pv->port, pv, BR_STATE_DISABLED);149149+ return br_mst_vlan_set_state(vg, pv, BR_STATE_DISABLED);149150}150151151152int br_mst_vlan_set_msti(struct net_bridge_vlan *mv, u16 msti)
+5-1
net/ipv4/tcp_timer.c
···481481{482482 const struct tcp_sock *tp = tcp_sk(sk);483483 const int timeout = TCP_RTO_MAX * 2;484484- u32 rcv_delta;484484+ s32 rcv_delta;485485486486+ /* Note: timer interrupt might have been delayed by at least one jiffy,487487+ * and tp->rcv_tstamp might very well have been written recently.488488+ * rcv_delta can thus be negative.489489+ */486490 rcv_delta = inet_csk(sk)->icsk_timeout - tp->rcv_tstamp;487491 if (rcv_delta <= timeout)488492 return false;
···11721172 .len = IPSET_MAXNAMELEN - 1 },11731173};1174117411751175-static void11761176-ip_set_destroy_set(struct ip_set *set)11771177-{11781178- pr_debug("set: %s\n", set->name);11791179-11801180- /* Must call it without holding any lock */11811181- set->variant->destroy(set);11821182- module_put(set->type->me);11831183- kfree(set);11841184-}11751175+/* In order to return quickly when destroying a single set, it is split11761176+ * into two stages:11771177+ * - Cancel garbage collector11781178+ * - Destroy the set itself via call_rcu()11791179+ */1185118011861181static void11871182ip_set_destroy_set_rcu(struct rcu_head *head)11881183{11891184 struct ip_set *set = container_of(head, struct ip_set, rcu);1190118511911191- ip_set_destroy_set(set);11861186+ set->variant->destroy(set);11871187+ module_put(set->type->me);11881188+ kfree(set);11891189+}11901190+11911191+static void11921192+_destroy_all_sets(struct ip_set_net *inst)11931193+{11941194+ struct ip_set *set;11951195+ ip_set_id_t i;11961196+ bool need_wait = false;11971197+11981198+ /* First cancel gc's: set:list sets are flushed as well */11991199+ for (i = 0; i < inst->ip_set_max; i++) {12001200+ set = ip_set(inst, i);12011201+ if (set) {12021202+ set->variant->cancel_gc(set);12031203+ if (set->type->features & IPSET_TYPE_NAME)12041204+ need_wait = true;12051205+ }12061206+ }12071207+ /* Must wait for flush to be really finished */12081208+ if (need_wait)12091209+ rcu_barrier();12101210+ for (i = 0; i < inst->ip_set_max; i++) {12111211+ set = ip_set(inst, i);12121212+ if (set) {12131213+ ip_set(inst, i) = NULL;12141214+ set->variant->destroy(set);12151215+ module_put(set->type->me);12161216+ kfree(set);12171217+ }12181218+ }11921219}1193122011941221static int ip_set_destroy(struct sk_buff *skb, const struct nfnl_info *info,···12291202 if (unlikely(protocol_min_failed(attr)))12301203 return -IPSET_ERR_PROTOCOL;1231120412321232-12331205 /* Commands are serialized and references are12341206 * protected by the ip_set_ref_lock.12351207 * External systems (i.e. xt_set) must call12361236- * ip_set_put|get_nfnl_* functions, that way we12081208+ * ip_set_nfnl_get_* functions, that way we12371209 * can safely check references here.12381210 *12391211 * list:set timer can only decrement the reference···12401214 * without holding the lock.12411215 */12421216 if (!attr[IPSET_ATTR_SETNAME]) {12431243- /* Must wait for flush to be really finished in list:set */12441244- rcu_barrier();12451217 read_lock_bh(&ip_set_ref_lock);12461218 for (i = 0; i < inst->ip_set_max; i++) {12471219 s = ip_set(inst, i);···12501226 }12511227 inst->is_destroyed = true;12521228 read_unlock_bh(&ip_set_ref_lock);12531253- for (i = 0; i < inst->ip_set_max; i++) {12541254- s = ip_set(inst, i);12551255- if (s) {12561256- ip_set(inst, i) = NULL;12571257- /* Must cancel garbage collectors */12581258- s->variant->cancel_gc(s);12591259- ip_set_destroy_set(s);12601260- }12611261- }12291229+ _destroy_all_sets(inst);12621230 /* Modified by ip_set_destroy() only, which is serialized */12631231 inst->is_destroyed = false;12641232 } else {···12711255 features = s->type->features;12721256 ip_set(inst, i) = NULL;12731257 read_unlock_bh(&ip_set_ref_lock);12581258+ /* Must cancel garbage collectors */12591259+ s->variant->cancel_gc(s);12741260 if (features & IPSET_TYPE_NAME) {12751261 /* Must wait for flush to be really finished */12761262 rcu_barrier();12771263 }12781278- /* Must cancel garbage collectors */12791279- s->variant->cancel_gc(s);12801264 call_rcu(&s->rcu, ip_set_destroy_set_rcu);12811265 }12821266 return 0;···23812365}2382236623832367static void __net_exit23682368+ip_set_net_pre_exit(struct net *net)23692369+{23702370+ struct ip_set_net *inst = ip_set_pernet(net);23712371+23722372+ inst->is_deleted = true; /* flag for ip_set_nfnl_put */23732373+}23742374+23752375+static void __net_exit23842376ip_set_net_exit(struct net *net)23852377{23862378 struct ip_set_net *inst = ip_set_pernet(net);2387237923882388- struct ip_set *set = NULL;23892389- ip_set_id_t i;23902390-23912391- inst->is_deleted = true; /* flag for ip_set_nfnl_put */23922392-23932393- nfnl_lock(NFNL_SUBSYS_IPSET);23942394- for (i = 0; i < inst->ip_set_max; i++) {23952395- set = ip_set(inst, i);23962396- if (set) {23972397- ip_set(inst, i) = NULL;23982398- set->variant->cancel_gc(set);23992399- ip_set_destroy_set(set);24002400- }24012401- }24022402- nfnl_unlock(NFNL_SUBSYS_IPSET);23802380+ _destroy_all_sets(inst);24032381 kvfree(rcu_dereference_protected(inst->ip_set_list, 1));24042382}2405238324062384static struct pernet_operations ip_set_net_ops = {24072385 .init = ip_set_net_init,23862386+ .pre_exit = ip_set_net_pre_exit,24082387 .exit = ip_set_net_exit,24092388 .id = &ip_set_net_id,24102389 .size = sizeof(struct ip_set_net),
+14-16
net/netfilter/ipset/ip_set_list_set.c
···7979 struct set_elem *e;8080 int ret;81818282- list_for_each_entry(e, &map->members, list) {8282+ list_for_each_entry_rcu(e, &map->members, list) {8383 if (SET_WITH_TIMEOUT(set) &&8484 ip_set_timeout_expired(ext_timeout(e, set)))8585 continue;···9999 struct set_elem *e;100100 int ret;101101102102- list_for_each_entry(e, &map->members, list) {102102+ list_for_each_entry_rcu(e, &map->members, list) {103103 if (SET_WITH_TIMEOUT(set) &&104104 ip_set_timeout_expired(ext_timeout(e, set)))105105 continue;···188188 struct list_set *map = set->data;189189 struct set_adt_elem *d = value;190190 struct set_elem *e, *next, *prev = NULL;191191- int ret;191191+ int ret = 0;192192193193- list_for_each_entry(e, &map->members, list) {193193+ rcu_read_lock();194194+ list_for_each_entry_rcu(e, &map->members, list) {194195 if (SET_WITH_TIMEOUT(set) &&195196 ip_set_timeout_expired(ext_timeout(e, set)))196197 continue;···202201203202 if (d->before == 0) {204203 ret = 1;204204+ goto out;205205 } else if (d->before > 0) {206206 next = list_next_entry(e, list);207207 ret = !list_is_last(&e->list, &map->members) &&···210208 } else {211209 ret = prev && prev->id == d->refid;212210 }213213- return ret;211211+ goto out;214212 }215215- return 0;213213+out:214214+ rcu_read_unlock();215215+ return ret;216216}217217218218static void···243239244240 /* Find where to add the new entry */245241 n = prev = next = NULL;246246- list_for_each_entry(e, &map->members, list) {242242+ list_for_each_entry_rcu(e, &map->members, list) {247243 if (SET_WITH_TIMEOUT(set) &&248244 ip_set_timeout_expired(ext_timeout(e, set)))249245 continue;···320316{321317 struct list_set *map = set->data;322318 struct set_adt_elem *d = value;323323- struct set_elem *e, *next, *prev = NULL;319319+ struct set_elem *e, *n, *next, *prev = NULL;324320325325- list_for_each_entry(e, &map->members, list) {321321+ list_for_each_entry_safe(e, n, &map->members, list) {326322 if (SET_WITH_TIMEOUT(set) &&327323 ip_set_timeout_expired(ext_timeout(e, set)))328324 continue;···428424list_set_destroy(struct ip_set *set)429425{430426 struct list_set *map = set->data;431431- struct set_elem *e, *n;432427433433- list_for_each_entry_safe(e, n, &map->members, list) {434434- list_del(&e->list);435435- ip_set_put_byindex(map->net, e->id);436436- ip_set_ext_destroy(set, e);437437- kfree(e);438438- }428428+ WARN_ON_ONCE(!list_empty(&map->members));439429 kfree(map);440430441431 set->data = NULL;
+3
net/netfilter/nft_meta.c
···839839 struct nft_meta *priv = nft_expr_priv(expr);840840 unsigned int len;841841842842+ if (!tb[NFTA_META_KEY] || !tb[NFTA_META_DREG])843843+ return -EINVAL;844844+842845 priv->key = ntohl(nla_get_be32(tb[NFTA_META_KEY]));843846 switch (priv->key) {844847 case NFT_META_PROTOCOL:
+4
net/netfilter/nft_payload.c
···650650 struct nft_payload *priv = nft_expr_priv(expr);651651 u32 base;652652653653+ if (!tb[NFTA_PAYLOAD_BASE] || !tb[NFTA_PAYLOAD_OFFSET] ||654654+ !tb[NFTA_PAYLOAD_LEN] || !tb[NFTA_PAYLOAD_DREG])655655+ return -EINVAL;656656+653657 base = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));654658 switch (base) {655659 case NFT_PAYLOAD_TUN_HEADER:
···18751875 offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base;18761876 maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages);18771877 /* slack space should prevent this ever happening: */18781878- if (unlikely(snd_buf->len > snd_buf->buflen))18781878+ if (unlikely(snd_buf->len > snd_buf->buflen)) {18791879+ status = -EIO;18791880 goto wrap_failed;18811881+ }18801882 /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was18811883 * done anyway, so it's safe to put the request on the wire: */18821884 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
···11cat <<EOF22/**33 * ${class}${atomicname}() - atomic subtract and test if zero with ${desc_order} ordering44- * @i: ${int} value to add44+ * @i: ${int} value to subtract55 * @v: pointer to ${atomic}_t66 *77 * Atomically updates @v to (@v - @i) with ${desc_order} ordering.
-13
scripts/kconfig/confdata.c
···533533 */534534 if (sym->visible == no && !conf_unsaved)535535 sym->flags &= ~SYMBOL_DEF_USER;536536- switch (sym->type) {537537- case S_STRING:538538- case S_INT:539539- case S_HEX:540540- /* Reset a string value if it's out of range */541541- if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))542542- break;543543- sym->flags &= ~SYMBOL_VALID;544544- conf_unsaved++;545545- break;546546- default:547547- break;548548- }549536 }550537 }551538
···398398 dep = expr_transform(dep);399399 dep = expr_alloc_and(expr_copy(basedep), dep);400400 dep = expr_eliminate_dups(dep);401401- if (menu->sym && menu->sym->type != S_TRISTATE)402402- dep = expr_trans_bool(dep);403401 prop->visible.expr = dep;404402405403 /*
+1-1
scripts/link-vmlinux.sh
···193193mksysmap()194194{195195 info NM ${2}196196- ${NM} -n "${1}" | "${srctree}/scripts/mksysmap" > "${2}"196196+ ${NM} -n "${1}" | sed -f "${srctree}/scripts/mksysmap" > "${2}"197197}198198199199sorttable()
+3-2
scripts/mod/modpost.c
···16471647 namespace = get_next_modinfo(&info, "import_ns",16481648 namespace);16491649 }16501650+16511651+ if (extra_warn && !get_modinfo(&info, "description"))16521652+ warn("missing MODULE_DESCRIPTION() in %s\n", modname);16501653 }1651165416521652- if (extra_warn && !get_modinfo(&info, "description"))16531653- warn("missing MODULE_DESCRIPTION() in %s\n", modname);16541655 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {16551656 symname = remove_dot(info.strtab + sym->st_name);16561657
···170170 * CPU is not affected by Branch171171 * History Injection.172172 */173173+#define ARCH_CAP_XAPIC_DISABLE BIT(21) /*174174+ * IA32_XAPIC_DISABLE_STATUS MSR175175+ * supported176176+ */173177#define ARCH_CAP_PBRSB_NO BIT(24) /*174178 * Not susceptible to Post-Barrier175179 * Return Stack Buffer Predictions.···194190#define ARCH_CAP_RFDS_CLEAR BIT(28) /*195191 * VERW clears CPU Register196192 * File.197197- */198198-199199-#define ARCH_CAP_XAPIC_DISABLE BIT(21) /*200200- * IA32_XAPIC_DISABLE_STATUS MSR201201- * supported202193 */203194204195#define MSR_IA32_FLUSH_CMD 0x0000010b
+20-2
tools/arch/x86/include/uapi/asm/kvm.h
···457457458458#define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001459459460460-/* attributes for system fd (group 0) */461461-#define KVM_X86_XCOMP_GUEST_SUPP 0460460+/* vendor-independent attributes for system fd (group 0) */461461+#define KVM_X86_GRP_SYSTEM 0462462+# define KVM_X86_XCOMP_GUEST_SUPP 0463463+464464+/* vendor-specific groups and attributes for system fd */465465+#define KVM_X86_GRP_SEV 1466466+# define KVM_X86_SEV_VMSA_FEATURES 0462467463468struct kvm_vmx_nested_state_data {464469 __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];···694689 /* Guest Migration Extension */695690 KVM_SEV_SEND_CANCEL,696691692692+ /* Second time is the charm; improved versions of the above ioctls. */693693+ KVM_SEV_INIT2,694694+697695 KVM_SEV_NR_MAX,698696};699697···706698 __u64 data;707699 __u32 error;708700 __u32 sev_fd;701701+};702702+703703+struct kvm_sev_init {704704+ __u64 vmsa_features;705705+ __u32 flags;706706+ __u16 ghcb_version;707707+ __u16 pad1;708708+ __u32 pad2[8];709709};710710711711struct kvm_sev_launch_start {···872856873857#define KVM_X86_DEFAULT_VM 0874858#define KVM_X86_SW_PROTECTED_VM 1859859+#define KVM_X86_SEV_VM 2860860+#define KVM_X86_SEV_ES_VM 3875861876862#endif /* _ASM_X86_KVM_H */
+4-1
tools/include/uapi/asm-generic/unistd.h
···842842#define __NR_lsm_list_modules 461843843__SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules)844844845845+#define __NR_mseal 462846846+__SYSCALL(__NR_mseal, sys_mseal)847847+845848#undef __NR_syscalls846846-#define __NR_syscalls 462849849+#define __NR_syscalls 463847850848851/*849852 * 32 bit systems traditionally used different
+28-3
tools/include/uapi/drm/i915_drm.h
···806806 */807807#define I915_PARAM_PXP_STATUS 58808808809809+/*810810+ * Query if kernel allows marking a context to send a Freq hint to SLPC. This811811+ * will enable use of the strategies allowed by the SLPC algorithm.812812+ */813813+#define I915_PARAM_HAS_CONTEXT_FREQ_HINT 59814814+809815/* Must be kept compact -- no holes and well documented */810816811817/**···21542148 * -EIO: The firmware did not succeed in creating the protected context.21552149 */21562150#define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd21512151+21522152+/*21532153+ * I915_CONTEXT_PARAM_LOW_LATENCY:21542154+ *21552155+ * Mark this context as a low latency workload which requires aggressive GT21562156+ * frequency scaling. Use I915_PARAM_HAS_CONTEXT_FREQ_HINT to check if the kernel21572157+ * supports this per context flag.21582158+ */21592159+#define I915_CONTEXT_PARAM_LOW_LATENCY 0xe21572160/* Must be kept compact -- no holes and well documented */2158216121592162 /** @value: Context parameter value to be set or queried */···26382623 *26392624 */2640262526262626+/*26272627+ * struct drm_i915_reset_stats - Return global reset and other context stats26282628+ *26292629+ * Driver keeps few stats for each contexts and also global reset count.26302630+ * This struct can be used to query those stats.26312631+ */26412632struct drm_i915_reset_stats {26332633+ /** @ctx_id: ID of the requested context */26422634 __u32 ctx_id;26352635+26362636+ /** @flags: MBZ */26432637 __u32 flags;2644263826452645- /* All resets since boot/module reload, for all contexts */26392639+ /** @reset_count: All resets since boot/module reload, for all contexts */26462640 __u32 reset_count;2647264126482648- /* Number of batches lost when active in GPU, for this context */26422642+ /** @batch_active: Number of batches lost when active in GPU, for this context */26492643 __u32 batch_active;2650264426512651- /* Number of batches lost pending for execution, for this context */26452645+ /** @batch_pending: Number of batches lost pending for execution, for this context */26522646 __u32 batch_pending;2653264726482648+ /** @pad: MBZ */26542649 __u32 pad;26552650};26562651
+2-2
tools/include/uapi/linux/kvm.h
···12211221/* Available with KVM_CAP_SPAPR_RESIZE_HPT */12221222#define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)12231223#define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)12241224-/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_MMU_HASH_V3 */12241224+/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */12251225#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)12261226-/* Available with KVM_CAP_PPC_RADIX_MMU */12261226+/* Available with KVM_CAP_PPC_MMU_RADIX */12271227#define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)12281228/* Available with KVM_CAP_PPC_GET_CPU_CHAR */12291229#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
+3-1
tools/include/uapi/linux/stat.h
···126126 __u64 stx_mnt_id;127127 __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */128128 __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */129129+ __u64 stx_subvol; /* Subvolume identifier */129130 /* 0xa0 */130130- __u64 __spare3[12]; /* Spare space for future expansion */131131+ __u64 __spare3[11]; /* Spare space for future expansion */131132 /* 0x100 */132133};133134···156155#define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */157156#define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */158157#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */158158+#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */159159160160#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */161161
···548548459 common lsm_get_self_attr sys_lsm_get_self_attr549549460 common lsm_set_self_attr sys_lsm_set_self_attr550550461 common lsm_list_modules sys_lsm_list_modules551551+462 common mseal sys_mseal
+1
tools/perf/arch/s390/entry/syscalls/syscall.tbl
···464464459 common lsm_get_self_attr sys_lsm_get_self_attr sys_lsm_get_self_attr465465460 common lsm_set_self_attr sys_lsm_set_self_attr sys_lsm_set_self_attr466466461 common lsm_list_modules sys_lsm_list_modules sys_lsm_list_modules467467+462 common mseal sys_mseal sys_mseal
+2-1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
···374374450 common set_mempolicy_home_node sys_set_mempolicy_home_node375375451 common cachestat sys_cachestat376376452 common fchmodat2 sys_fchmodat2377377-453 64 map_shadow_stack sys_map_shadow_stack377377+453 common map_shadow_stack sys_map_shadow_stack378378454 common futex_wake sys_futex_wake379379455 common futex_wait sys_futex_wait380380456 common futex_requeue sys_futex_requeue···383383459 common lsm_get_self_attr sys_lsm_get_self_attr384384460 common lsm_set_self_attr sys_lsm_set_self_attr385385461 common lsm_list_modules sys_lsm_list_modules386386+462 common mseal sys_mseal386387387388#388389# Due to a historical design error, certain syscalls are numbered differently
+2-4
tools/perf/builtin-record.c
···1956195619571957 if (count.lost) {19581958 if (!lost) {19591959- lost = zalloc(sizeof(*lost) +19601960- session->machines.host.id_hdr_size);19591959+ lost = zalloc(PERF_SAMPLE_MAX_SIZE);19611960 if (!lost) {19621961 pr_debug("Memory allocation failed\n");19631962 return;···19721973 lost_count = perf_bpf_filter__lost_count(evsel);19731974 if (lost_count) {19741975 if (!lost) {19751975- lost = zalloc(sizeof(*lost) +19761976- session->machines.host.id_hdr_size);19761976+ lost = zalloc(PERF_SAMPLE_MAX_SIZE);19771977 if (!lost) {19781978 pr_debug("Memory allocation failed\n");19791979 return;
···99#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)10101111/*1212+ * Request nofications on a directory.1313+ * See below for events that may be notified.1414+ */1515+#define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2)1616+1717+#define F_DUPFD_QUERY (F_LINUX_SPECIFIC_BASE + 3)1818+1919+/*1220 * Cancel a blocking posix lock; internal use only until we expose an1321 * asynchronous lock api to userspace:1422 */···24162517/* Create a file descriptor with FD_CLOEXEC set. */2618#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)2727-2828-/*2929- * Request nofications on a directory.3030- * See below for events that may be notified.3131- */3232-#define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2)33193420/*3521 * Set and get of pipe page size array