···5566Linux kernel developers take security very seriously. As such, we'd77like to know when a security bug is found so that it can be fixed and88-disclosed as quickly as possible. Please report security bugs to the99-Linux kernel security team.88+disclosed as quickly as possible.99+1010+Preparing your report1111+---------------------1212+1313+Like with any bug report, a security bug report requires a lot of analysis work1414+from the developers, so the more information you can share about the issue, the1515+better. Please review the procedure outlined in1616+Documentation/admin-guide/reporting-issues.rst if you are unclear about what1717+information is helpful. The following information are absolutely necessary in1818+**any** security bug report:1919+2020+ * **affected kernel version range**: with no version indication, your report2121+ will not be processed. A significant part of reports are for bugs that2222+ have already been fixed, so it is extremely important that vulnerabilities2323+ are verified on recent versions (development tree or latest stable2424+ version), at least by verifying that the code has not changed since the2525+ version where it was detected.2626+2727+ * **description of the problem**: a detailed description of the problem, with2828+ traces showing its manifestation, and why you consider that the observed2929+ behavior as a problem in the kernel, is necessary.3030+3131+ * **reproducer**: developers will need to be able to reproduce the problem to3232+ consider a fix as effective. This includes both a way to trigger the issue3333+ and a way to confirm it happens. A reproducer with low complexity3434+ dependencies will be needed (source code, shell script, sequence of3535+ instructions, file-system image etc). Binary-only executables are not3636+ accepted. Working exploits are extremely helpful and will not be released3737+ without consent from the reporter, unless they are already public. By3838+ definition if an issue cannot be reproduced, it is not exploitable, thus it3939+ is not a security bug.4040+4141+ * **conditions**: if the bug depends on certain configuration options,4242+ sysctls, permissions, timing, code modifications etc, these should be4343+ indicated.4444+4545+In addition, the following information are highly desirable:4646+4747+ * **suspected location of the bug**: the file names and functions where the4848+ bug is suspected to be present are very important, at least to help forward4949+ the report to the appropriate maintainers. When not possible (for example,5050+ "system freezes each time I run this command"), the security team will help5151+ identify the source of the bug.5252+5353+ * **a proposed fix**: bug reporters who have analyzed the cause of a bug in5454+ the source code almost always have an accurate idea on how to fix it,5555+ because they spent a long time studying it and its implications. Proposing5656+ a tested fix will save maintainers a lot of time, even if the fix ends up5757+ not being the right one, because it helps understand the bug. When5858+ proposing a tested fix, please always format it in a way that can be5959+ immediately merged (see Documentation/process/submitting-patches.rst).6060+ This will save some back-and-forth exchanges if it is accepted, and you6161+ will be credited for finding and fixing this issue. Note that in this case6262+ only a ``Signed-off-by:`` tag is needed, without ``Reported-by:`` when the6363+ reporter and author are the same.6464+6565+ * **mitigations**: very often during a bug analysis, some ways of mitigating6666+ the issue appear. It is useful to share them, as they can be helpful to6767+ keep end users protected during the time it takes them to apply the fix.6868+6969+Identifying contacts7070+--------------------7171+7272+The most effective way to report a security bug is to send it directly to the7373+affected subsystem's maintainers and Cc: the Linux kernel security team. Do7474+not send it to a public list at this stage, unless you have good reasons to7575+consider the issue as being public or trivial to discover (e.g. result of a7676+widely available automated vulnerability scanning tool that can be repeated by7777+anyone).7878+7979+If you're sending a report for issues affecting multiple parts in the kernel,8080+even if they're fairly similar issues, please send individual messages (think8181+that maintainers will not all work on the issues at the same time). The only8282+exception is when an issue concerns closely related parts maintained by the8383+exact same subset of maintainers, and these parts are expected to be fixed all8484+at once by the same commit, then it may be acceptable to report them at once.8585+8686+One difficulty for most first-time reporters is to figure the right list of8787+recipients to send a report to. In the Linux kernel, all official maintainers8888+are trusted, so the consequences of accidentally including the wrong maintainer8989+are essentially a bit more noise for that person, i.e. nothing dramatic. As9090+such, a suitable method to figure the list of maintainers (which kernel9191+security officers use) is to rely on the get_maintainer.pl script, tuned to9292+only report maintainers. This script, when passed a file name, will look for9393+its path in the MAINTAINERS file to figure a hierarchical list of relevant9494+maintainers. Calling it a first time with the finest level of filtering will9595+most of the time return a short list of this specific file's maintainers::9696+9797+ $ ./scripts/get_maintainer.pl --no-l --no-r --pattern-depth 1 \9898+ drivers/example.c9999+ Developer One <dev1@example.com> (maintainer:example driver)100100+ Developer Two <dev2@example.org> (maintainer:example driver)101101+102102+These two maintainers should then receive the message. If the command does not103103+return anything, it means the affected file is part of a wider subsystem, so we104104+should be less specific::105105+106106+ $ ./scripts/get_maintainer.pl --no-l --no-r drivers/example.c107107+ Developer One <dev1@example.com> (maintainer:example subsystem)108108+ Developer Two <dev2@example.org> (maintainer:example subsystem)109109+ Developer Three <dev3@example.com> (maintainer:example subsystem [GENERAL])110110+ Developer Four <dev4@example.org> (maintainer:example subsystem [GENERAL])111111+112112+Here, picking the first, most specific ones, is sufficient. When the list is113113+long, it is possible to produce a comma-delimited e-mail address list on a114114+single line suitable for use in the To: field of a mailer like this::115115+116116+ $ ./scripts/get_maintainer.pl --no-tree --no-l --no-r --no-n --m \117117+ --no-git-fallback --no-substatus --no-rolestats --no-multiline \118118+ --pattern-depth 1 drivers/example.c119119+ dev1@example.com, dev2@example.org120120+121121+or this for the wider list::122122+123123+ $ ./scripts/get_maintainer.pl --no-tree --no-l --no-r --no-n --m \124124+ --no-git-fallback --no-substatus --no-rolestats --no-multiline \125125+ drivers/example.c126126+ dev1@example.com, dev2@example.org, dev3@example.com, dev4@example.org127127+128128+If at this point you're still facing difficulties spotting the right129129+maintainers, **and only in this case**, it's possible to send your report to130130+the Linux kernel security team only. Your message will be triaged, and you131131+will receive instructions about whom to contact, if needed. Your message may132132+equally be forwarded as-is to the relevant maintainers.133133+134134+Sending the report135135+------------------136136+137137+Reports are to be sent over e-mail exclusively. Please use a working e-mail138138+address, preferably the same that you want to appear in ``Reported-by`` tags139139+if any. If unsure, send your report to yourself first.1014011141The security team and maintainers almost always require additional12142information beyond what was initially provided in a report and rely on···14818or cannot effectively discuss their findings may be abandoned if the14919communication does not quickly improve.15020151151-As it is with any bug, the more information provided the easier it152152-will be to diagnose and fix. Please review the procedure outlined in153153-'Documentation/admin-guide/reporting-issues.rst' if you are unclear about what154154-information is helpful. Any exploit code is very helpful and will not155155-be released without consent from the reporter unless it has already been156156-made public.157157-2121+The report must be sent to maintainers, with the security team in ``Cc:``.15822The Linux kernel security team can be contacted by email at15923<security@kernel.org>. This is a private list of security officers160160-who will help verify the bug report and develop and release a fix.161161-If you already have a fix, please include it with your report, as162162-that can speed up the process considerably. It is possible that the163163-security team will bring in extra help from area maintainers to164164-understand and fix the security vulnerability.2424+who will help verify the bug report and assist developers working on a fix.2525+It is possible that the security team will bring in extra help from area2626+maintainers to understand and fix the security vulnerability.1652716628Please send **plain text** emails without attachments where possible.16729It is much harder to have a context-quoted discussion about a complex···16442Markdown, HTML and RST formatted reports are particularly frowned upon since16543they're quite hard to read for humans and encourage to use dedicated viewers,16644sometimes online, which by definition is not acceptable for a confidential167167-security report.4545+security report. Note that some mailers tend to mangle formatting of plain4646+text by default, please consult Documentation/process/email-clients.rst for4747+more info.1684816949Disclosure and embargoed information17050------------------------------------
···8080 int srsets; /* Shadow register sets */8181 int package;/* physical package number */8282 unsigned int globalnumber;8383-#ifdef CONFIG_64BIT8483 int vmbits; /* Virtual memory size in bits */8585-#endif8684 void *data; /* Additional data */8785 unsigned int watch_reg_count; /* Number that exist */8886 unsigned int watch_reg_use_cnt; /* Usable by ptrace */
···44#include "libgcc.h"5566/*77- * GCC 7 & older can suboptimally generate __multi3 calls for mips64r6, so for77+ * GCC 9 & older can suboptimally generate __multi3 calls for mips64r6, so for88 * that specific case only we implement that intrinsic here.99 *1010 * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=829811111 */1212-#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPSR6) && (__GNUC__ < 8)1212+#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPSR6) && (__GNUC__ < 10)13131414/* multiply 64-bit values, low 64-bits returned */1515static inline long long notrace dmulu(long long a, long long b)···5151}5252EXPORT_SYMBOL(__multi3);53535454-#endif /* 64BIT && CPU_MIPSR6 && GCC7 */5454+#endif /* 64BIT && CPU_MIPSR6 && GCC9 */
+17-1
arch/mips/loongson64/env.c
···1717#include <linux/dma-map-ops.h>1818#include <linux/export.h>1919#include <linux/libfdt.h>2020+#include <linux/minmax.h>2021#include <linux/pci_ids.h>2222+#include <linux/serial_core.h>2123#include <linux/string_choices.h>2224#include <asm/bootinfo.h>2325#include <loongson.h>···108106109107 is_loongson64g = (read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64G;110108111111- for (i = 0; i < system->nr_uarts; i++) {109109+ for (i = 0; i < min(system->nr_uarts, MAX_UARTS); i++) {112110 uartdev = &system->uarts[i];111111+112112+ /*113113+ * Some firmware does not set nr_uarts properly and passes empty114114+ * items. Ignore them silently.115115+ */116116+ if (uartdev->uart_base == 0)117117+ continue;118118+119119+ /* Our DT only works with UPIO_MEM. */120120+ if (uartdev->iotype != UPIO_MEM) {121121+ pr_warn("Ignore UART 0x%llx with iotype %u passed by firmware\n",122122+ uartdev->uart_base, uartdev->iotype);123123+ continue;124124+ }113125114126 ret = lefi_fixup_fdt_serial(fdt_buf, uartdev->uart_base,115127 uartdev->uartclk);
+2-1
arch/mips/mm/cache.c
···207207{208208 if (IS_ENABLED(CONFIG_CPU_R3000) && cpu_has_3k_cache)209209 r3k_cache_init();210210- if (IS_ENABLED(CONFIG_CPU_R4K_CACHE_TLB) && cpu_has_4k_cache)210210+ if ((IS_ENABLED(CONFIG_CPU_R4K_CACHE_TLB) ||211211+ IS_ENABLED(CONFIG_CPU_SB1)) && cpu_has_4k_cache)211212 r4k_cache_init();212213213214 if (IS_ENABLED(CONFIG_CPU_CAVIUM_OCTEON) && cpu_has_octeon_cache)
+231-56
arch/mips/mm/tlb-r4k.c
···1313#include <linux/sched.h>1414#include <linux/smp.h>1515#include <linux/memblock.h>1616+#include <linux/minmax.h>1617#include <linux/mm.h>1718#include <linux/hugetlb.h>1819#include <linux/export.h>···2524#include <asm/hazards.h>2625#include <asm/mmu_context.h>2726#include <asm/tlb.h>2727+#include <asm/tlbdebug.h>2828#include <asm/tlbex.h>2929#include <asm/tlbmisc.h>3030#include <asm/setup.h>···513511__setup("ntlb=", set_ntlb);514512515513516516-/* Comparison function for EntryHi VPN fields. */517517-static int r4k_vpn_cmp(const void *a, const void *b)514514+/* The start bit position of VPN2 and Mask in EntryHi/PageMask registers. */515515+#define VPN2_SHIFT 13516516+517517+/* Read full EntryHi even with CONFIG_32BIT. */518518+static inline unsigned long long read_c0_entryhi_native(void)518519{519519- long v = *(unsigned long *)a - *(unsigned long *)b;520520- int s = sizeof(long) > sizeof(int) ? sizeof(long) * 8 - 1: 0;521521- return s ? (v != 0) | v >> s : v;520520+ return cpu_has_64bits ? read_c0_entryhi_64() : read_c0_entryhi();521521+}522522+523523+/* Write full EntryHi even with CONFIG_32BIT. */524524+static inline void write_c0_entryhi_native(unsigned long long v)525525+{526526+ if (cpu_has_64bits)527527+ write_c0_entryhi_64(v);528528+ else529529+ write_c0_entryhi(v);530530+}531531+532532+/* TLB entry state for uniquification. */533533+struct tlbent {534534+ unsigned long long wired:1;535535+ unsigned long long global:1;536536+ unsigned long long asid:10;537537+ unsigned long long vpn:51;538538+ unsigned long long pagesz:5;539539+ unsigned long long index:14;540540+};541541+542542+/*543543+ * Comparison function for TLB entry sorting. Place wired entries first,544544+ * then global entries, then order by the increasing VPN/ASID and the545545+ * decreasing page size. This lets us avoid clashes with wired entries546546+ * easily and get entries for larger pages out of the way first.547547+ *548548+ * We could group bits so as to reduce the number of comparisons, but this549549+ * is seldom executed and not performance-critical, so prefer legibility.550550+ */551551+static int r4k_entry_cmp(const void *a, const void *b)552552+{553553+ struct tlbent ea = *(struct tlbent *)a, eb = *(struct tlbent *)b;554554+555555+ if (ea.wired > eb.wired)556556+ return -1;557557+ else if (ea.wired < eb.wired)558558+ return 1;559559+ else if (ea.global > eb.global)560560+ return -1;561561+ else if (ea.global < eb.global)562562+ return 1;563563+ else if (ea.vpn < eb.vpn)564564+ return -1;565565+ else if (ea.vpn > eb.vpn)566566+ return 1;567567+ else if (ea.asid < eb.asid)568568+ return -1;569569+ else if (ea.asid > eb.asid)570570+ return 1;571571+ else if (ea.pagesz > eb.pagesz)572572+ return -1;573573+ else if (ea.pagesz < eb.pagesz)574574+ return 1;575575+ else576576+ return 0;577577+}578578+579579+/*580580+ * Fetch all the TLB entries. Mask individual VPN values retrieved with581581+ * the corresponding page mask and ignoring any 1KiB extension as we'll582582+ * be using 4KiB pages for uniquification.583583+ */584584+static void __ref r4k_tlb_uniquify_read(struct tlbent *tlb_vpns, int tlbsize)585585+{586586+ int start = num_wired_entries();587587+ unsigned long long vpn_mask;588588+ bool global;589589+ int i;590590+591591+ vpn_mask = GENMASK(current_cpu_data.vmbits - 1, VPN2_SHIFT);592592+ vpn_mask |= cpu_has_64bits ? 3ULL << 62 : 1 << 31;593593+594594+ for (i = 0; i < tlbsize; i++) {595595+ unsigned long long entryhi, vpn, mask, asid;596596+ unsigned int pagesz;597597+598598+ write_c0_index(i);599599+ mtc0_tlbr_hazard();600600+ tlb_read();601601+ tlb_read_hazard();602602+603603+ global = !!(read_c0_entrylo0() & ENTRYLO_G);604604+ entryhi = read_c0_entryhi_native();605605+ mask = read_c0_pagemask();606606+607607+ asid = entryhi & cpu_asid_mask(¤t_cpu_data);608608+ vpn = (entryhi & vpn_mask & ~mask) >> VPN2_SHIFT;609609+ pagesz = ilog2((mask >> VPN2_SHIFT) + 1);610610+611611+ tlb_vpns[i].global = global;612612+ tlb_vpns[i].asid = global ? 0 : asid;613613+ tlb_vpns[i].vpn = vpn;614614+ tlb_vpns[i].pagesz = pagesz;615615+ tlb_vpns[i].wired = i < start;616616+ tlb_vpns[i].index = i;617617+ }618618+}619619+620620+/*621621+ * Write unique values to all but the wired TLB entries each, using622622+ * the 4KiB page size. This size might not be supported with R6, but623623+ * EHINV is mandatory for R6, so we won't ever be called in that case.624624+ *625625+ * A sorted table is supplied with any wired entries at the beginning,626626+ * followed by any global entries, and then finally regular entries.627627+ * We start at the VPN and ASID values of zero and only assign user628628+ * addresses, therefore guaranteeing no clash with addresses produced629629+ * by UNIQUE_ENTRYHI. We avoid any VPN values used by wired or global630630+ * entries, by increasing the VPN value beyond the span of such entry.631631+ *632632+ * When a VPN/ASID clash is found with a regular entry we increment the633633+ * ASID instead until no VPN/ASID clash has been found or the ASID space634634+ * has been exhausted, in which case we increase the VPN value beyond635635+ * the span of the largest clashing entry.636636+ *637637+ * We do not need to be concerned about FTLB or MMID configurations as638638+ * those are required to implement the EHINV feature.639639+ */640640+static void __ref r4k_tlb_uniquify_write(struct tlbent *tlb_vpns, int tlbsize)641641+{642642+ unsigned long long asid, vpn, vpn_size, pagesz;643643+ int widx, gidx, idx, sidx, lidx, i;644644+645645+ vpn_size = 1ULL << (current_cpu_data.vmbits - VPN2_SHIFT);646646+ pagesz = ilog2((PM_4K >> VPN2_SHIFT) + 1);647647+648648+ write_c0_pagemask(PM_4K);649649+ write_c0_entrylo0(0);650650+ write_c0_entrylo1(0);651651+652652+ asid = 0;653653+ vpn = 0;654654+ widx = 0;655655+ gidx = 0;656656+ for (sidx = 0; sidx < tlbsize && tlb_vpns[sidx].wired; sidx++)657657+ ;658658+ for (lidx = sidx; lidx < tlbsize && tlb_vpns[lidx].global; lidx++)659659+ ;660660+ idx = gidx = sidx + 1;661661+ for (i = sidx; i < tlbsize; i++) {662662+ unsigned long long entryhi, vpn_pagesz = 0;663663+664664+ while (1) {665665+ if (WARN_ON(vpn >= vpn_size)) {666666+ dump_tlb_all();667667+ /* Pray local_flush_tlb_all() will cope. */668668+ return;669669+ }670670+671671+ /* VPN must be below the next wired entry. */672672+ if (widx < sidx && vpn >= tlb_vpns[widx].vpn) {673673+ vpn = max(vpn,674674+ (tlb_vpns[widx].vpn +675675+ (1ULL << tlb_vpns[widx].pagesz)));676676+ asid = 0;677677+ widx++;678678+ continue;679679+ }680680+ /* VPN must be below the next global entry. */681681+ if (gidx < lidx && vpn >= tlb_vpns[gidx].vpn) {682682+ vpn = max(vpn,683683+ (tlb_vpns[gidx].vpn +684684+ (1ULL << tlb_vpns[gidx].pagesz)));685685+ asid = 0;686686+ gidx++;687687+ continue;688688+ }689689+ /* Try to find a free ASID so as to conserve VPNs. */690690+ if (idx < tlbsize && vpn == tlb_vpns[idx].vpn &&691691+ asid == tlb_vpns[idx].asid) {692692+ unsigned long long idx_pagesz;693693+694694+ idx_pagesz = tlb_vpns[idx].pagesz;695695+ vpn_pagesz = max(vpn_pagesz, idx_pagesz);696696+ do697697+ idx++;698698+ while (idx < tlbsize &&699699+ vpn == tlb_vpns[idx].vpn &&700700+ asid == tlb_vpns[idx].asid);701701+ asid++;702702+ if (asid > cpu_asid_mask(¤t_cpu_data)) {703703+ vpn += vpn_pagesz;704704+ asid = 0;705705+ vpn_pagesz = 0;706706+ }707707+ continue;708708+ }709709+ /* VPN mustn't be above the next regular entry. */710710+ if (idx < tlbsize && vpn > tlb_vpns[idx].vpn) {711711+ vpn = max(vpn,712712+ (tlb_vpns[idx].vpn +713713+ (1ULL << tlb_vpns[idx].pagesz)));714714+ asid = 0;715715+ idx++;716716+ continue;717717+ }718718+ break;719719+ }720720+721721+ entryhi = (vpn << VPN2_SHIFT) | asid;722722+ write_c0_entryhi_native(entryhi);723723+ write_c0_index(tlb_vpns[i].index);724724+ mtc0_tlbw_hazard();725725+ tlb_write_indexed();726726+727727+ tlb_vpns[i].asid = asid;728728+ tlb_vpns[i].vpn = vpn;729729+ tlb_vpns[i].pagesz = pagesz;730730+731731+ asid++;732732+ if (asid > cpu_asid_mask(¤t_cpu_data)) {733733+ vpn += 1ULL << pagesz;734734+ asid = 0;735735+ }736736+ }522737}523738524739/*···746527{747528 int tlbsize = current_cpu_data.tlbsize;748529 bool use_slab = slab_is_available();749749- int start = num_wired_entries();750530 phys_addr_t tlb_vpn_size;751751- unsigned long *tlb_vpns;752752- unsigned long vpn_mask;753753- int cnt, ent, idx, i;754754-755755- vpn_mask = GENMASK(cpu_vmbits - 1, 13);756756- vpn_mask |= IS_ENABLED(CONFIG_64BIT) ? 3ULL << 62 : 1 << 31;531531+ struct tlbent *tlb_vpns;757532758533 tlb_vpn_size = tlbsize * sizeof(*tlb_vpns);759534 tlb_vpns = (use_slab ?760760- kmalloc(tlb_vpn_size, GFP_KERNEL) :535535+ kmalloc(tlb_vpn_size, GFP_ATOMIC) :761536 memblock_alloc_raw(tlb_vpn_size, sizeof(*tlb_vpns)));762537 if (WARN_ON(!tlb_vpns))763538 return; /* Pray local_flush_tlb_all() is good enough. */764539765540 htw_stop();766541767767- for (i = start, cnt = 0; i < tlbsize; i++, cnt++) {768768- unsigned long vpn;542542+ r4k_tlb_uniquify_read(tlb_vpns, tlbsize);769543770770- write_c0_index(i);771771- mtc0_tlbr_hazard();772772- tlb_read();773773- tlb_read_hazard();774774- vpn = read_c0_entryhi();775775- vpn &= vpn_mask & PAGE_MASK;776776- tlb_vpns[cnt] = vpn;544544+ sort(tlb_vpns, tlbsize, sizeof(*tlb_vpns), r4k_entry_cmp, NULL);777545778778- /* Prevent any large pages from overlapping regular ones. */779779- write_c0_pagemask(read_c0_pagemask() & PM_DEFAULT_MASK);780780- mtc0_tlbw_hazard();781781- tlb_write_indexed();782782- tlbw_use_hazard();783783- }784784-785785- sort(tlb_vpns, cnt, sizeof(tlb_vpns[0]), r4k_vpn_cmp, NULL);546546+ r4k_tlb_uniquify_write(tlb_vpns, tlbsize);786547787548 write_c0_pagemask(PM_DEFAULT_MASK);788788- write_c0_entrylo0(0);789789- write_c0_entrylo1(0);790790-791791- idx = 0;792792- ent = tlbsize;793793- for (i = start; i < tlbsize; i++)794794- while (1) {795795- unsigned long entryhi, vpn;796796-797797- entryhi = UNIQUE_ENTRYHI(ent);798798- vpn = entryhi & vpn_mask & PAGE_MASK;799799-800800- if (idx >= cnt || vpn < tlb_vpns[idx]) {801801- write_c0_entryhi(entryhi);802802- write_c0_index(i);803803- mtc0_tlbw_hazard();804804- tlb_write_indexed();805805- ent++;806806- break;807807- } else if (vpn == tlb_vpns[idx]) {808808- ent++;809809- } else {810810- idx++;811811- }812812- }813549814550 tlbw_use_hazard();815551 htw_start();···814640 temp_tlb_entry = current_cpu_data.tlbsize - 1;815641816642 /* From this point on the ARC firmware is dead. */817817- r4k_tlb_uniquify();643643+ if (!cpu_has_tlbinv)644644+ r4k_tlb_uniquify();818645 local_flush_tlb_all();819646820647 /* Did I tell you that ARC SUCKS? */
+4-4
arch/mips/ralink/clk.c
···2121{2222 switch (ralink_soc) {2323 case RT2880_SOC:2424- *idx = 0;2424+ *idx = 1;2525 return "ralink,rt2880-sysc";2626 case RT3883_SOC:2727- *idx = 0;2727+ *idx = 1;2828 return "ralink,rt3883-sysc";2929 case RT305X_SOC_RT3050:3030- *idx = 0;3030+ *idx = 1;3131 return "ralink,rt3050-sysc";3232 case RT305X_SOC_RT3052:3333- *idx = 0;3333+ *idx = 1;3434 return "ralink,rt3052-sysc";3535 case RT305X_SOC_RT3350:3636 *idx = 1;
+2-2
arch/powerpc/kernel/dma-iommu.c
···6767}6868bool arch_dma_alloc_direct(struct device *dev)6969{7070- if (dev->dma_ops_bypass)7070+ if (dev->dma_ops_bypass && dev->bus_dma_limit)7171 return true;72727373 return false;···75757676bool arch_dma_free_direct(struct device *dev, dma_addr_t dma_handle)7777{7878- if (!dev->dma_ops_bypass)7878+ if (!dev->dma_ops_bypass || !dev->bus_dma_limit)7979 return false;80808181 return is_direct_handle(dev, dma_handle);
+4
arch/riscv/include/asm/runtime-const.h
···22#ifndef _ASM_RISCV_RUNTIME_CONST_H33#define _ASM_RISCV_RUNTIME_CONST_H4455+#ifdef MODULE66+ #error "Cannot use runtime-const infrastructure from modules"77+#endif88+59#include <asm/asm.h>610#include <asm/alternative.h>711#include <asm/cacheflush.h>
···347347 if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen))348348 return -EINVAL;349349350350- if (!(arg & PR_TAGGED_ADDR_ENABLE))350350+ if (!(arg & PR_TAGGED_ADDR_ENABLE)) {351351 pmlen = PMLEN_0;352352+ pmm = ENVCFG_PMM_PMLEN_0;353353+ }352354353355 if (mmap_write_lock_killable(mm))354356 return -EINTR;
+5-1
arch/s390/kernel/perf_cpum_sf.c
···11681168static void hw_perf_event_update(struct perf_event *event, int flush_all)11691169{11701170 unsigned long long event_overflow, sampl_overflow, num_sdb;11711171+ struct cpu_hw_sf *cpuhw = this_cpu_ptr(&cpu_hw_sf);11711172 struct hw_perf_event *hwc = &event->hw;11721173 union hws_trailer_header prev, new;11731174 struct hws_trailer_entry *te;···12481247 * are dropped.12491248 * Slightly increase the interval to avoid hitting this limit.12501249 */12511251- if (event_overflow)12501250+ if (event_overflow) {12521251 SAMPL_RATE(hwc) += DIV_ROUND_UP(SAMPL_RATE(hwc), 10);12521252+ if (SAMPL_RATE(hwc) > cpuhw->qsi.max_sampl_rate)12531253+ SAMPL_RATE(hwc) = cpuhw->qsi.max_sampl_rate;12541254+ }12531255}1254125612551257static inline unsigned long aux_sdb_index(struct aux_buffer *aux,
+4-2
arch/x86/events/intel/core.c
···48554855 intel_pmu_set_acr_caused_constr(leader, idx++, cause_mask);4856485648574857 if (leader->nr_siblings) {48584858- for_each_sibling_event(sibling, leader)48594859- intel_pmu_set_acr_caused_constr(sibling, idx++, cause_mask);48584858+ for_each_sibling_event(sibling, leader) {48594859+ if (is_x86_event(sibling))48604860+ intel_pmu_set_acr_caused_constr(sibling, idx++, cause_mask);48614861+ }48604862 }4861486348624864 if (leader != event)
+14
arch/x86/kernel/Makefile
···4444KCOV_INSTRUMENT_unwind_frame.o := n4545KCOV_INSTRUMENT_unwind_guess.o := n46464747+# Disable KCOV to prevent crashes during kexec: load_segments() invalidates4848+# the GS base, which KCOV relies on for per-CPU data.4949+#5050+# As KCOV and KEXEC compatibility should be preserved (e.g. syzkaller is5151+# using it to collect crash dumps during kernel fuzzing), disabling5252+# KCOV for KEXEC kernels is not an option. Selectively disabling KCOV5353+# instrumentation for individual affected functions can be fragile, while5454+# adding more checks to KCOV would slow it down.5555+#5656+# As a compromise solution, disable KCOV instrumentation for the whole5757+# source code file. If its coverage is ever needed, other approaches5858+# should be considered.5959+KCOV_INSTRUMENT_machine_kexec_64.o := n6060+4761CFLAGS_head32.o := -fno-stack-protector4862CFLAGS_head64.o := -fno-stack-protector4963CFLAGS_irq.o := -I $(src)/../include/asm/trace
+2
arch/x86/mm/Makefile
···44KCOV_INSTRUMENT_mem_encrypt.o := n55KCOV_INSTRUMENT_mem_encrypt_amd.o := n66KCOV_INSTRUMENT_pgprot.o := n77+# See the "Disable KCOV" comment in arch/x86/kernel/Makefile.88+KCOV_INSTRUMENT_physaddr.o := n79810KASAN_SANITIZE_mem_encrypt.o := n911KASAN_SANITIZE_mem_encrypt_amd.o := n
···623623 sg_init_table(sgl->sg, MAX_SGL_ENTS + 1);624624 sgl->cur = 0;625625626626- if (sg)626626+ if (sg) {627627+ sg_unmark_end(sg + MAX_SGL_ENTS - 1);627628 sg_chain(sg, MAX_SGL_ENTS + 1, sgl->sg);629629+ }628630629631 list_add_tail(&sgl->list, &ctx->tsgl_list);630632 }···637635/**638636 * af_alg_count_tsgl - Count number of TX SG entries639637 *640640- * The counting starts from the beginning of the SGL to @bytes. If641641- * an @offset is provided, the counting of the SG entries starts at the @offset.638638+ * The counting starts from the beginning of the SGL to @bytes.642639 *643640 * @sk: socket of connection to user space644641 * @bytes: Count the number of SG entries holding given number of bytes.645645- * @offset: Start the counting of SG entries from the given offset.646642 * Return: Number of TX SG entries found given the constraints647643 */648648-unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset)644644+unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes)649645{650646 const struct alg_sock *ask = alg_sk(sk);651647 const struct af_alg_ctx *ctx = ask->private;···658658 const struct scatterlist *sg = sgl->sg;659659660660 for (i = 0; i < sgl->cur; i++) {661661- size_t bytes_count;662662-663663- /* Skip offset */664664- if (offset >= sg[i].length) {665665- offset -= sg[i].length;666666- bytes -= sg[i].length;667667- continue;668668- }669669-670670- bytes_count = sg[i].length - offset;671671-672672- offset = 0;673661 sgl_count++;674674-675675- /* If we have seen requested number of bytes, stop */676676- if (bytes_count >= bytes)662662+ if (sg[i].length >= bytes)677663 return sgl_count;678664679679- bytes -= bytes_count;665665+ bytes -= sg[i].length;680666 }681667 }682668···674688 * af_alg_pull_tsgl - Release the specified buffers from TX SGL675689 *676690 * If @dst is non-null, reassign the pages to @dst. The caller must release677677- * the pages. If @dst_offset is given only reassign the pages to @dst starting678678- * at the @dst_offset (byte). The caller must ensure that @dst is large679679- * enough (e.g. by using af_alg_count_tsgl with the same offset).691691+ * the pages.680692 *681693 * @sk: socket of connection to user space682694 * @used: Number of bytes to pull from TX SGL683695 * @dst: If non-NULL, buffer is reassigned to dst SGL instead of releasing. The684696 * caller must release the buffers in dst.685685- * @dst_offset: Reassign the TX SGL from given offset. All buffers before686686- * reaching the offset is released.687697 */688688-void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,689689- size_t dst_offset)698698+void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst)690699{691700 struct alg_sock *ask = alg_sk(sk);692701 struct af_alg_ctx *ctx = ask->private;···706725 * SG entries in dst.707726 */708727 if (dst) {709709- if (dst_offset >= plen) {710710- /* discard page before offset */711711- dst_offset -= plen;712712- } else {713713- /* reassign page to dst after offset */714714- get_page(page);715715- sg_set_page(dst + j, page,716716- plen - dst_offset,717717- sg[i].offset + dst_offset);718718- dst_offset = 0;719719- j++;720720- }728728+ /* reassign page to dst after offset */729729+ get_page(page);730730+ sg_set_page(dst + j, page, plen, sg[i].offset);731731+ j++;721732 }722733723734 sg[i].length -= plen;
+19-81
crypto/algif_aead.c
···2626#include <crypto/internal/aead.h>2727#include <crypto/scatterwalk.h>2828#include <crypto/if_alg.h>2929-#include <crypto/skcipher.h>3029#include <linux/init.h>3130#include <linux/list.h>3231#include <linux/kernel.h>···7172 struct alg_sock *pask = alg_sk(psk);7273 struct af_alg_ctx *ctx = ask->private;7374 struct crypto_aead *tfm = pask->private;7474- unsigned int i, as = crypto_aead_authsize(tfm);7575+ unsigned int as = crypto_aead_authsize(tfm);7576 struct af_alg_async_req *areq;7676- struct af_alg_tsgl *tsgl, *tmp;7777 struct scatterlist *rsgl_src, *tsgl_src = NULL;7878 int err = 0;7979 size_t used = 0; /* [in] TX bufs to be en/decrypted */···152154 outlen -= less;153155 }154156157157+ /*158158+ * Create a per request TX SGL for this request which tracks the159159+ * SG entries from the global TX SGL.160160+ */155161 processed = used + ctx->aead_assoclen;156156- list_for_each_entry_safe(tsgl, tmp, &ctx->tsgl_list, list) {157157- for (i = 0; i < tsgl->cur; i++) {158158- struct scatterlist *process_sg = tsgl->sg + i;159159-160160- if (!(process_sg->length) || !sg_page(process_sg))161161- continue;162162- tsgl_src = process_sg;163163- break;164164- }165165- if (tsgl_src)166166- break;167167- }168168- if (processed && !tsgl_src) {169169- err = -EFAULT;162162+ areq->tsgl_entries = af_alg_count_tsgl(sk, processed);163163+ if (!areq->tsgl_entries)164164+ areq->tsgl_entries = 1;165165+ areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),166166+ areq->tsgl_entries),167167+ GFP_KERNEL);168168+ if (!areq->tsgl) {169169+ err = -ENOMEM;170170 goto free;171171 }172172+ sg_init_table(areq->tsgl, areq->tsgl_entries);173173+ af_alg_pull_tsgl(sk, processed, areq->tsgl);174174+ tsgl_src = areq->tsgl;172175173176 /*174177 * Copy of AAD from source to destination···178179 * when user space uses an in-place cipher operation, the kernel179180 * will copy the data as it does not see whether such in-place operation180181 * is initiated.181181- *182182- * To ensure efficiency, the following implementation ensure that the183183- * ciphers are invoked to perform a crypto operation in-place. This184184- * is achieved by memory management specified as follows.185182 */186183187184 /* Use the RX SGL as source (and destination) for crypto op. */188185 rsgl_src = areq->first_rsgl.sgl.sgt.sgl;189186190190- if (ctx->enc) {191191- /*192192- * Encryption operation - The in-place cipher operation is193193- * achieved by the following operation:194194- *195195- * TX SGL: AAD || PT196196- * | |197197- * | copy |198198- * v v199199- * RX SGL: AAD || PT || Tag200200- */201201- memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src,202202- processed);203203- af_alg_pull_tsgl(sk, processed, NULL, 0);204204- } else {205205- /*206206- * Decryption operation - To achieve an in-place cipher207207- * operation, the following SGL structure is used:208208- *209209- * TX SGL: AAD || CT || Tag210210- * | | ^211211- * | copy | | Create SGL link.212212- * v v |213213- * RX SGL: AAD || CT ----+214214- */215215-216216- /* Copy AAD || CT to RX SGL buffer for in-place operation. */217217- memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src, outlen);218218-219219- /* Create TX SGL for tag and chain it to RX SGL. */220220- areq->tsgl_entries = af_alg_count_tsgl(sk, processed,221221- processed - as);222222- if (!areq->tsgl_entries)223223- areq->tsgl_entries = 1;224224- areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),225225- areq->tsgl_entries),226226- GFP_KERNEL);227227- if (!areq->tsgl) {228228- err = -ENOMEM;229229- goto free;230230- }231231- sg_init_table(areq->tsgl, areq->tsgl_entries);232232-233233- /* Release TX SGL, except for tag data and reassign tag data. */234234- af_alg_pull_tsgl(sk, processed, areq->tsgl, processed - as);235235-236236- /* chain the areq TX SGL holding the tag with RX SGL */237237- if (usedpages) {238238- /* RX SGL present */239239- struct af_alg_sgl *sgl_prev = &areq->last_rsgl->sgl;240240- struct scatterlist *sg = sgl_prev->sgt.sgl;241241-242242- sg_unmark_end(sg + sgl_prev->sgt.nents - 1);243243- sg_chain(sg, sgl_prev->sgt.nents + 1, areq->tsgl);244244- } else245245- /* no RX SGL present (e.g. authentication only) */246246- rsgl_src = areq->tsgl;247247- }187187+ memcpy_sglist(rsgl_src, tsgl_src, ctx->aead_assoclen);248188249189 /* Initialize the crypto operation */250250- aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src,190190+ aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,251191 areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv);252192 aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);253193 aead_request_set_tfm(&areq->cra_u.aead_req, tfm);···388450 struct crypto_aead *tfm = pask->private;389451 unsigned int ivlen = crypto_aead_ivsize(tfm);390452391391- af_alg_pull_tsgl(sk, ctx->used, NULL, 0);453453+ af_alg_pull_tsgl(sk, ctx->used, NULL);392454 sock_kzfree_s(sk, ctx->iv, ivlen);393455 sock_kfree_s(sk, ctx, ctx->len);394456 af_alg_release_parent(sk);
+3-3
crypto/algif_skcipher.c
···138138 * Create a per request TX SGL for this request which tracks the139139 * SG entries from the global TX SGL.140140 */141141- areq->tsgl_entries = af_alg_count_tsgl(sk, len, 0);141141+ areq->tsgl_entries = af_alg_count_tsgl(sk, len);142142 if (!areq->tsgl_entries)143143 areq->tsgl_entries = 1;144144 areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),···149149 goto free;150150 }151151 sg_init_table(areq->tsgl, areq->tsgl_entries);152152- af_alg_pull_tsgl(sk, len, areq->tsgl, 0);152152+ af_alg_pull_tsgl(sk, len, areq->tsgl);153153154154 /* Initialize the crypto operation */155155 skcipher_request_set_tfm(&areq->cra_u.skcipher_req, tfm);···363363 struct alg_sock *pask = alg_sk(psk);364364 struct crypto_skcipher *tfm = pask->private;365365366366- af_alg_pull_tsgl(sk, ctx->used, NULL, 0);366366+ af_alg_pull_tsgl(sk, ctx->used, NULL);367367 sock_kzfree_s(sk, ctx->iv, crypto_skcipher_ivsize(tfm));368368 if (ctx->state)369369 sock_kzfree_s(sk, ctx->state, crypto_skcipher_statesize(tfm));
···164164165165 do {166166 unsigned int dcur;167167+ unsigned long avail_in;167168168169 dcur = acomp_walk_next_dst(&walk);169169- if (!dcur) {170170- out_of_space = true;171171- break;172172- }173170174171 stream->avail_out = dcur;175172 stream->next_out = walk.dst.virt.addr;173173+ avail_in = stream->avail_in;176174177175 ret = zlib_inflate(stream, Z_NO_FLUSH);176176+177177+ if (!dcur && avail_in == stream->avail_in) {178178+ out_of_space = true;179179+ break;180180+ }178181179182 dcur -= stream->avail_out;180183 acomp_walk_done_dst(&walk, dcur);
+45-2
drivers/accel/qaic/qaic_control.c
···914914 */915915 return -ENODEV;916916917917- if (status) {917917+ if (usr && status) {918918 /*919919 * Releasing resources failed on the device side, which puts920920 * us in a bind since they may still be in use, so enable the···11091109 mutex_lock(&qdev->cntl_mutex);11101110 if (!list_empty(&elem.list))11111111 list_del(&elem.list);11121112+ /* resp_worker() processed the response but the wait was interrupted */11131113+ else if (ret == -ERESTARTSYS)11141114+ ret = 0;11121115 if (!ret && !elem.buf)11131116 ret = -ETIMEDOUT;11141117 else if (ret > 0 && !elem.buf)···14221419 }14231420 mutex_unlock(&qdev->cntl_mutex);1424142114251425- if (!found)14221422+ if (!found) {14231423+ /*14241424+ * The user might have gone away at this point without waiting14251425+ * for QAIC_TRANS_DEACTIVATE_FROM_DEV transaction coming from14261426+ * the device. If this is not handled correctly, the host will14271427+ * not know that the DBC[n] has been freed on the device.14281428+ * Due to this failure in synchronization between the device and14291429+ * the host, if another user requests to activate a network, and14301430+ * the device assigns DBC[n] again, save_dbc_buf() will hang,14311431+ * waiting for dbc[n]->in_use to be set to false, which will not14321432+ * happen unless the qaic_dev_reset_clean_local_state() gets14331433+ * called by resetting the device (or re-inserting the module).14341434+ *14351435+ * As a solution, we look for QAIC_TRANS_DEACTIVATE_FROM_DEV14361436+ * transactions in the message before disposing of it, then14371437+ * handle releasing the DBC resources.14381438+ *14391439+ * Since the user has gone away, if the device could not14401440+ * deactivate the network (status != 0), there is no way to14411441+ * enable and reassign the DBC to the user. We can put trust in14421442+ * the device that it will release all the active DBCs in14431443+ * response to the QAIC_TRANS_TERMINATE_TO_DEV transaction,14441444+ * otherwise, the user can issue an soc_reset to the device.14451445+ */14461446+ u32 msg_count = le32_to_cpu(msg->hdr.count);14471447+ u32 msg_len = le32_to_cpu(msg->hdr.len);14481448+ u32 len = 0;14491449+ int j;14501450+14511451+ for (j = 0; j < msg_count && len < msg_len; ++j) {14521452+ struct wire_trans_hdr *trans_hdr;14531453+14541454+ trans_hdr = (struct wire_trans_hdr *)(msg->data + len);14551455+ if (le32_to_cpu(trans_hdr->type) == QAIC_TRANS_DEACTIVATE_FROM_DEV) {14561456+ if (decode_deactivate(qdev, trans_hdr, &len, NULL))14571457+ len += le32_to_cpu(trans_hdr->len);14581458+ } else {14591459+ len += le32_to_cpu(trans_hdr->len);14601460+ }14611461+ }14261462 /* request must have timed out, drop packet */14271463 kfree(msg);14641464+ }1428146514291466 kfree(resp);14301467}
+7
drivers/acpi/riscv/rimt.c
···263263 if (!rimt_fwnode)264264 return -EPROBE_DEFER;265265266266+ /*267267+ * EPROBE_DEFER ensures IOMMU is probed before the devices that268268+ * depend on them. During shutdown, however, the IOMMU may be removed269269+ * first, leading to issues. To avoid this, a device link is added270270+ * which enforces the correct removal order.271271+ */272272+ device_link_add(dev, rimt_fwnode->dev, DL_FLAG_AUTOREMOVE_CONSUMER);266273 return acpi_iommu_fwspec_init(dev, deviceid, rimt_fwnode);267274}268275
+5-3
drivers/android/binder/page_range.rs
···1313//1414// The shrinker will use trylock methods because it locks them in a different order.15151616+use crate::AssertSync;1717+1618use core::{1719 marker::PhantomPinned,1820 mem::{size_of, size_of_val, MaybeUninit},···145143}146144147145// We do not define any ops. For now, used only to check identity of vmas.148148-static BINDER_VM_OPS: bindings::vm_operations_struct = pin_init::zeroed();146146+static BINDER_VM_OPS: AssertSync<bindings::vm_operations_struct> = AssertSync(pin_init::zeroed());149147150148// To ensure that we do not accidentally install pages into or zap pages from the wrong vma, we151149// check its vm_ops and private data before using it.152150fn check_vma(vma: &virt::VmaRef, owner: *const ShrinkablePageRange) -> Option<&virt::VmaMixedMap> {153151 // SAFETY: Just reading the vm_ops pointer of any active vma is safe.154152 let vm_ops = unsafe { (*vma.as_ptr()).vm_ops };155155- if !ptr::eq(vm_ops, &BINDER_VM_OPS) {153153+ if !ptr::eq(vm_ops, &BINDER_VM_OPS.0) {156154 return None;157155 }158156···344342345343 // SAFETY: We own the vma, and we don't use any methods on VmaNew that rely on346344 // `vm_ops`.347347- unsafe { (*vma.as_ptr()).vm_ops = &BINDER_VM_OPS };345345+ unsafe { (*vma.as_ptr()).vm_ops = &BINDER_VM_OPS.0 };348346349347 Ok(num_pages)350348 }
+1-1
drivers/android/binder/rust_binder_main.rs
···306306/// Makes the inner type Sync.307307#[repr(transparent)]308308pub struct AssertSync<T>(T);309309-// SAFETY: Used only to insert `file_operations` into a global, which is safe.309309+// SAFETY: Used only to insert C bindings types into globals, which is safe.310310unsafe impl<T> Sync for AssertSync<T> {}311311312312/// File operations that rust_binderfs.c can use.
+12-3
drivers/auxdisplay/lcd2s.c
···9999{100100 struct lcd2s_data *lcd2s = lcd->drvdata;101101 u8 buf[2] = { LCD2S_CMD_WRITE, c };102102+ int ret;102103103103- lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));104104+ ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));105105+ if (ret < 0)106106+ return ret;107107+ if (ret != sizeof(buf))108108+ return -EIO;104109 return 0;105110}106111···113108{114109 struct lcd2s_data *lcd2s = lcd->drvdata;115110 u8 buf[3] = { LCD2S_CMD_CUR_POS, y + 1, x + 1 };111111+ int ret;116112117117- lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));118118-113113+ ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));114114+ if (ret < 0)115115+ return ret;116116+ if (ret != sizeof(buf))117117+ return -EIO;119118 return 0;120119}121120
···793793 __comedi_clear_subdevice_runflags(s, COMEDI_SRF_RUNNING |794794 COMEDI_SRF_BUSY);795795 spin_unlock_irqrestore(&s->spin_lock, flags);796796- if (comedi_is_runflags_busy(runflags)) {796796+ if (async) {797797 /*798798 * "Run active" counter was set to 1 when setting up the799799 * command. Decrement it and wait for it to become 0.800800 */801801- comedi_put_is_subdevice_running(s);802802- wait_for_completion(&async->run_complete);801801+ if (comedi_is_runflags_busy(runflags)) {802802+ comedi_put_is_subdevice_running(s);803803+ wait_for_completion(&async->run_complete);804804+ }803805 comedi_buf_reset(s);804806 async->inttrig = NULL;805807 kfree(async->cmd.chanlist);
+8
drivers/comedi/drivers.c
···10631063 ret = -EIO;10641064 goto out;10651065 }10661066+ if (IS_ENABLED(CONFIG_LOCKDEP)) {10671067+ /*10681068+ * dev->spinlock is for private use by the attached low-level10691069+ * driver. Reinitialize it to stop lock-dependency tracking10701070+ * between attachments to different low-level drivers.10711071+ */10721072+ spin_lock_init(&dev->spinlock);10731073+ }10661074 dev->driver = driv;10671075 dev->board_name = dev->board_ptr ? *(const char **)dev->board_ptr10681076 : dev->driver->driver_name;
+12
drivers/comedi/drivers/dt2815.c
···175175 ? current_range_type : voltage_range_type;176176 }177177178178+ /*179179+ * Check if hardware is present before attempting any I/O operations.180180+ * Reading 0xff from status register typically indicates no hardware181181+ * on the bus (floating bus reads as all 1s).182182+ */183183+ if (inb(dev->iobase + DT2815_STATUS) == 0xff) {184184+ dev_err(dev->class_dev,185185+ "No hardware detected at I/O base 0x%lx\n",186186+ dev->iobase);187187+ return -ENODEV;188188+ }189189+178190 /* Init the 2815 */179191 outb(0x00, dev->iobase + DT2815_STATUS);180192 for (i = 0; i < 100; i++) {
···122122 depends on OF123123 select GPIB_COMMON124124 select GPIB_NEC7210125125+ depends on HAS_IOMEM125126 help126127 GPIB driver for Fluke based cda devices.127128
+73-23
drivers/gpib/common/gpib_os.c
···888888 if (read_cmd.completed_transfer_count > read_cmd.requested_transfer_count)889889 return -EINVAL;890890891891- desc = handle_to_descriptor(file_priv, read_cmd.handle);892892- if (!desc)893893- return -EINVAL;894894-895891 if (WARN_ON_ONCE(sizeof(userbuf) > sizeof(read_cmd.buffer_ptr)))896892 return -EFAULT;897893···899903 /* Check write access to buffer */900904 if (!access_ok(userbuf, remain))901905 return -EFAULT;906906+907907+ /* Lock descriptors to prevent concurrent close from freeing descriptor */908908+ if (mutex_lock_interruptible(&file_priv->descriptors_mutex))909909+ return -ERESTARTSYS;910910+ desc = handle_to_descriptor(file_priv, read_cmd.handle);911911+ if (!desc) {912912+ mutex_unlock(&file_priv->descriptors_mutex);913913+ return -EINVAL;914914+ }915915+ atomic_inc(&desc->descriptor_busy);916916+ mutex_unlock(&file_priv->descriptors_mutex);902917903918 atomic_set(&desc->io_in_progress, 1);904919···944937 retval = copy_to_user((void __user *)arg, &read_cmd, sizeof(read_cmd));945938946939 atomic_set(&desc->io_in_progress, 0);940940+ atomic_dec(&desc->descriptor_busy);947941948942 wake_up_interruptible(&board->wait);949943 if (retval)···972964 if (cmd.completed_transfer_count > cmd.requested_transfer_count)973965 return -EINVAL;974966975975- desc = handle_to_descriptor(file_priv, cmd.handle);976976- if (!desc)977977- return -EINVAL;978978-979967 userbuf = (u8 __user *)(unsigned long)cmd.buffer_ptr;980968 userbuf += cmd.completed_transfer_count;981969···983979 /* Check read access to buffer */984980 if (!access_ok(userbuf, remain))985981 return -EFAULT;982982+983983+ /* Lock descriptors to prevent concurrent close from freeing descriptor */984984+ if (mutex_lock_interruptible(&file_priv->descriptors_mutex))985985+ return -ERESTARTSYS;986986+ desc = handle_to_descriptor(file_priv, cmd.handle);987987+ if (!desc) {988988+ mutex_unlock(&file_priv->descriptors_mutex);989989+ return -EINVAL;990990+ }991991+ atomic_inc(&desc->descriptor_busy);992992+ mutex_unlock(&file_priv->descriptors_mutex);986993987994 /*988995 * Write buffer loads till we empty the user supplied buffer.···10181003 userbuf += bytes_written;10191004 if (retval < 0) {10201005 atomic_set(&desc->io_in_progress, 0);10061006+ atomic_dec(&desc->descriptor_busy);1021100710221008 wake_up_interruptible(&board->wait);10231009 break;···10381022 */10391023 if (!no_clear_io_in_prog || fault)10401024 atomic_set(&desc->io_in_progress, 0);10251025+ atomic_dec(&desc->descriptor_busy);1041102610421027 wake_up_interruptible(&board->wait);10431028 if (fault)···10641047 if (write_cmd.completed_transfer_count > write_cmd.requested_transfer_count)10651048 return -EINVAL;1066104910671067- desc = handle_to_descriptor(file_priv, write_cmd.handle);10681068- if (!desc)10691069- return -EINVAL;10701070-10711050 userbuf = (u8 __user *)(unsigned long)write_cmd.buffer_ptr;10721051 userbuf += write_cmd.completed_transfer_count;10731052···10721059 /* Check read access to buffer */10731060 if (!access_ok(userbuf, remain))10741061 return -EFAULT;10621062+10631063+ /* Lock descriptors to prevent concurrent close from freeing descriptor */10641064+ if (mutex_lock_interruptible(&file_priv->descriptors_mutex))10651065+ return -ERESTARTSYS;10661066+ desc = handle_to_descriptor(file_priv, write_cmd.handle);10671067+ if (!desc) {10681068+ mutex_unlock(&file_priv->descriptors_mutex);10691069+ return -EINVAL;10701070+ }10711071+ atomic_inc(&desc->descriptor_busy);10721072+ mutex_unlock(&file_priv->descriptors_mutex);1075107310761074 atomic_set(&desc->io_in_progress, 1);10771075···11181094 fault = copy_to_user((void __user *)arg, &write_cmd, sizeof(write_cmd));1119109511201096 atomic_set(&desc->io_in_progress, 0);10971097+ atomic_dec(&desc->descriptor_busy);1121109811221099 wake_up_interruptible(&board->wait);11231100 if (fault)···13011276{13021277 struct gpib_close_dev_ioctl cmd;13031278 struct gpib_file_private *file_priv = filep->private_data;12791279+ struct gpib_descriptor *desc;12801280+ unsigned int pad;12811281+ int sad;13041282 int retval;1305128313061284 retval = copy_from_user(&cmd, (void __user *)arg, sizeof(cmd));···1312128413131285 if (cmd.handle >= GPIB_MAX_NUM_DESCRIPTORS)13141286 return -EINVAL;13151315- if (!file_priv->descriptors[cmd.handle])12871287+12881288+ mutex_lock(&file_priv->descriptors_mutex);12891289+ desc = file_priv->descriptors[cmd.handle];12901290+ if (!desc) {12911291+ mutex_unlock(&file_priv->descriptors_mutex);13161292 return -EINVAL;13171317-13181318- retval = decrement_open_device_count(board, &board->device_list,13191319- file_priv->descriptors[cmd.handle]->pad,13201320- file_priv->descriptors[cmd.handle]->sad);13211321- if (retval < 0)13221322- return retval;13231323-13241324- kfree(file_priv->descriptors[cmd.handle]);12931293+ }12941294+ if (atomic_read(&desc->descriptor_busy)) {12951295+ mutex_unlock(&file_priv->descriptors_mutex);12961296+ return -EBUSY;12971297+ }12981298+ /* Remove from table while holding lock to prevent new IO from starting */13251299 file_priv->descriptors[cmd.handle] = NULL;13001300+ pad = desc->pad;13011301+ sad = desc->sad;13021302+ mutex_unlock(&file_priv->descriptors_mutex);1326130313271327- return 0;13041304+ retval = decrement_open_device_count(board, &board->device_list, pad, sad);13051305+13061306+ kfree(desc);13071307+ return retval;13281308}1329130913301310static int serial_poll_ioctl(struct gpib_board *board, unsigned long arg)···13671331 if (retval)13681332 return -EFAULT;1369133313341334+ /*13351335+ * Lock descriptors to prevent concurrent close from freeing13361336+ * descriptor. ibwait() releases big_gpib_mutex when wait_mask13371337+ * is non-zero, so desc must be pinned with descriptor_busy.13381338+ */13391339+ mutex_lock(&file_priv->descriptors_mutex);13701340 desc = handle_to_descriptor(file_priv, wait_cmd.handle);13711371- if (!desc)13411341+ if (!desc) {13421342+ mutex_unlock(&file_priv->descriptors_mutex);13721343 return -EINVAL;13441344+ }13451345+ atomic_inc(&desc->descriptor_busy);13461346+ mutex_unlock(&file_priv->descriptors_mutex);1373134713741348 retval = ibwait(board, wait_cmd.wait_mask, wait_cmd.clear_mask,13751349 wait_cmd.set_mask, &wait_cmd.ibsta, wait_cmd.usec_timeout, desc);13501350+13511351+ atomic_dec(&desc->descriptor_busy);13521352+13761353 if (retval < 0)13771354 return retval;13781355···20842035 desc->is_board = 0;20852036 desc->autopoll_enabled = 0;20862037 atomic_set(&desc->io_in_progress, 0);20382038+ atomic_set(&desc->descriptor_busy, 0);20872039}2088204020892041int gpib_register_driver(struct gpib_interface *interface, struct module *provider_module)
+8
drivers/gpib/include/gpib_types.h
···364364 unsigned int pad; /* primary gpib address */365365 int sad; /* secondary gpib address (negative means disabled) */366366 atomic_t io_in_progress;367367+ /*368368+ * Kernel-only reference count to prevent descriptor from being369369+ * freed while IO handlers hold a pointer to it. Incremented370370+ * before each IO operation, decremented when done. Unlike371371+ * io_in_progress, this cannot be modified from userspace via372372+ * general_ibstatus().373373+ */374374+ atomic_t descriptor_busy;367375 unsigned is_board : 1;368376 unsigned autopoll_enabled : 1;369377};
···584584 unsigned long config;585585 bool ret = false;586586 int i, type;587587+ bool is_imx8qm = of_device_is_compatible(port->dev->of_node, "fsl,imx8qm-gpio");587588588589 static const u32 pad_type_map[] = {589590 IMX_SCU_WAKEUP_OFF, /* 0 */590591 IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_RISING */591592 IMX_SCU_WAKEUP_FALL_EDGE, /* IRQ_TYPE_EDGE_FALLING */592592- IMX_SCU_WAKEUP_FALL_EDGE, /* IRQ_TYPE_EDGE_BOTH */593593+ IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_BOTH */593594 IMX_SCU_WAKEUP_HIGH_LVL, /* IRQ_TYPE_LEVEL_HIGH */594595 IMX_SCU_WAKEUP_OFF, /* 5 */595596 IMX_SCU_WAKEUP_OFF, /* 6 */···605604 config = pad_type_map[type];606605 else607606 config = IMX_SCU_WAKEUP_OFF;607607+608608+ if (is_imx8qm && config == IMX_SCU_WAKEUP_FALL_EDGE) {609609+ dev_warn_once(port->dev,610610+ "No falling-edge support for wakeup on i.MX8QM\n");611611+ config = IMX_SCU_WAKEUP_OFF;612612+ }613613+608614 ret |= mxc_gpio_generic_config(port, i, config);609615 }610616 }
+2-2
drivers/gpio/gpio-qixis-fpga.c
···6060 return PTR_ERR(reg);61616262 regmap = devm_regmap_init_mmio(&pdev->dev, reg, ®map_config_8r_8v);6363- if (!regmap)6464- return -ENODEV;6363+ if (IS_ERR(regmap))6464+ return PTR_ERR(regmap);65656666 /* In this case, the offset of our register is 0 inside the6767 * regmap area that we just created.
+41-16
drivers/gpio/gpiolib-shared.c
···443443}444444#endif /* CONFIG_RESET_GPIO */445445446446-int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,447447- unsigned long lflags)446446+int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *fwnode,447447+ const char *con_id, unsigned long lflags)448448{449449 const char *dev_id = dev_name(consumer);450450 struct gpiod_lookup_table *lookup;···458458 if (!ref->fwnode && device_is_compatible(consumer, "reset-gpio")) {459459 if (!gpio_shared_dev_is_reset_gpio(consumer, entry, ref))460460 continue;461461- } else if (!device_match_fwnode(consumer, ref->fwnode)) {461461+ } else if (fwnode != ref->fwnode) {462462 continue;463463 }464464···506506 auxiliary_device_uninit(adev);507507}508508509509-int gpio_device_setup_shared(struct gpio_device *gdev)509509+int gpiochip_setup_shared(struct gpio_chip *gc)510510{511511+ struct gpio_device *gdev = gc->gpiodev;511512 struct gpio_shared_entry *entry;512513 struct gpio_shared_ref *ref;513514 struct gpio_desc *desc;···539538 if (list_count_nodes(&entry->refs) <= 1)540539 continue;541540542542- desc = &gdev->descs[entry->offset];541541+ scoped_guard(mutex, &entry->lock) {542542+#if IS_ENABLED(CONFIG_OF)543543+ if (is_of_node(entry->fwnode) && gc->of_xlate) {544544+ /*545545+ * This is the earliest that we can tranlate the546546+ * devicetree offset to the chip offset.547547+ */548548+ struct of_phandle_args gpiospec = { };543549544544- __set_bit(GPIOD_FLAG_SHARED, &desc->flags);545545- /*546546- * Shared GPIOs are not requested via the normal path. Make547547- * them inaccessible to anyone even before we register the548548- * chip.549549- */550550- ret = gpiod_request_commit(desc, "shared");551551- if (ret)552552- return ret;550550+ gpiospec.np = to_of_node(entry->fwnode);551551+ gpiospec.args_count = 2;552552+ gpiospec.args[0] = entry->offset;553553554554- pr_debug("GPIO %u owned by %s is shared by multiple consumers\n",555555- entry->offset, gpio_device_get_label(gdev));554554+ ret = gc->of_xlate(gc, &gpiospec, NULL);555555+ if (ret < 0)556556+ return ret;557557+558558+ entry->offset = ret;559559+ }560560+#endif /* CONFIG_OF */561561+562562+ desc = &gdev->descs[entry->offset];563563+564564+ __set_bit(GPIOD_FLAG_SHARED, &desc->flags);565565+ /*566566+ * Shared GPIOs are not requested via the normal path. Make567567+ * them inaccessible to anyone even before we register the568568+ * chip.569569+ */570570+ ret = gpiod_request_commit(desc, "shared");571571+ if (ret)572572+ return ret;573573+574574+ pr_debug("GPIO %u owned by %s is shared by multiple consumers\n",575575+ entry->offset, gpio_device_get_label(gdev));576576+ }556577557578 list_for_each_entry(ref, &entry->refs, list) {558579 pr_debug("Setting up a shared GPIO entry for %s (con_id: '%s')\n",···598575 struct gpio_shared_ref *ref;599576600577 list_for_each_entry(entry, &gpio_shared_list, list) {578578+ guard(mutex)(&entry->lock);579579+601580 if (!device_match_fwnode(&gdev->dev, entry->fwnode))602581 continue;603582
···892892#define gcdev_unregister(gdev) device_del(&(gdev)->dev)893893#endif894894895895+/*896896+ * An initial reference count has been held in gpiochip_add_data_with_key().897897+ * The caller should drop the reference via gpio_device_put() on errors.898898+ */895899static int gpiochip_setup_dev(struct gpio_device *gdev)896900{897901 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);898902 int ret;899899-900900- device_initialize(&gdev->dev);901903902904 /*903905 * If fwnode doesn't belong to another device, it's safe to clear its···966964 list_for_each_entry_srcu(gdev, &gpio_devices, list,967965 srcu_read_lock_held(&gpio_devices_srcu)) {968966 ret = gpiochip_setup_dev(gdev);969969- if (ret)967967+ if (ret) {968968+ gpio_device_put(gdev);970969 dev_err(&gdev->dev,971970 "Failed to initialize gpio device (%d)\n", ret);971971+ }972972 }973973}974974···10511047 int base = 0;10521048 int ret;1053104910541054- /*10551055- * First: allocate and populate the internal stat container, and10561056- * set up the struct device.10571057- */10581050 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);10591051 if (!gdev)10601052 return -ENOMEM;10611061-10621062- gdev->dev.type = &gpio_dev_type;10631063- gdev->dev.bus = &gpio_bus_type;10641064- gdev->dev.parent = gc->parent;10651065- rcu_assign_pointer(gdev->chip, gc);10661066-10671053 gc->gpiodev = gdev;10681054 gpiochip_set_data(gc, data);10691069-10701070- device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc));1071105510721056 ret = ida_alloc(&gpio_ida, GFP_KERNEL);10731057 if (ret < 0)10741058 goto err_free_gdev;10751059 gdev->id = ret;1076106010771077- ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);10611061+ ret = init_srcu_struct(&gdev->srcu);10781062 if (ret)10791063 goto err_free_ida;10641064+ rcu_assign_pointer(gdev->chip, gc);1080106510661066+ ret = init_srcu_struct(&gdev->desc_srcu);10671067+ if (ret)10681068+ goto err_cleanup_gdev_srcu;10691069+10701070+ ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);10711071+ if (ret)10721072+ goto err_cleanup_desc_srcu;10731073+10741074+ device_initialize(&gdev->dev);10751075+ /*10761076+ * After this point any allocated resources to `gdev` will be10771077+ * free():ed by gpiodev_release(). If you add new resources10781078+ * then make sure they get free():ed there.10791079+ */10801080+ gdev->dev.type = &gpio_dev_type;10811081+ gdev->dev.bus = &gpio_bus_type;10821082+ gdev->dev.parent = gc->parent;10831083+ device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc));10841084+10851085+ ret = gpiochip_get_ngpios(gc, &gdev->dev);10861086+ if (ret)10871087+ goto err_put_device;10881088+ gdev->ngpio = gc->ngpio;10891089+10901090+ gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL);10911091+ if (!gdev->descs) {10921092+ ret = -ENOMEM;10931093+ goto err_put_device;10941094+ }10951095+10961096+ gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL);10971097+ if (!gdev->label) {10981098+ ret = -ENOMEM;10991099+ goto err_put_device;11001100+ }11011101+11021102+ gdev->can_sleep = gc->can_sleep;11031103+ rwlock_init(&gdev->line_state_lock);11041104+ RAW_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier);11051105+ BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier);11061106+#ifdef CONFIG_PINCTRL11071107+ INIT_LIST_HEAD(&gdev->pin_ranges);11081108+#endif10811109 if (gc->parent && gc->parent->driver)10821110 gdev->owner = gc->parent->driver->owner;10831111 else if (gc->owner)···11171081 gdev->owner = gc->owner;11181082 else11191083 gdev->owner = THIS_MODULE;11201120-11211121- ret = gpiochip_get_ngpios(gc, &gdev->dev);11221122- if (ret)11231123- goto err_free_dev_name;11241124-11251125- gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL);11261126- if (!gdev->descs) {11271127- ret = -ENOMEM;11281128- goto err_free_dev_name;11291129- }11301130-11311131- gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL);11321132- if (!gdev->label) {11331133- ret = -ENOMEM;11341134- goto err_free_descs;11351135- }11361136-11371137- gdev->ngpio = gc->ngpio;11381138- gdev->can_sleep = gc->can_sleep;11391139-11401140- rwlock_init(&gdev->line_state_lock);11411141- RAW_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier);11421142- BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier);11431143-11441144- ret = init_srcu_struct(&gdev->srcu);11451145- if (ret)11461146- goto err_free_label;11471147-11481148- ret = init_srcu_struct(&gdev->desc_srcu);11491149- if (ret)11501150- goto err_cleanup_gdev_srcu;1151108411521085 scoped_guard(mutex, &gpio_devices_lock) {11531086 /*···11321127 if (base < 0) {11331128 ret = base;11341129 base = 0;11351135- goto err_cleanup_desc_srcu;11301130+ goto err_put_device;11361131 }1137113211381133 /*···11521147 ret = gpiodev_add_to_list_unlocked(gdev);11531148 if (ret) {11541149 gpiochip_err(gc, "GPIO integer space overlap, cannot add chip\n");11551155- goto err_cleanup_desc_srcu;11501150+ goto err_put_device;11561151 }11571152 }11581158-11591159-#ifdef CONFIG_PINCTRL11601160- INIT_LIST_HEAD(&gdev->pin_ranges);11611161-#endif1162115311631154 if (gc->names)11641155 gpiochip_set_desc_names(gc);···12111210 if (ret)12121211 goto err_remove_irqchip_mask;1213121212141214- ret = gpio_device_setup_shared(gdev);12131213+ ret = gpiochip_setup_shared(gc);12151214 if (ret)12161215 goto err_remove_irqchip;12171216···12491248 scoped_guard(mutex, &gpio_devices_lock)12501249 list_del_rcu(&gdev->list);12511250 synchronize_srcu(&gpio_devices_srcu);12521252- if (gdev->dev.release) {12531253- /* release() has been registered by gpiochip_setup_dev() */12541254- gpio_device_put(gdev);12551255- goto err_print_message;12561256- }12511251+err_put_device:12521252+ gpio_device_put(gdev);12531253+ goto err_print_message;12541254+12571255err_cleanup_desc_srcu:12581256 cleanup_srcu_struct(&gdev->desc_srcu);12591257err_cleanup_gdev_srcu:12601258 cleanup_srcu_struct(&gdev->srcu);12611261-err_free_label:12621262- kfree_const(gdev->label);12631263-err_free_descs:12641264- kfree(gdev->descs);12651265-err_free_dev_name:12661266- kfree(dev_name(&gdev->dev));12671259err_free_ida:12681260 ida_free(&gpio_ida, gdev->id);12691261err_free_gdev:12701262 kfree(gdev);12631263+12711264err_print_message:12721265 /* failures here can mean systems won't boot... */12731266 if (ret != -EPROBE_DEFER) {···24602465 return -EBUSY;2461246624622467 offset = gpiod_hwgpio(desc);24632463- if (!gpiochip_line_is_valid(guard.gc, offset))24642464- return -EINVAL;24682468+ if (!gpiochip_line_is_valid(guard.gc, offset)) {24692469+ ret = -EINVAL;24702470+ goto out_clear_bit;24712471+ }2465247224662473 /* NOTE: gpio_request() can be called in early boot,24672474 * before IRQs are enabled, for non-sleeping (SOC) GPIOs.···47144717 * lookup table for the proxy device as previously47154718 * we only knew the consumer's fwnode.47164719 */47174717- ret = gpio_shared_add_proxy_lookup(consumer, con_id,47184718- lookupflags);47204720+ ret = gpio_shared_add_proxy_lookup(consumer, fwnode,47214721+ con_id, lookupflags);47194722 if (ret)47204723 return ERR_PTR(ret);47214724
+6-2
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
···27032703 if (r)27042704 return r;2705270527062706- if (amdgpu_acpi_should_gpu_reset(adev))27072707- return amdgpu_asic_reset(adev);27062706+ if (amdgpu_acpi_should_gpu_reset(adev)) {27072707+ amdgpu_device_lock_reset_domain(adev->reset_domain);27082708+ r = amdgpu_asic_reset(adev);27092709+ amdgpu_device_unlock_reset_domain(adev->reset_domain);27102710+ return r;27112711+ }27082712 return 0;27092713}27102714
+44
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
···404404}405405406406/**407407+ * amdgpu_gart_map_gfx9_mqd - map mqd and ctrl_stack dma_addresses into GART entries408408+ *409409+ * @adev: amdgpu_device pointer410410+ * @offset: offset into the GPU's gart aperture411411+ * @pages: number of pages to bind412412+ * @dma_addr: DMA addresses of pages413413+ * @flags: page table entry flags414414+ *415415+ * Map the MQD and control stack addresses into GART entries with the correct416416+ * memory types on gfxv9. The MQD occupies the first 4KB and is followed by417417+ * the control stack. The MQD uses UC (uncached) memory, while the control stack418418+ * uses NC (non-coherent) memory.419419+ */420420+void amdgpu_gart_map_gfx9_mqd(struct amdgpu_device *adev, uint64_t offset,421421+ int pages, dma_addr_t *dma_addr, uint64_t flags)422422+{423423+ uint64_t page_base;424424+ unsigned int i, j, t;425425+ int idx;426426+ uint64_t ctrl_flags = AMDGPU_PTE_MTYPE_VG10(flags, AMDGPU_MTYPE_NC);427427+ void *dst;428428+429429+ if (!adev->gart.ptr)430430+ return;431431+432432+ if (!drm_dev_enter(adev_to_drm(adev), &idx))433433+ return;434434+435435+ t = offset / AMDGPU_GPU_PAGE_SIZE;436436+ dst = adev->gart.ptr;437437+ for (i = 0; i < pages; i++) {438438+ page_base = dma_addr[i];439439+ for (j = 0; j < AMDGPU_GPU_PAGES_IN_CPU_PAGE; j++, t++) {440440+ if ((i == 0) && (j == 0))441441+ amdgpu_gmc_set_pte_pde(adev, dst, t, page_base, flags);442442+ else443443+ amdgpu_gmc_set_pte_pde(adev, dst, t, page_base, ctrl_flags);444444+ page_base += AMDGPU_GPU_PAGE_SIZE;445445+ }446446+ }447447+ drm_dev_exit(idx);448448+}449449+450450+/**407451 * amdgpu_gart_bind - bind pages into the gart page table408452 *409453 * @adev: amdgpu_device pointer
···6868 return -EINVAL;69697070 spin_lock(&amdgpu_pasid_idr_lock);7171+ /* TODO: Need to replace the idr with an xarry, and then7272+ * handle the internal locking with ATOMIC safe paths.7373+ */7174 pasid = idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1,7272- 1U << bits, GFP_KERNEL);7575+ 1U << bits, GFP_ATOMIC);7376 spin_unlock(&amdgpu_pasid_idr_lock);74777578 if (pasid >= 0)
+3-13
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
···853853 int num_xcc = max(1U, adev->gfx.num_xcc_per_xcp);854854 uint64_t page_idx, pages_per_xcc;855855 int i;856856- uint64_t ctrl_flags = AMDGPU_PTE_MTYPE_VG10(flags, AMDGPU_MTYPE_NC);857856858857 pages_per_xcc = total_pages;859858 do_div(pages_per_xcc, num_xcc);860859861860 for (i = 0, page_idx = 0; i < num_xcc; i++, page_idx += pages_per_xcc) {862862- /* MQD page: use default flags */863863- amdgpu_gart_bind(adev,861861+ amdgpu_gart_map_gfx9_mqd(adev,864862 gtt->offset + (page_idx << PAGE_SHIFT),865865- 1, >t->ttm.dma_address[page_idx], flags);866866- /*867867- * Ctrl pages - modify the memory type to NC (ctrl_flags) from868868- * the second page of the BO onward.869869- */870870- amdgpu_gart_bind(adev,871871- gtt->offset + ((page_idx + 1) << PAGE_SHIFT),872872- pages_per_xcc - 1,873873- >t->ttm.dma_address[page_idx + 1],874874- ctrl_flags);863863+ pages_per_xcc, >t->ttm.dma_address[page_idx],864864+ flags);875865 }876866}877867
+7
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
···600600 goto unpin_bo;601601 }602602603603+ /* Validate doorbell_offset is within the doorbell BO */604604+ if ((u64)db_info->doorbell_offset * db_size + db_size >605605+ amdgpu_bo_size(db_obj->obj)) {606606+ r = -EINVAL;607607+ goto unpin_bo;608608+ }609609+603610 index = amdgpu_doorbell_index_on_bar(uq_mgr->adev, db_obj->obj,604611 db_info->doorbell_offset, db_size);605612 drm_dbg_driver(adev_to_drm(uq_mgr->adev),
···324324325325 r = amdgpu_userq_input_va_validate(adev, queue, compute_mqd->eop_va,326326 2048);327327- if (r)327327+ if (r) {328328+ kfree(compute_mqd);328329 goto free_mqd;330330+ }329331330332 userq_props->eop_gpu_addr = compute_mqd->eop_va;331333 userq_props->hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_NORMAL;···367365368366 r = amdgpu_userq_input_va_validate(adev, queue, mqd_gfx_v11->shadow_va,369367 shadow_info.shadow_size);370370- if (r)368368+ if (r) {369369+ kfree(mqd_gfx_v11);371370 goto free_mqd;371371+ }372372 r = amdgpu_userq_input_va_validate(adev, queue, mqd_gfx_v11->csa_va,373373 shadow_info.csa_size);374374- if (r)374374+ if (r) {375375+ kfree(mqd_gfx_v11);375376 goto free_mqd;377377+ }376378377379 kfree(mqd_gfx_v11);378380 } else if (queue->queue_type == AMDGPU_HW_IP_DMA) {···396390 }397391 r = amdgpu_userq_input_va_validate(adev, queue, mqd_sdma_v11->csa_va,398392 32);399399- if (r)393393+ if (r) {394394+ kfree(mqd_sdma_v11);400395 goto free_mqd;396396+ }401397402398 userq_props->csa_addr = mqd_sdma_v11->csa_va;403399 kfree(mqd_sdma_v11);
+2-1
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
···170170 int retry_loop;171171172172 /* For a reset done at the end of S3, only wait for TOS to be unloaded */173173- if (adev->in_s3 && !(adev->flags & AMD_IS_APU) && amdgpu_in_reset(adev))173173+ if ((adev->in_s4 || adev->in_s3) && !(adev->flags & AMD_IS_APU) &&174174+ amdgpu_in_reset(adev))174175 return psp_v11_wait_for_tos_unload(psp);175176176177 for (retry_loop = 0; retry_loop < 20; retry_loop++) {
+15-8
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
···4242 struct queue_properties *q)4343{4444 if (mm->dev->kfd->cwsr_enabled &&4545- q->type == KFD_QUEUE_TYPE_COMPUTE)4646- return ALIGN(q->ctl_stack_size, PAGE_SIZE) +4747- ALIGN(sizeof(struct v9_mqd), PAGE_SIZE);4545+ q->type == KFD_QUEUE_TYPE_COMPUTE) {4646+4747+ /* On gfxv9, the MQD resides in the first 4K page,4848+ * followed by the control stack. Align both to4949+ * AMDGPU_GPU_PAGE_SIZE to maintain the required 4K boundary.5050+ */5151+5252+ return ALIGN(ALIGN(q->ctl_stack_size, AMDGPU_GPU_PAGE_SIZE) +5353+ ALIGN(sizeof(struct v9_mqd), AMDGPU_GPU_PAGE_SIZE), PAGE_SIZE);5454+ }48554956 return mm->mqd_size;5057}···158151 if (!mqd_mem_obj)159152 return NULL;160153 retval = amdgpu_amdkfd_alloc_kernel_mem(node->adev,161161- (ALIGN(q->ctl_stack_size, PAGE_SIZE) +162162- ALIGN(sizeof(struct v9_mqd), PAGE_SIZE)) *154154+ (ALIGN(ALIGN(q->ctl_stack_size, AMDGPU_GPU_PAGE_SIZE) +155155+ ALIGN(sizeof(struct v9_mqd), AMDGPU_GPU_PAGE_SIZE), PAGE_SIZE)) *163156 NUM_XCC(node->xcc_mask),164157 mqd_on_vram(node->adev) ? AMDGPU_GEM_DOMAIN_VRAM :165158 AMDGPU_GEM_DOMAIN_GTT,···367360 struct kfd_context_save_area_header header;368361369362 /* Control stack is located one page after MQD. */370370- void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);363363+ void *mqd_ctl_stack = (void *)((uintptr_t)mqd + AMDGPU_GPU_PAGE_SIZE);371364372365 m = get_mqd(mqd);373366···404397{405398 struct v9_mqd *m;406399 /* Control stack is located one page after MQD. */407407- void *ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);400400+ void *ctl_stack = (void *)((uintptr_t)mqd + AMDGPU_GPU_PAGE_SIZE);408401409402 m = get_mqd(mqd);410403···450443 *gart_addr = addr;451444452445 /* Control stack is located one page after MQD. */453453- ctl_stack = (void *)((uintptr_t)*mqd + PAGE_SIZE);446446+ ctl_stack = (void *)((uintptr_t)*mqd + AMDGPU_GPU_PAGE_SIZE);454447 memcpy(ctl_stack, ctl_stack_src, ctl_stack_size);455448456449 m->cp_hqd_pq_doorbell_control =
+2-2
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
···102102 * The first chunk is the TBA used for the CWSR ISA code. The second103103 * chunk is used as TMA for user-mode trap handler setup in daisy-chain mode.104104 */105105-#define KFD_CWSR_TBA_TMA_SIZE (PAGE_SIZE * 2)106106-#define KFD_CWSR_TMA_OFFSET (PAGE_SIZE + 2048)105105+#define KFD_CWSR_TBA_TMA_SIZE (AMDGPU_GPU_PAGE_SIZE * 2)106106+#define KFD_CWSR_TMA_OFFSET (AMDGPU_GPU_PAGE_SIZE + 2048)107107108108#define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \109109 (KFD_MAX_NUM_OF_PROCESSES * \
···137137 intel_dp->DP |= DP_SYNC_VS_HIGH;138138 intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT;139139140140- if (drm_dp_enhanced_frame_cap(intel_dp->dpcd))140140+ if (pipe_config->enhanced_framing)141141 intel_dp->DP |= DP_ENHANCED_FRAMING;142142143143 intel_dp->DP |= DP_PIPE_SEL_IVB(crtc->pipe);
+2-2
drivers/gpu/drm/i915/display/icl_dsi.c
···889889 * non-compressed link speeds, and simplifies down to the ratio between890890 * compressed and non-compressed bpp.891891 */892892- if (crtc_state->dsc.compression_enable) {892892+ if (is_vid_mode(intel_dsi) && crtc_state->dsc.compression_enable) {893893 mul = fxp_q4_to_int(crtc_state->dsc.compressed_bpp_x16);894894 div = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);895895 }···15031503 struct drm_display_mode *adjusted_mode =15041504 &pipe_config->hw.adjusted_mode;1505150515061506- if (pipe_config->dsc.compressed_bpp_x16) {15061506+ if (is_vid_mode(intel_dsi) && pipe_config->dsc.compressed_bpp_x16) {15071507 int div = fxp_q4_to_int(pipe_config->dsc.compressed_bpp_x16);15081508 int mul = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);15091509
+54
drivers/gpu/drm/i915/display/intel_cdclk.c
···29712971 return 0;29722972}2973297329742974+static int intel_cdclk_update_crtc_min_voltage_level(struct intel_atomic_state *state,29752975+ struct intel_crtc *crtc,29762976+ u8 old_min_voltage_level,29772977+ u8 new_min_voltage_level,29782978+ bool *need_cdclk_calc)29792979+{29802980+ struct intel_display *display = to_intel_display(state);29812981+ struct intel_cdclk_state *cdclk_state;29822982+ bool allow_voltage_level_decrease = intel_any_crtc_needs_modeset(state);29832983+ int ret;29842984+29852985+ if (new_min_voltage_level == old_min_voltage_level)29862986+ return 0;29872987+29882988+ if (!allow_voltage_level_decrease &&29892989+ new_min_voltage_level < old_min_voltage_level)29902990+ return 0;29912991+29922992+ cdclk_state = intel_atomic_get_cdclk_state(state);29932993+ if (IS_ERR(cdclk_state))29942994+ return PTR_ERR(cdclk_state);29952995+29962996+ old_min_voltage_level = cdclk_state->min_voltage_level[crtc->pipe];29972997+29982998+ if (new_min_voltage_level == old_min_voltage_level)29992999+ return 0;30003000+30013001+ if (!allow_voltage_level_decrease &&30023002+ new_min_voltage_level < old_min_voltage_level)30033003+ return 0;30043004+30053005+ cdclk_state->min_voltage_level[crtc->pipe] = new_min_voltage_level;30063006+30073007+ ret = intel_atomic_lock_global_state(&cdclk_state->base);30083008+ if (ret)30093009+ return ret;30103010+30113011+ *need_cdclk_calc = true;30123012+30133013+ drm_dbg_kms(display->drm,30143014+ "[CRTC:%d:%s] min voltage level: %d -> %d\n",30153015+ crtc->base.base.id, crtc->base.name,30163016+ old_min_voltage_level, new_min_voltage_level);30173017+30183018+ return 0;30193019+}30203020+29743021int intel_cdclk_update_dbuf_bw_min_cdclk(struct intel_atomic_state *state,29753022 int old_min_cdclk, int new_min_cdclk,29763023 bool *need_cdclk_calc)···34313384 old_crtc_state->min_cdclk,34323385 new_crtc_state->min_cdclk,34333386 need_cdclk_calc);33873387+ if (ret)33883388+ return ret;33893389+33903390+ ret = intel_cdclk_update_crtc_min_voltage_level(state, crtc,33913391+ old_crtc_state->min_voltage_level,33923392+ new_crtc_state->min_voltage_level,33933393+ need_cdclk_calc);34343394 if (ret)34353395 return ret;34363396 }
···380380 return 0;381381 }382382383383+ /*384384+ * On PTL, older GSC FWs have a bug that can cause them to crash during385385+ * PXP invalidation events, which leads to a complete loss of power386386+ * management on the media GT. Therefore, we can't use PXP on FWs that387387+ * have this bug, which was fixed in PTL GSC build 1396.388388+ */389389+ if (xe->info.platform == XE_PANTHERLAKE &&390390+ gt->uc.gsc.fw.versions.found[XE_UC_FW_VER_RELEASE].build < 1396) {391391+ drm_info(&xe->drm, "PXP requires PTL GSC build 1396 or newer\n");392392+ return 0;393393+ }394394+383395 pxp = drmm_kzalloc(&xe->drm, sizeof(struct xe_pxp), GFP_KERNEL);384396 if (!pxp) {385397 err = -ENOMEM;···524512static int pxp_start(struct xe_pxp *pxp, u8 type)525513{526514 int ret = 0;527527- bool restart = false;515515+ bool restart;528516529517 if (!xe_pxp_is_enabled(pxp))530518 return -ENODEV;···552540 if (!wait_for_completion_timeout(&pxp->activation,553541 msecs_to_jiffies(PXP_ACTIVATION_TIMEOUT_MS)))554542 return -ETIMEDOUT;543543+544544+ restart = false;555545556546 mutex_lock(&pxp->mutex);557547···597583 drm_err(&pxp->xe->drm, "PXP termination failed before start\n");598584 mutex_lock(&pxp->mutex);599585 pxp->status = XE_PXP_ERROR;586586+ complete_all(&pxp->termination);600587601588 goto out_unlock;602589 }···885870 pxp->key_instance++;886871 needs_queue_inval = true;887872 break;888888- default:889889- drm_err(&pxp->xe->drm, "unexpected state during PXP suspend: %u",890890- pxp->status);891891- ret = -EIO;892892- goto out;893873 }894874895875 /*···909899910900 pxp->last_suspend_key_instance = pxp->key_instance;911901912912-out:913902 return ret;914903}915904
···173173MODULE_AUTHOR("Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>");174174MODULE_DESCRIPTION("PMBUS driver for LTC4286 and compatibles");175175MODULE_LICENSE("GPL");176176+MODULE_IMPORT_NS("PMBUS");
+4-1
drivers/hwmon/pmbus/pxe1610.c
···104104 * By default this device doesn't boot to page 0, so set page 0105105 * to access all pmbus registers.106106 */107107- i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);107107+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);108108+ if (ret < 0)109109+ return dev_err_probe(&client->dev, ret,110110+ "Failed to set page 0\n");108111109112 /* Read Manufacturer id */110113 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
+5-5
drivers/hwmon/pmbus/tps53679.c
···103103 }104104105105 ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);106106- if (ret < 0)107107- return ret;106106+ if (ret <= 0)107107+ return ret < 0 ? ret : -EIO;108108109109- /* Adjust length if null terminator if present */109109+ /* Adjust length if null terminator is present */110110 buf_len = (buf[ret - 1] != '\x00' ? ret : ret - 1);111111112112 id_len = strlen(id);···175175 ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);176176 if (ret < 0)177177 return ret;178178- if (strncmp("TI\x53\x67\x60", buf, 5)) {179179- dev_err(&client->dev, "Unexpected device ID: %s\n", buf);178178+ if (ret != 6 || memcmp(buf, "TI\x53\x67\x60\x00", 6)) {179179+ dev_err(&client->dev, "Unexpected device ID: %*ph\n", ret, buf);180180 return -ENODEV;181181 }182182
+2
drivers/iio/accel/adxl313_core.c
···998998999999 ret = regmap_write(data->regmap, ADXL313_REG_FIFO_CTL,10001000 FIELD_PREP(ADXL313_REG_FIFO_CTL_MODE_MSK, ADXL313_FIFO_BYPASS));10011001+ if (ret)10021002+ return ret;1001100310021004 ret = regmap_write(data->regmap, ADXL313_REG_INT_ENABLE, 0);10031005 if (ret)
···274274275275 ret = pm_runtime_resume_and_get(dev);276276 if (ret)277277- goto pdown;277277+ return ret;278278279279 ret = ads1119_configure_channel(st, mux, gain, datarate);280280 if (ret)281281 goto pdown;282282+283283+ if (st->client->irq)284284+ reinit_completion(&st->completion);282285283286 ret = i2c_smbus_write_byte(st->client, ADS1119_CMD_START_SYNC);284287 if (ret)···738735 return dev_err_probe(dev, ret, "Failed to setup IIO buffer\n");739736740737 if (client->irq > 0) {741741- ret = devm_request_threaded_irq(dev, client->irq,742742- ads1119_irq_handler,743743- NULL, IRQF_ONESHOT,744744- "ads1119", indio_dev);738738+ ret = devm_request_irq(dev, client->irq, ads1119_irq_handler,739739+ IRQF_NO_THREAD, "ads1119", indio_dev);745740 if (ret)746741 return dev_err_probe(dev, ret,747742 "Failed to allocate irq\n");
+5-3
drivers/iio/adc/ti-ads7950.c
···427427static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)428428{429429 struct ti_ads7950_state *st = gpiochip_get_data(chip);430430+ bool state;430431 int ret;431432432433 mutex_lock(&st->slock);433434434435 /* If set as output, return the output */435436 if (st->gpio_cmd_settings_bitmask & BIT(offset)) {436436- ret = st->cmd_settings_bitmask & BIT(offset);437437+ state = st->cmd_settings_bitmask & BIT(offset);438438+ ret = 0;437439 goto out;438440 }439441···446444 if (ret)447445 goto out;448446449449- ret = ((st->single_rx >> 12) & BIT(offset)) ? 1 : 0;447447+ state = (st->single_rx >> 12) & BIT(offset);450448451449 /* Revert back to original settings */452450 st->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA;···458456out:459457 mutex_unlock(&st->slock);460458461461- return ret;459459+ return ret ?: state;462460}463461464462static int ti_ads7950_get_direction(struct gpio_chip *chip,
···6565#define MCP47FEB02_MAX_SCALES_CH 36666#define MCP47FEB02_DAC_WIPER_UNLOCKED 06767#define MCP47FEB02_NORMAL_OPERATION 06868-#define MCP47FEB02_INTERNAL_BAND_GAP_mV 24406868+#define MCP47FEB02_INTERNAL_BAND_GAP_uV 24400006969#define NV_DAC_ADDR_OFFSET 0x1070707171enum mcp47feb02_vref_mode {···697697};698698699699static void mcp47feb02_init_scale(struct mcp47feb02_data *data, enum mcp47feb02_scale scale,700700- int vref_mV, int scale_avail[])700700+ int vref_uV, int scale_avail[])701701{702702 u32 value_micro, value_int;703703 u64 tmp;704704705705- /* vref_mV should not be negative */706706- tmp = (u64)vref_mV * MICRO >> data->chip_features->resolution;705705+ /* vref_uV should not be negative */706706+ tmp = (u64)vref_uV * MILLI >> data->chip_features->resolution;707707 value_int = div_u64_rem(tmp, MICRO, &value_micro);708708 scale_avail[scale * 2] = value_int;709709 scale_avail[scale * 2 + 1] = value_micro;710710}711711712712-static int mcp47feb02_init_scales_avail(struct mcp47feb02_data *data, int vdd_mV,713713- int vref_mV, int vref1_mV)712712+static int mcp47feb02_init_scales_avail(struct mcp47feb02_data *data, int vdd_uV,713713+ int vref_uV, int vref1_uV)714714{715715- struct device *dev = regmap_get_device(data->regmap);716715 int tmp_vref;717716718718- mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale);717717+ mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_uV, data->scale);719718720719 if (data->use_vref)721721- tmp_vref = vref_mV;720720+ tmp_vref = vref_uV;722721 else723723- tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;722722+ tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_uV;724723725724 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X1, tmp_vref, data->scale);726725 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X2, tmp_vref * 2, data->scale);727726728727 if (data->phys_channels >= 4) {729729- mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale_1);730730-731731- if (data->use_vref1 && vref1_mV <= 0)732732- return dev_err_probe(dev, vref1_mV, "Invalid voltage for Vref1\n");728728+ mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_uV, data->scale_1);733729734730 if (data->use_vref1)735735- tmp_vref = vref1_mV;731731+ tmp_vref = vref1_uV;736732 else737737- tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;733733+ tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_uV;738734739735 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X1,740736 tmp_vref, data->scale_1);···951955 u32 num_channels;952956 u8 chan_idx = 0;953957954954- guard(mutex)(&data->lock);955955-956958 num_channels = device_get_child_node_count(dev);957959 if (num_channels > chip_features->phys_channels)958960 return dev_err_probe(dev, -EINVAL, "More channels than the chip supports\n");···10741080 return 0;10751081}1076108210771077-static int mcp47feb02_init_ch_scales(struct mcp47feb02_data *data, int vdd_mV,10781078- int vref_mV, int vref1_mV)10831083+static int mcp47feb02_init_ch_scales(struct mcp47feb02_data *data, int vdd_uV,10841084+ int vref_uV, int vref1_uV)10791085{10801086 unsigned int i;10811087···10831089 struct device *dev = regmap_get_device(data->regmap);10841090 int ret;1085109110861086- ret = mcp47feb02_init_scales_avail(data, vdd_mV, vref_mV, vref1_mV);10921092+ ret = mcp47feb02_init_scales_avail(data, vdd_uV, vref_uV, vref1_uV);10871093 if (ret)10881094 return dev_err_probe(dev, ret, "failed to init scales for ch %u\n", i);10891095 }···10971103 struct device *dev = &client->dev;10981104 struct mcp47feb02_data *data;10991105 struct iio_dev *indio_dev;11001100- int vref1_mV = 0;11011101- int vref_mV = 0;11021102- int vdd_mV;11031103- int ret;11061106+ int vref1_uV, vref_uV, vdd_uV, ret;1104110711051108 indio_dev = devm_iio_device_alloc(dev, sizeof(*data));11061109 if (!indio_dev)···11341143 if (ret < 0)11351144 return ret;1136114511371137- vdd_mV = ret / MILLI;11461146+ vdd_uV = ret;1138114711391148 ret = devm_regulator_get_enable_read_voltage(dev, "vref");11401149 if (ret > 0) {11411141- vref_mV = ret / MILLI;11501150+ vref_uV = ret;11421151 data->use_vref = true;11431152 } else {11531153+ vref_uV = 0;11441154 dev_dbg(dev, "using internal band gap as voltage reference.\n");11451155 dev_dbg(dev, "Vref is unavailable.\n");11461156 }···11491157 if (chip_features->have_ext_vref1) {11501158 ret = devm_regulator_get_enable_read_voltage(dev, "vref1");11511159 if (ret > 0) {11521152- vref1_mV = ret / MILLI;11601160+ vref1_uV = ret;11531161 data->use_vref1 = true;11541162 } else {11631163+ vref1_uV = 0;11551164 dev_dbg(dev, "using internal band gap as voltage reference 1.\n");11561165 dev_dbg(dev, "Vref1 is unavailable.\n");11571166 }···11621169 if (ret)11631170 return dev_err_probe(dev, ret, "Error initialising vref register\n");1164117111651165- ret = mcp47feb02_init_ch_scales(data, vdd_mV, vref_mV, vref1_mV);11721172+ ret = mcp47feb02_init_ch_scales(data, vdd_uV, vref_uV, vref1_uV);11661173 if (ret)11671174 return ret;11681175
+21-11
drivers/iio/gyro/mpu3050-core.c
···1129112911301130 ret = iio_trigger_register(mpu3050->trig);11311131 if (ret)11321132- return ret;11321132+ goto err_iio_trigger;1133113311341134 indio_dev->trig = iio_trigger_get(mpu3050->trig);1135113511361136 return 0;11371137+11381138+err_iio_trigger:11391139+ free_irq(mpu3050->irq, mpu3050->trig);11401140+11411141+ return ret;11371142}1138114311391144int mpu3050_common_probe(struct device *dev,···12261221 goto err_power_down;12271222 }1228122312291229- ret = iio_device_register(indio_dev);12301230- if (ret) {12311231- dev_err(dev, "device register failed\n");12321232- goto err_cleanup_buffer;12331233- }12341234-12351224 dev_set_drvdata(dev, indio_dev);1236122512371226 /* Check if we have an assigned IRQ to use as trigger */···12481249 pm_runtime_use_autosuspend(dev);12491250 pm_runtime_put(dev);1250125112521252+ ret = iio_device_register(indio_dev);12531253+ if (ret) {12541254+ dev_err(dev, "device register failed\n");12551255+ goto err_iio_device_register;12561256+ }12571257+12511258 return 0;1252125912531253-err_cleanup_buffer:12601260+err_iio_device_register:12611261+ pm_runtime_get_sync(dev);12621262+ pm_runtime_put_noidle(dev);12631263+ pm_runtime_disable(dev);12641264+ if (irq)12651265+ free_irq(mpu3050->irq, mpu3050->trig);12541266 iio_triggered_buffer_cleanup(indio_dev);12551267err_power_down:12561268 mpu3050_power_down(mpu3050);···12741264 struct iio_dev *indio_dev = dev_get_drvdata(dev);12751265 struct mpu3050 *mpu3050 = iio_priv(indio_dev);1276126612671267+ iio_device_unregister(indio_dev);12771268 pm_runtime_get_sync(dev);12781269 pm_runtime_put_noidle(dev);12791270 pm_runtime_disable(dev);12801280- iio_triggered_buffer_cleanup(indio_dev);12811271 if (mpu3050->irq)12821282- free_irq(mpu3050->irq, mpu3050);12831283- iio_device_unregister(indio_dev);12721272+ free_irq(mpu3050->irq, mpu3050->trig);12731273+ iio_triggered_buffer_cleanup(indio_dev);12841274 mpu3050_power_down(mpu3050);12851275}12861276
+4-4
drivers/iio/imu/adis16550.c
···643643 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:644644 switch (chan->type) {645645 case IIO_ANGL_VEL:646646- ret = adis16550_get_accl_filter_freq(st, val);646646+ ret = adis16550_get_gyro_filter_freq(st, val);647647 if (ret)648648 return ret;649649 return IIO_VAL_INT;650650 case IIO_ACCEL:651651- ret = adis16550_get_gyro_filter_freq(st, val);651651+ ret = adis16550_get_accl_filter_freq(st, val);652652 if (ret)653653 return ret;654654 return IIO_VAL_INT;···681681 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:682682 switch (chan->type) {683683 case IIO_ANGL_VEL:684684- return adis16550_set_accl_filter_freq(st, val);685685- case IIO_ACCEL:686684 return adis16550_set_gyro_filter_freq(st, val);685685+ case IIO_ACCEL:686686+ return adis16550_set_accl_filter_freq(st, val);687687 default:688688 return -EINVAL;689689 }
···225225 const struct st_lsm6dsx_reg *batch_reg;226226 u8 data;227227228228+ /* Only internal sensors have a FIFO ODR configuration register. */229229+ if (sensor->id >= ARRAY_SIZE(hw->settings->batch))230230+ return 0;231231+228232 batch_reg = &hw->settings->batch[sensor->id];229233 if (batch_reg->addr) {230234 int val;···862858 int i, ret;863859864860 for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {861861+ const struct iio_dev_attr **attrs;862862+865863 if (!hw->iio_devs[i])866864 continue;867865866866+ /*867867+ * For the accelerometer, allow setting FIFO sampling frequency868868+ * values different from the sensor sampling frequency, which869869+ * may be needed to keep FIFO data rate low while sampling870870+ * acceleration data at high rates for accurate event detection.871871+ */872872+ attrs = i == ST_LSM6DSX_ID_ACC ? st_lsm6dsx_buffer_attrs : NULL;868873 ret = devm_iio_kfifo_buffer_setup_ext(hw->dev, hw->iio_devs[i],869874 &st_lsm6dsx_buffer_ops,870870- st_lsm6dsx_buffer_attrs);875875+ attrs);871876 if (ret)872877 return ret;873878 }
···1919 struct hid_sensor_common common_attributes;2020 struct hid_sensor_hub_attribute_info quaternion;2121 struct {2222- s32 sampled_vals[4];2323- aligned_s64 timestamp;2222+ IIO_DECLARE_QUATERNION(s32, sampled_vals);2323+ /*2424+ * ABI regression avoidance: There are two copies of the same2525+ * timestamp in case of userspace depending on broken alignment2626+ * from older kernels.2727+ */2828+ aligned_s64 timestamp[2];2429 } scan;2530 int scale_pre_decml;2631 int scale_post_decml;···159154 if (!rot_state->timestamp)160155 rot_state->timestamp = iio_get_time_ns(indio_dev);161156162162- iio_push_to_buffers_with_timestamp(indio_dev, &rot_state->scan,163163- rot_state->timestamp);157157+ /*158158+ * ABI regression avoidance: IIO previously had an incorrect159159+ * implementation of iio_push_to_buffers_with_timestamp() that160160+ * put the timestamp in the last 8 bytes of the buffer, which161161+ * was incorrect according to the IIO ABI. To avoid breaking162162+ * userspace that may be depending on this broken behavior, we163163+ * put the timestamp in both the correct place [0] and the old164164+ * incorrect place [1].165165+ */166166+ rot_state->scan.timestamp[0] = rot_state->timestamp;167167+ rot_state->scan.timestamp[1] = rot_state->timestamp;168168+169169+ iio_push_to_buffers(indio_dev, &rot_state->scan);164170165171 rot_state->timestamp = 0;166172 }
+1-1
drivers/iio/pressure/abp2030pa.c
···520520 data->p_offset = div_s64(odelta * data->pmin, pdelta) - data->outmin;521521522522 if (data->irq > 0) {523523- ret = devm_request_irq(dev, irq, abp2_eoc_handler, IRQF_ONESHOT,523523+ ret = devm_request_irq(dev, irq, abp2_eoc_handler, 0,524524 dev_name(dev), data);525525 if (ret)526526 return ret;
+4-3
drivers/iio/proximity/rfd77402.c
···173173 struct i2c_client *client = data->client;174174 int val, ret;175175176176- if (data->irq_en) {177177- reinit_completion(&data->completion);176176+ if (data->irq_en)178177 return rfd77402_wait_for_irq(data);179179- }180178181179 /*182180 * As per RFD77402 datasheet section '3.1.1 Single Measure', the···201203 RFD77402_STATUS_MCPU_ON);202204 if (ret < 0)203205 return ret;206206+207207+ if (data->irq_en)208208+ reinit_completion(&data->completion);204209205210 ret = i2c_smbus_write_byte_data(client, RFD77402_CMD_R,206211 RFD77402_CMD_SINGLE |
···33config INTEL_MEI44 tristate "Intel Management Engine Interface"55 depends on PCI66+ depends on X86 || DRM_XE!=n || COMPILE_TEST67 default X86_64 || MATOM78 help89 The Intel Management Engine (Intel ME) provides Manageability,
+4-10
drivers/misc/mei/hw-me.c
···13371337 /* check if we need to start the dev */13381338 if (!mei_host_is_ready(dev)) {13391339 if (mei_hw_is_ready(dev)) {13401340- /* synchronized by dev mutex */13411341- if (waitqueue_active(&dev->wait_hw_ready)) {13421342- dev_dbg(&dev->dev, "we need to start the dev.\n");13431343- dev->recvd_hw_ready = true;13441344- wake_up(&dev->wait_hw_ready);13451345- } else if (dev->dev_state != MEI_DEV_UNINITIALIZED &&13461346- dev->dev_state != MEI_DEV_POWERING_DOWN &&13471347- dev->dev_state != MEI_DEV_POWER_DOWN) {13401340+ if (dev->dev_state == MEI_DEV_ENABLED) {13481341 dev_dbg(&dev->dev, "Force link reset.\n");13491342 schedule_work(&dev->reset_work);13501343 } else {13511351- dev_dbg(&dev->dev, "Ignore this interrupt in state = %d\n",13521352- dev->dev_state);13441344+ dev_dbg(&dev->dev, "we need to start the dev.\n");13451345+ dev->recvd_hw_ready = true;13461346+ wake_up(&dev->wait_hw_ready);13531347 }13541348 } else {13551349 dev_dbg(&dev->dev, "Spurious Interrupt\n");
+1-1
drivers/net/bonding/bond_main.c
···53265326 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP))53275327 continue;5328532853295329- if (bond_is_last_slave(bond, slave)) {53295329+ if (i + 1 == slaves_count) {53305330 skb2 = skb;53315331 skb_used = true;53325332 } else {
···13681368 struct airoha_eth *eth = ppe->eth;13691369 int err = 0;1370137013711371+ /* Netfilter flowtable can try to offload flower rules while not all13721372+ * the net_devices are registered or initialized. Delay offloading13731373+ * until all net_devices are registered in the system.13741374+ */13751375+ if (!test_bit(DEV_STATE_REGISTERED, ð->state))13761376+ return -EBUSY;13771377+13711378 mutex_lock(&flow_offload_mutex);1372137913731380 if (!eth->npu)
+52-24
drivers/net/ethernet/broadcom/bnxt/bnxt.c
···80458045 ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);80468046 if (!ulp_msix)80478047 bnxt_set_ulp_stat_ctxs(bp, 0);80488048+ else80498049+ bnxt_set_dflt_ulp_stat_ctxs(bp);8048805080498051 if (ulp_msix > bp->ulp_num_msix_want)80508052 ulp_msix = bp->ulp_num_msix_want;···86738671 struct hwrm_func_backing_store_qcaps_v2_output *resp;86748672 struct hwrm_func_backing_store_qcaps_v2_input *req;86758673 struct bnxt_ctx_mem_info *ctx = bp->ctx;86768676- u16 type;86748674+ u16 type, next_type = 0;86778675 int rc;8678867686798677 rc = hwrm_req_init(bp, req, HWRM_FUNC_BACKING_STORE_QCAPS_V2);···8689868786908688 resp = hwrm_req_hold(bp, req);8691868986928692- for (type = 0; type < BNXT_CTX_V2_MAX; ) {86908690+ for (type = 0; type < BNXT_CTX_V2_MAX; type = next_type) {86938691 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];86948692 u8 init_val, init_off, i;86958693 u32 max_entries;···87028700 if (rc)87038701 goto ctx_done;87048702 flags = le32_to_cpu(resp->flags);87058705- type = le16_to_cpu(resp->next_valid_type);87038703+ next_type = le16_to_cpu(resp->next_valid_type);87068704 if (!(flags & BNXT_CTX_MEM_TYPE_VALID)) {87078705 bnxt_free_one_ctx_mem(bp, ctxm, true);87088706 continue;···87178715 else87188716 continue;87198717 }87208720- ctxm->type = le16_to_cpu(resp->type);87188718+ ctxm->type = type;87218719 ctxm->entry_size = entry_size;87228720 ctxm->flags = flags;87238721 ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map);···1299412992 return bp->num_tc ? bp->tx_nr_rings / bp->num_tc : bp->tx_nr_rings;1299512993}12996129941299512995+static void bnxt_set_xdp_tx_rings(struct bnxt *bp)1299612996+{1299712997+ bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;1299812998+ bp->tx_nr_rings += bp->tx_nr_rings_xdp;1299912999+}1300013000+1300113001+static void bnxt_adj_tx_rings(struct bnxt *bp)1300213002+{1300313003+ /* Make adjustments if reserved TX rings are less than requested */1300413004+ bp->tx_nr_rings -= bp->tx_nr_rings_xdp;1300513005+ bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);1300613006+ if (bp->tx_nr_rings_xdp)1300713007+ bnxt_set_xdp_tx_rings(bp);1300813008+}1300913009+1299713010static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)1299813011{1299913012 int rc = 0;···1302613009 if (rc)1302713010 return rc;13028130111302913029- /* Make adjustments if reserved TX rings are less than requested */1303013030- bp->tx_nr_rings -= bp->tx_nr_rings_xdp;1303113031- bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);1303213032- if (bp->tx_nr_rings_xdp) {1303313033- bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;1303413034- bp->tx_nr_rings += bp->tx_nr_rings_xdp;1303513035- }1301213012+ bnxt_adj_tx_rings(bp);1303613013 rc = bnxt_alloc_mem(bp, irq_re_init);1303713014 if (rc) {1303813015 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc);···1544715436 return 0;1544815437}15449154381543915439+void bnxt_set_cp_rings(struct bnxt *bp, bool sh)1544015440+{1544115441+ int tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);1544215442+1544315443+ bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) :1544415444+ tx_cp + bp->rx_nr_rings;1544515445+}1544615446+1545015447int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)1545115448{1545215449 struct bnxt *bp = netdev_priv(dev);1545315450 bool sh = false;1545415454- int rc, tx_cp;1545115451+ int rc;15455154521545615453 if (tc > bp->max_tc) {1545715454 netdev_err(dev, "Too many traffic classes requested: %d. Max supported is %d.\n",···1549215473 bp->num_tc = 0;1549315474 }1549415475 bp->tx_nr_rings += bp->tx_nr_rings_xdp;1549515495- tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);1549615496- bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) :1549715497- tx_cp + bp->rx_nr_rings;1547615476+ bnxt_set_cp_rings(bp, sh);15498154771549915478 if (netif_running(bp->dev))1550015479 return bnxt_open_nic(bp, true, false);···1654216525 bp->tx_nr_rings = bnxt_tx_nr_rings(bp);1654316526}16544165271652816528+static void bnxt_adj_dflt_rings(struct bnxt *bp, bool sh)1652916529+{1653016530+ if (sh)1653116531+ bnxt_trim_dflt_sh_rings(bp);1653216532+ else1653316533+ bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings;1653416534+ bp->tx_nr_rings = bnxt_tx_nr_rings(bp);1653516535+ if (sh && READ_ONCE(bp->xdp_prog)) {1653616536+ bnxt_set_xdp_tx_rings(bp);1653716537+ bnxt_set_cp_rings(bp, true);1653816538+ }1653916539+}1654016540+1654516541static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)1654616542{1654716543 int dflt_rings, max_rx_rings, max_tx_rings, rc;···1658016550 return rc;1658116551 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings);1658216552 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings);1658316583- if (sh)1658416584- bnxt_trim_dflt_sh_rings(bp);1658516585- else1658616586- bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings;1658716587- bp->tx_nr_rings = bnxt_tx_nr_rings(bp);1655316553+1655416554+ bnxt_adj_dflt_rings(bp, sh);16588165551658916556 avail_msix = bnxt_get_max_func_irqs(bp) - bp->cp_nr_rings;1659016557 if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS) {···1659416567 rc = __bnxt_reserve_rings(bp);1659516568 if (rc && rc != -ENODEV)1659616569 netdev_warn(bp->dev, "Unable to reserve tx rings\n");1659716597- bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);1657016570+1657116571+ bnxt_adj_tx_rings(bp);1659816572 if (sh)1659916599- bnxt_trim_dflt_sh_rings(bp);1657316573+ bnxt_adj_dflt_rings(bp, true);16600165741660116575 /* Rings may have been trimmed, re-reserve the trimmed rings. */1660216576 if (bnxt_need_reserve_rings(bp)) {1660316577 rc = __bnxt_reserve_rings(bp);1660416578 if (rc && rc != -ENODEV)1660516579 netdev_warn(bp->dev, "2nd rings reservation failed.\n");1660616606- bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);1658016580+ bnxt_adj_tx_rings(bp);1660716581 }1660816582 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) {1660916583 bp->rx_nr_rings++;···1663816610 if (rc)1663916611 goto init_dflt_ring_err;16640166121664116641- bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);1661316613+ bnxt_adj_tx_rings(bp);16642166141664316615 bnxt_set_dflt_rfs(bp);1664416616
···197197 return 0;198198 }199199200200- for (i = 0; i <= ring->size_mask; i++) {200200+ for (i = 0; i < (ring->size_mask + 1) * FBNIC_BD_FRAG_COUNT; i++) {201201 u64 bd = le64_to_cpu(ring->desc[i]);202202203203 seq_printf(s, "%04x %#04llx %#014llx\n", i,
+3-3
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
···927927 /* Force DMA writes to flush before writing to tail */928928 dma_wmb();929929930930- writel(i, bdq->doorbell);930930+ writel(i * FBNIC_BD_FRAG_COUNT, bdq->doorbell);931931 }932932}933933···25642564 hpq->tail = 0;25652565 hpq->head = 0;2566256625672567- log_size = fls(hpq->size_mask);25672567+ log_size = fls(hpq->size_mask) + ilog2(FBNIC_BD_FRAG_COUNT);2568256825692569 /* Store descriptor ring address and size */25702570 fbnic_ring_wr32(hpq, FBNIC_QUEUE_BDQ_HPQ_BAL, lower_32_bits(hpq->dma));···25762576 if (!ppq->size_mask)25772577 goto write_ctl;2578257825792579- log_size = fls(ppq->size_mask);25792579+ log_size = fls(ppq->size_mask) + ilog2(FBNIC_BD_FRAG_COUNT);2580258025812581 /* Add enabling of PPQ to BDQ control */25822582 bdq_ctl |= FBNIC_QUEUE_BDQ_CTL_PPQ_ENABLE;
+1-1
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
···3838#define FBNIC_MAX_XDPQS 128u39394040/* These apply to TWQs, TCQ, RCQ */4141-#define FBNIC_QUEUE_SIZE_MIN 16u4141+#define FBNIC_QUEUE_SIZE_MIN 64u4242#define FBNIC_QUEUE_SIZE_MAX SZ_64K43434444#define FBNIC_TXQ_SIZE_DEFAULT 1024
+7
drivers/net/ethernet/microsoft/mana/mana_en.c
···766766 }767767768768 *frag_count = 1;769769+770770+ /* In the single-buffer path, napi_build_skb() must see the771771+ * actual backing allocation size so skb->truesize reflects772772+ * the full page (or higher-order page), not just the usable773773+ * packet area.774774+ */775775+ *alloc_size = PAGE_SIZE << get_order(*alloc_size);769776 return;770777 }771778
+4-10
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
···156156static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue);157157static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,158158 u32 rxmode, u32 chan);159159-static int stmmac_vlan_restore(struct stmmac_priv *priv);159159+static void stmmac_vlan_restore(struct stmmac_priv *priv);160160161161#ifdef CONFIG_DEBUG_FS162162static const struct net_device_ops stmmac_netdev_ops;···68596859 return ret;68606860}6861686168626862-static int stmmac_vlan_restore(struct stmmac_priv *priv)68626862+static void stmmac_vlan_restore(struct stmmac_priv *priv)68636863{68646864- int ret;68656865-68666864 if (!(priv->dev->features & NETIF_F_VLAN_FEATURES))68676867- return 0;68656865+ return;6868686668696867 if (priv->hw->num_vlan)68706868 stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw);6871686968726872- ret = stmmac_vlan_update(priv, priv->num_double_vlans);68736873- if (ret)68746874- netdev_err(priv->dev, "Failed to restore VLANs\n");68756875-68766876- return ret;68706870+ stmmac_vlan_update(priv, priv->num_double_vlans);68776871}6878687268796873static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf)
···105105#define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */106106#define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */107107108108-#define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */108108+#define XAXIDMA_BD_CTRL_LENGTH_MASK GENMASK(25, 0) /* Requested len */109109#define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */110110#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */111111#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */···130130#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */131131#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */132132133133-#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */133133+#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK GENMASK(25, 0) /* Actual len */134134#define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */135135#define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */136136#define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */
+4-5
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
···770770 * @first_bd: Index of first descriptor to clean up771771 * @nr_bds: Max number of descriptors to clean up772772 * @force: Whether to clean descriptors even if not complete773773- * @sizep: Pointer to a u32 filled with the total sum of all bytes774774- * in all cleaned-up descriptors. Ignored if NULL.773773+ * @sizep: Pointer to a u32 accumulating the total byte count of774774+ * completed packets (using skb->len). Ignored if NULL.775775 * @budget: NAPI budget (use 0 when not called from NAPI poll)776776 *777777 * Would either be called after a successful transmit operation, or after···805805 DMA_TO_DEVICE);806806807807 if (cur_p->skb && (status & XAXIDMA_BD_STS_COMPLETE_MASK)) {808808+ if (sizep)809809+ *sizep += cur_p->skb->len;808810 napi_consume_skb(cur_p->skb, budget);809811 packets++;810812 }···820818 wmb();821819 cur_p->cntrl = 0;822820 cur_p->status = 0;823823-824824- if (sizep)825825- *sizep += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;826821 }827822828823 if (!force) {
+6-1
drivers/net/phy/sfp.c
···480480{481481 /* Ubiquiti U-Fiber Instant module claims that support all transceiver482482 * types including 10G Ethernet which is not truth. So clear all claimed483483- * modes and set only one mode which module supports: 1000baseX_Full.483483+ * modes and set only one mode which module supports: 1000baseX_Full,484484+ * along with the Autoneg and pause bits.484485 */485486 linkmode_zero(caps->link_modes);486487 linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT,487488 caps->link_modes);489489+ linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, caps->link_modes);490490+ linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, caps->link_modes);491491+ linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, caps->link_modes);492492+488493 phy_interface_zero(caps->interfaces);489494 __set_bit(PHY_INTERFACE_MODE_1000BASEX, caps->interfaces);490495}
+9-11
drivers/net/virtio_net.c
···381381 struct xdp_buff **xsk_buffs;382382};383383384384-#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40385385-386384/* Control VQ buffers: protected by the rtnl lock */387385struct control_buf {388386 struct virtio_net_ctrl_hdr hdr;···484486485487 /* Must be last as it ends in a flexible-array member. */486488 TRAILING_OVERLAP(struct virtio_net_rss_config_trailer, rss_trailer, hash_key_data,487487- u8 rss_hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE];489489+ u8 rss_hash_key_data[NETDEV_RSS_KEY_LEN];488490 );489491};490492static_assert(offsetof(struct virtnet_info, rss_trailer.hash_key_data) ==···67066708 struct virtnet_info *vi;67076709 u16 max_queue_pairs;67086710 int mtu = 0;67116711+ u16 key_sz;6709671267106713 /* Find if host supports multiqueue/rss virtio_net device */67116714 max_queue_pairs = 1;···68416842 }6842684368436844 if (vi->has_rss || vi->has_rss_hash_report) {68446844- vi->rss_key_size =68456845- virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));68466846- if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {68476847- dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",68486848- vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);68496849- err = -EINVAL;68506850- goto free;68516851- }68456845+ key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));68466846+68476847+ vi->rss_key_size = min_t(u16, key_sz, NETDEV_RSS_KEY_LEN);68486848+ if (key_sz > vi->rss_key_size)68496849+ dev_warn(&vdev->dev,68506850+ "rss_max_key_size=%u exceeds driver limit %u, clamping\n",68516851+ key_sz, vi->rss_key_size);6852685268536853 vi->rss_hash_types_supported =68546854 virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
+4-2
drivers/net/vxlan/vxlan_core.c
···19651965 ns_olen = request->len - skb_network_offset(request) -19661966 sizeof(struct ipv6hdr) - sizeof(*ns);19671967 for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) {19681968- if (!ns->opt[i + 1]) {19681968+ if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) {19691969 kfree_skb(reply);19701970 return NULL;19711971 }19721972 if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) {19731973- daddr = ns->opt + i + sizeof(struct nd_opt_hdr);19731973+ if ((ns->opt[i + 1] << 3) >=19741974+ sizeof(struct nd_opt_hdr) + ETH_ALEN)19751975+ daddr = ns->opt + i + sizeof(struct nd_opt_hdr);19741976 break;19751977 }19761978 }
+7-8
drivers/net/wireless/ath/ath11k/dp_rx.c
···11// SPDX-License-Identifier: BSD-3-Clause-Clear22/*33 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.44- * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.44+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.55 */6677#include <linux/ieee80211.h>···11101110 struct ath11k_base *ab = ar->ab;11111111 struct ath11k_peer *peer;11121112 struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta);11131113+ struct dp_rx_tid *rx_tid;11131114 int vdev_id = arsta->arvif->vdev_id;11141114- dma_addr_t paddr;11151115- bool active;11161115 int ret;1117111611181117 spin_lock_bh(&ab->base_lock);···11231124 return -ENOENT;11241125 }1125112611261126- paddr = peer->rx_tid[params->tid].paddr;11271127- active = peer->rx_tid[params->tid].active;11271127+ rx_tid = &peer->rx_tid[params->tid];1128112811291129- if (!active) {11291129+ if (!rx_tid->active) {11301130 spin_unlock_bh(&ab->base_lock);11311131 return 0;11321132 }1133113311341134- ret = ath11k_peer_rx_tid_reo_update(ar, peer, peer->rx_tid, 1, 0, false);11341134+ ret = ath11k_peer_rx_tid_reo_update(ar, peer, rx_tid, 1, 0, false);11351135 spin_unlock_bh(&ab->base_lock);11361136 if (ret) {11371137 ath11k_warn(ab, "failed to update reo for rx tid %d: %d\n",···11391141 }1140114211411143 ret = ath11k_wmi_peer_rx_reorder_queue_setup(ar, vdev_id,11421142- params->sta->addr, paddr,11441144+ params->sta->addr,11451145+ rx_tid->paddr,11431146 params->tid, 1, 1);11441147 if (ret)11451148 ath11k_warn(ab, "failed to send wmi to delete rx tid %d\n",
···111111 IEEE80211_HE_MAC_CAP2_ACK_EN);112112}113113114114-static void iwl_mld_set_he_support(struct iwl_mld *mld,115115- struct ieee80211_vif *vif,116116- struct iwl_mac_config_cmd *cmd)114114+struct iwl_mld_mac_wifi_gen_sta_iter_data {115115+ struct ieee80211_vif *vif;116116+ struct iwl_mac_wifi_gen_support *support;117117+};118118+119119+static void iwl_mld_mac_wifi_gen_sta_iter(void *_data,120120+ struct ieee80211_sta *sta)117121{118118- if (vif->type == NL80211_IFTYPE_AP)119119- cmd->wifi_gen.he_ap_support = 1;120120- else121121- cmd->wifi_gen.he_support = 1;122122+ struct iwl_mld_sta *mld_sta = iwl_mld_sta_from_mac80211(sta);123123+ struct iwl_mld_mac_wifi_gen_sta_iter_data *data = _data;124124+ struct ieee80211_link_sta *link_sta;125125+ unsigned int link_id;126126+127127+ if (mld_sta->vif != data->vif)128128+ return;129129+130130+ for_each_sta_active_link(data->vif, sta, link_sta, link_id) {131131+ if (link_sta->he_cap.has_he)132132+ data->support->he_support = 1;133133+ if (link_sta->eht_cap.has_eht)134134+ data->support->eht_support = 1;135135+ }136136+}137137+138138+static void iwl_mld_set_wifi_gen(struct iwl_mld *mld,139139+ struct ieee80211_vif *vif,140140+ struct iwl_mac_wifi_gen_support *support)141141+{142142+ struct iwl_mld_mac_wifi_gen_sta_iter_data sta_iter_data = {143143+ .vif = vif,144144+ .support = support,145145+ };146146+ struct ieee80211_bss_conf *link_conf;147147+ unsigned int link_id;148148+149149+ switch (vif->type) {150150+ case NL80211_IFTYPE_MONITOR:151151+ /* for sniffer, set to HW capabilities */152152+ support->he_support = 1;153153+ support->eht_support = mld->trans->cfg->eht_supported;154154+ break;155155+ case NL80211_IFTYPE_AP:156156+ /* for AP set according to the link configs */157157+ for_each_vif_active_link(vif, link_conf, link_id) {158158+ support->he_ap_support |= link_conf->he_support;159159+ support->eht_support |= link_conf->eht_support;160160+ }161161+ break;162162+ default:163163+ /*164164+ * If we have MLO enabled, then the firmware needs to enable165165+ * address translation for the station(s) we add. That depends166166+ * on having EHT enabled in firmware, which in turn depends on167167+ * mac80211 in the iteration below.168168+ * However, mac80211 doesn't enable capabilities on the AP STA169169+ * until it has parsed the association response successfully,170170+ * so set EHT (and HE as a pre-requisite for EHT) when the vif171171+ * is an MLD.172172+ */173173+ if (ieee80211_vif_is_mld(vif)) {174174+ support->he_support = 1;175175+ support->eht_support = 1;176176+ }177177+178178+ ieee80211_iterate_stations_mtx(mld->hw,179179+ iwl_mld_mac_wifi_gen_sta_iter,180180+ &sta_iter_data);181181+ break;182182+ }122183}123184124185/* fill the common part for all interface types */···189128 u32 action)190129{191130 struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);192192- struct ieee80211_bss_conf *link_conf;193193- unsigned int link_id;194131195132 lockdep_assert_wiphy(mld->wiphy);196133···206147 cmd->nic_not_ack_enabled =207148 cpu_to_le32(!iwl_mld_is_nic_ack_enabled(mld, vif));208149209209- /* If we have MLO enabled, then the firmware needs to enable210210- * address translation for the station(s) we add. That depends211211- * on having EHT enabled in firmware, which in turn depends on212212- * mac80211 in the code below.213213- * However, mac80211 doesn't enable HE/EHT until it has parsed214214- * the association response successfully, so just skip all that215215- * and enable both when we have MLO.216216- */217217- if (ieee80211_vif_is_mld(vif)) {218218- iwl_mld_set_he_support(mld, vif, cmd);219219- cmd->wifi_gen.eht_support = 1;220220- return;221221- }222222-223223- for_each_vif_active_link(vif, link_conf, link_id) {224224- if (!link_conf->he_support)225225- continue;226226-227227- iwl_mld_set_he_support(mld, vif, cmd);228228-229229- /* EHT, if supported, was already set above */230230- break;231231- }150150+ iwl_mld_set_wifi_gen(mld, vif, &cmd->wifi_gen);232151}233152234153static void iwl_mld_fill_mac_cmd_sta(struct iwl_mld *mld,
+19
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
···1761176117621762 if (vif->type == NL80211_IFTYPE_STATION)17631763 iwl_mld_link_set_2mhz_block(mld, vif, sta);17641764+17651765+ if (sta->tdls) {17661766+ /*17671767+ * update MAC since wifi generation flags may change,17681768+ * we also update MAC on association to the AP via the17691769+ * vif assoc change17701770+ */17711771+ iwl_mld_mac_fw_action(mld, vif, FW_CTXT_ACTION_MODIFY);17721772+ }17731773+17641774 /* Now the link_sta's capabilities are set, update the FW */17651775 iwl_mld_config_tlc(mld, vif, sta);17661776···18821872 if (sta->tdls && iwl_mld_tdls_sta_count(mld) == 0) {18831873 /* just removed last TDLS STA, so enable PM */18841874 iwl_mld_update_mac_power(mld, vif, false);18751875+ }18761876+18771877+ if (sta->tdls) {18781878+ /*18791879+ * update MAC since wifi generation flags may change,18801880+ * we also update MAC on disassociation to the AP via18811881+ * the vif assoc change18821882+ */18831883+ iwl_mld_mac_fw_action(mld, vif, FW_CTXT_ACTION_MODIFY);18851884 }18861885 } else {18871886 return -EINVAL;
···739739740740 /* Ignore any BSS that was not seen in the last MLO scan */741741 if (ktime_before(link_conf->bss->ts_boottime,742742- mld->scan.last_mlo_scan_time))742742+ mld->scan.last_mlo_scan_start_time))743743 continue;744744745745 data[n_data].link_id = link_id;···945945 if (!mld_vif->authorized || hweight16(usable_links) <= 1)946946 return;947947948948- if (WARN(ktime_before(mld->scan.last_mlo_scan_time,948948+ if (WARN(ktime_before(mld->scan.last_mlo_scan_start_time,949949 ktime_sub_ns(ktime_get_boottime_ns(),950950 5ULL * NSEC_PER_SEC)),951951 "Last MLO scan was too long ago, can't select links\n"))
+5
drivers/net/wireless/intel/iwlwifi/mld/notif.c
···287287 * at least enough bytes to cover the structure listed in the CMD_VER_ENTRY.288288 */289289290290+CMD_VERSIONS(scan_start_notif,291291+ CMD_VER_ENTRY(1, iwl_umac_scan_start))290292CMD_VERSIONS(scan_complete_notif,291293 CMD_VER_ENTRY(1, iwl_umac_scan_complete))292294CMD_VERSIONS(scan_iter_complete_notif,···362360 link_id)363361DEFINE_SIMPLE_CANCELLATION(roc, iwl_roc_notif, activity)364362DEFINE_SIMPLE_CANCELLATION(scan_complete, iwl_umac_scan_complete, uid)363363+DEFINE_SIMPLE_CANCELLATION(scan_start, iwl_umac_scan_start, uid)365364DEFINE_SIMPLE_CANCELLATION(probe_resp_data, iwl_probe_resp_data_notif,366365 mac_id)367366DEFINE_SIMPLE_CANCELLATION(uapsd_misbehaving_ap, iwl_uapsd_misbehaving_ap_notif,···405402 RX_HANDLER_SYNC)406403 RX_HANDLER_NO_OBJECT(LEGACY_GROUP, BA_NOTIF, compressed_ba_notif,407404 RX_HANDLER_SYNC)405405+ RX_HANDLER_OF_SCAN(LEGACY_GROUP, SCAN_START_NOTIFICATION_UMAC,406406+ scan_start_notif)408407 RX_HANDLER_OF_SCAN(LEGACY_GROUP, SCAN_COMPLETE_UMAC,409408 scan_complete_notif)410409 RX_HANDLER_NO_OBJECT(LEGACY_GROUP, SCAN_ITERATION_COMPLETE_UMAC,
···2727void iwl_mld_handle_match_found_notif(struct iwl_mld *mld,2828 struct iwl_rx_packet *pkt);29293030+void iwl_mld_handle_scan_start_notif(struct iwl_mld *mld,3131+ struct iwl_rx_packet *pkt);3232+3033void iwl_mld_handle_scan_complete_notif(struct iwl_mld *mld,3134 struct iwl_rx_packet *pkt);3235···117114 * in jiffies.118115 * @last_start_time_jiffies: stores the last start time in jiffies119116 * (interface up/reset/resume).120120- * @last_mlo_scan_time: start time of the last MLO scan in nanoseconds since121121- * boot.117117+ * @last_mlo_scan_start_time: start time of the last MLO scan in nanoseconds118118+ * since boot.122119 */123120struct iwl_mld_scan {124121 /* Add here fields that need clean up on restart */···139136 void *cmd;140137 unsigned long last_6ghz_passive_jiffies;141138 unsigned long last_start_time_jiffies;142142- u64 last_mlo_scan_time;139139+ u64 last_mlo_scan_start_time;143140};144141145142/**
+1-1
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
···28072807 if (IS_ERR_OR_NULL(vif))28082808 return;2809280928102810- if (len < sizeof(struct iwl_scan_offload_match_info)) {28102810+ if (len < sizeof(struct iwl_scan_offload_match_info) + matches_len) {28112811 IWL_ERR(mvm, "Invalid scan match info notification\n");28122812 return;28132813 }
+2-1
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
···470470 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,471471 };472472473473- if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) {473473+ if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210 ||474474+ !mvm->trans->cfg->uhb_supported) {474475 IWL_DEBUG_RADIO(mvm, "UATS feature is not supported\n");475476 return;476477 }
···211211212212 timer_delete(&dev->cmd_timeout);213213 for (i = 0; i < count; i++) {214214+ if (unlikely(!skb_tailroom(dev->recv_skb)))215215+ skb_trim(dev->recv_skb, 0);216216+214217 skb_put_u8(dev->recv_skb, *data++);215218 if (!pn532_uart_rx_is_frame(dev->recv_skb))216219 continue;
···6666 dma_addr_t dma_buf;6767 size_t words = bytes / WORD_INBYTES;6868 int ret;6969- int value;6969+ unsigned int value;7070 char *data;71717272 if (bytes % WORD_INBYTES != 0) {···8080 }81818282 if (pufflag == 1 && flag == EFUSE_WRITE) {8383- memcpy(&value, val, bytes);8383+ memcpy(&value, val, sizeof(value));8484 if ((offset == EFUSE_PUF_START_OFFSET ||8585 offset == EFUSE_PUF_MID_OFFSET) &&8686 value & P_USER_0_64_UPPER_MASK) {···100100 if (!efuse)101101 return -ENOMEM;102102103103- data = dma_alloc_coherent(dev, sizeof(bytes),103103+ data = dma_alloc_coherent(dev, bytes,104104 &dma_buf, GFP_KERNEL);105105 if (!data) {106106 ret = -ENOMEM;···134134 if (flag == EFUSE_READ)135135 memcpy(val, data, bytes);136136efuse_access_err:137137- dma_free_coherent(dev, sizeof(bytes),137137+ dma_free_coherent(dev, bytes,138138 data, dma_buf);139139efuse_data_fail:140140 dma_free_coherent(dev, sizeof(struct xilinx_efuse),
+14-18
drivers/s390/crypto/zcrypt_msgtype6.c
···953953/*954954 * The request distributor calls this function if it picked the CEXxC955955 * device to handle a modexpo request.956956+ * This function assumes that ap_msg has been initialized with957957+ * ap_init_apmsg() and thus a valid buffer with the size of958958+ * ap_msg->bufsize is available within ap_msg. Also the caller has959959+ * to make sure ap_release_apmsg() is always called even on failure.956960 * @zq: pointer to zcrypt_queue structure that identifies the957961 * CEXxC device to the request distributor958962 * @mex: pointer to the modexpo request buffer···968964 struct ap_response_type *resp_type = &ap_msg->response;969965 int rc;970966971971- ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);972972- if (!ap_msg->msg)973973- return -ENOMEM;974974- ap_msg->bufsize = PAGE_SIZE;975967 ap_msg->receive = zcrypt_msgtype6_receive;976968 ap_msg->psmid = (((unsigned long)current->pid) << 32) +977969 atomic_inc_return(&zcrypt_step);978970 rc = icamex_msg_to_type6mex_msgx(zq, ap_msg, mex);979971 if (rc)980980- goto out_free;972972+ goto out;981973 resp_type->type = CEXXC_RESPONSE_TYPE_ICA;982974 init_completion(&resp_type->work);983975 rc = ap_queue_message(zq->queue, ap_msg);984976 if (rc)985985- goto out_free;977977+ goto out;986978 rc = wait_for_completion_interruptible(&resp_type->work);987979 if (rc == 0) {988980 rc = ap_msg->rc;···991991 ap_cancel_message(zq->queue, ap_msg);992992 }993993994994-out_free:995995- free_page((unsigned long)ap_msg->msg);996996- ap_msg->msg = NULL;994994+out:997995 return rc;998996}9999971000998/*1001999 * The request distributor calls this function if it picked the CEXxC10021000 * device to handle a modexpo_crt request.10011001+ * This function assumes that ap_msg has been initialized with10021002+ * ap_init_apmsg() and thus a valid buffer with the size of10031003+ * ap_msg->bufsize is available within ap_msg. Also the caller has10041004+ * to make sure ap_release_apmsg() is always called even on failure.10031005 * @zq: pointer to zcrypt_queue structure that identifies the10041006 * CEXxC device to the request distributor10051007 * @crt: pointer to the modexpoc_crt request buffer···10131011 struct ap_response_type *resp_type = &ap_msg->response;10141012 int rc;1015101310161016- ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);10171017- if (!ap_msg->msg)10181018- return -ENOMEM;10191019- ap_msg->bufsize = PAGE_SIZE;10201014 ap_msg->receive = zcrypt_msgtype6_receive;10211015 ap_msg->psmid = (((unsigned long)current->pid) << 32) +10221016 atomic_inc_return(&zcrypt_step);10231017 rc = icacrt_msg_to_type6crt_msgx(zq, ap_msg, crt);10241018 if (rc)10251025- goto out_free;10191019+ goto out;10261020 resp_type->type = CEXXC_RESPONSE_TYPE_ICA;10271021 init_completion(&resp_type->work);10281022 rc = ap_queue_message(zq->queue, ap_msg);10291023 if (rc)10301030- goto out_free;10241024+ goto out;10311025 rc = wait_for_completion_interruptible(&resp_type->work);10321026 if (rc == 0) {10331027 rc = ap_msg->rc;···10361038 ap_cancel_message(zq->queue, ap_msg);10371039 }1038104010391039-out_free:10401040- free_page((unsigned long)ap_msg->msg);10411041- ap_msg->msg = NULL;10411041+out:10421042 return rc;10431043}10441044
+12
drivers/spi/spi-amlogic-spifc-a4.c
···10661066 .finish_io_req = aml_sfc_ecc_finish_io_req,10671067};1068106810691069+static void aml_sfc_unregister_ecc_engine(void *data)10701070+{10711071+ struct nand_ecc_engine *eng = data;10721072+10731073+ nand_ecc_unregister_on_host_hw_engine(eng);10741074+}10751075+10691076static int aml_sfc_clk_init(struct aml_sfc *sfc)10701077{10711078 sfc->gate_clk = devm_clk_get_enabled(sfc->dev, "gate");···11551148 ret = nand_ecc_register_on_host_hw_engine(&sfc->ecc_eng);11561149 if (ret)11571150 return dev_err_probe(&pdev->dev, ret, "failed to register Aml host ecc engine.\n");11511151+11521152+ ret = devm_add_action_or_reset(dev, aml_sfc_unregister_ecc_engine,11531153+ &sfc->ecc_eng);11541154+ if (ret)11551155+ return dev_err_probe(dev, ret, "failed to add ECC unregister action\n");1158115611591157 ret = of_property_read_u32(np, "amlogic,rx-adj", &val);11601158 if (!ret)
+9-8
drivers/spi/spi-cadence-quadspi.c
···14831483 if (refcount_read(&cqspi->inflight_ops) == 0)14841484 return -ENODEV;1485148514861486- if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {14871487- ret = pm_runtime_resume_and_get(dev);14881488- if (ret) {14891489- dev_err(&mem->spi->dev, "resume failed with %d\n", ret);14901490- return ret;14911491- }14921492- }14931493-14941486 if (!refcount_read(&cqspi->refcount))14951487 return -EBUSY;14961488···14941502 return -EBUSY;14951503 }1496150415051505+ if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {15061506+ ret = pm_runtime_resume_and_get(dev);15071507+ if (ret) {15081508+ dev_err(&mem->spi->dev, "resume failed with %d\n", ret);15091509+ goto dec_inflight_refcount;15101510+ }15111511+ }15121512+14971513 ret = cqspi_mem_process(mem, op);1498151414991515 if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))···15101510 if (ret)15111511 dev_err(&mem->spi->dev, "operation failed with %d\n", ret);1512151215131513+dec_inflight_refcount:15131514 if (refcount_read(&cqspi->inflight_ops) > 1)15141515 refcount_dec(&cqspi->inflight_ops);15151516
+6-6
drivers/spi/spi-stm32-ospi.c
···928928 dma_cfg.dst_addr = ospi->regs_phys_base + OSPI_DR;929929 ret = stm32_ospi_dma_setup(ospi, &dma_cfg);930930 if (ret)931931- return ret;931931+ goto err_dma_free;932932933933 mutex_init(&ospi->lock);934934···965965 if (ret) {966966 /* Disable ospi */967967 writel_relaxed(0, ospi->regs_base + OSPI_CR);968968- goto err_pm_resume;968968+ goto err_reset_control;969969 }970970971971 pm_runtime_put_autosuspend(ospi->dev);972972973973 return 0;974974975975+err_reset_control:976976+ reset_control_release(ospi->rstc);975977err_pm_resume:976978 pm_runtime_put_sync_suspend(ospi->dev);977979978980err_pm_enable:979981 pm_runtime_force_suspend(ospi->dev);980982 mutex_destroy(&ospi->lock);983983+err_dma_free:981984 if (ospi->dma_chtx)982985 dma_release_channel(ospi->dma_chtx);983986 if (ospi->dma_chrx)···992989static void stm32_ospi_remove(struct platform_device *pdev)993990{994991 struct stm32_ospi *ospi = platform_get_drvdata(pdev);995995- int ret;996992997997- ret = pm_runtime_resume_and_get(ospi->dev);998998- if (ret < 0)999999- return;993993+ pm_runtime_resume_and_get(ospi->dev);10009941001995 spi_unregister_controller(ospi->ctrl);1002996 /* Disable ospi */
+27-5
drivers/thermal/thermal_core.c
···41414242static bool thermal_pm_suspended;43434444+static struct workqueue_struct *thermal_wq __ro_after_init;4545+4446/*4547 * Governor section: set of functions to handle thermal governors4648 *···315313 if (delay > HZ)316314 delay = round_jiffies_relative(delay);317315318318- mod_delayed_work(system_freezable_power_efficient_wq, &tz->poll_queue, delay);316316+ mod_delayed_work(thermal_wq, &tz->poll_queue, delay);319317}320318321319static void thermal_zone_recheck(struct thermal_zone_device *tz, int error)···16421640 device_del(&tz->device);16431641release_device:16441642 put_device(&tz->device);16431643+ wait_for_completion(&tz->removal);16451644remove_id:16461645 ida_free(&thermal_tz_ida, id);16471646free_tzp:···1788178517891786 guard(thermal_zone)(tz);1790178717881788+ /* If the thermal zone is going away, there's nothing to do. */17891789+ if (tz->state & TZ_STATE_FLAG_EXIT)17901790+ return;17911791+17911792 tz->state &= ~(TZ_STATE_FLAG_SUSPENDED | TZ_STATE_FLAG_RESUMING);1792179317931794 thermal_debug_tz_resume(tz);···18181811 }1819181218201813 tz->state |= TZ_STATE_FLAG_SUSPENDED;18141814+18151815+ /* Prevent new work from getting to the workqueue subsequently. */18161816+ cancel_delayed_work(&tz->poll_queue);18211817}1822181818231819static void thermal_pm_notify_prepare(void)···18391829{18401830 guard(thermal_zone)(tz);1841183118421842- cancel_delayed_work(&tz->poll_queue);18431843-18441832 reinit_completion(&tz->resume);18451833 tz->state |= TZ_STATE_FLAG_RESUMING;18461834···18481840 */18491841 INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_resume);18501842 /* Queue up the work without a delay. */18511851- mod_delayed_work(system_freezable_power_efficient_wq, &tz->poll_queue, 0);18431843+ mod_delayed_work(thermal_wq, &tz->poll_queue, 0);18521844}1853184518541846static void thermal_pm_notify_complete(void)···18711863 case PM_RESTORE_PREPARE:18721864 case PM_SUSPEND_PREPARE:18731865 thermal_pm_notify_prepare();18661866+ /*18671867+ * Allow any leftover thermal work items already on the18681868+ * worqueue to complete so they don't get in the way later.18691869+ */18701870+ flush_workqueue(thermal_wq);18741871 break;18751872 case PM_POST_HIBERNATION:18761873 case PM_POST_RESTORE:···19081895 if (result)19091896 goto error;1910189718981898+ thermal_wq = alloc_workqueue("thermal_events",18991899+ WQ_FREEZABLE | WQ_POWER_EFFICIENT | WQ_PERCPU, 0);19001900+ if (!thermal_wq) {19011901+ result = -ENOMEM;19021902+ goto unregister_netlink;19031903+ }19041904+19111905 result = thermal_register_governors();19121906 if (result)19131913- goto unregister_netlink;19071907+ goto destroy_workqueue;1914190819151909 thermal_class = kzalloc_obj(*thermal_class);19161910 if (!thermal_class) {···1944192419451925unregister_governors:19461926 thermal_unregister_governors();19271927+destroy_workqueue:19281928+ destroy_workqueue(thermal_wq);19471929unregister_netlink:19481930 thermal_netlink_exit();19491931error:
+1-1
drivers/thunderbolt/nhi.c
···10201020 * If power rails are sustainable for wakeup from S4 this10211021 * property is set by the BIOS.10221022 */10231023- if (device_property_read_u8(&pdev->dev, "WAKE_SUPPORTED", &val))10231023+ if (!device_property_read_u8(&pdev->dev, "WAKE_SUPPORTED", &val))10241024 return !!val;1025102510261026 return true;
+18
drivers/tty/vt/vt.c
···19091909 dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols;19101910 memcpy(dest, src, 2 * cols);19111911 }19121912+ /*19131913+ * If the console was resized while in the alternate screen,19141914+ * resize the saved unicode buffer to the current dimensions.19151915+ * On allocation failure new_uniscr is NULL, causing the old19161916+ * buffer to be freed and vc_uni_lines to be lazily rebuilt19171917+ * via vc_uniscr_check() when next needed.19181918+ */19191919+ if (vc->vc_saved_uni_lines &&19201920+ (vc->vc_saved_rows != vc->vc_rows ||19211921+ vc->vc_saved_cols != vc->vc_cols)) {19221922+ u32 **new_uniscr = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows);19231923+19241924+ if (new_uniscr)19251925+ vc_uniscr_copy_area(new_uniscr, vc->vc_cols, vc->vc_rows,19261926+ vc->vc_saved_uni_lines, cols, 0, rows);19271927+ vc_uniscr_free(vc->vc_saved_uni_lines);19281928+ vc->vc_saved_uni_lines = new_uniscr;19291929+ }19121930 vc_uniscr_set(vc, vc->vc_saved_uni_lines);19131931 vc->vc_saved_uni_lines = NULL;19141932 restore_cur(vc);
···2525 */2626int usb_offload_get(struct usb_device *udev)2727{2828- int ret;2828+ int ret = 0;29293030- usb_lock_device(udev);3131- if (udev->state == USB_STATE_NOTATTACHED) {3232- usb_unlock_device(udev);3030+ if (!usb_get_dev(udev))3331 return -ENODEV;3232+3333+ if (pm_runtime_get_if_active(&udev->dev) != 1) {3434+ ret = -EBUSY;3535+ goto err_rpm;3436 }35373636- if (udev->state == USB_STATE_SUSPENDED ||3737- udev->offload_at_suspend) {3838- usb_unlock_device(udev);3939- return -EBUSY;4040- }3838+ spin_lock(&udev->offload_lock);41394242- /*4343- * offload_usage could only be modified when the device is active, since4444- * it will alter the suspend flow of the device.4545- */4646- ret = usb_autoresume_device(udev);4747- if (ret < 0) {4848- usb_unlock_device(udev);4949- return ret;4040+ if (udev->offload_pm_locked) {4141+ ret = -EAGAIN;4242+ goto err;5043 }51445245 udev->offload_usage++;5353- usb_autosuspend_device(udev);5454- usb_unlock_device(udev);4646+4747+err:4848+ spin_unlock(&udev->offload_lock);4949+ pm_runtime_put_autosuspend(&udev->dev);5050+err_rpm:5151+ usb_put_dev(udev);55525653 return ret;5754}···6669 */6770int usb_offload_put(struct usb_device *udev)6871{6969- int ret;7272+ int ret = 0;70737171- usb_lock_device(udev);7272- if (udev->state == USB_STATE_NOTATTACHED) {7373- usb_unlock_device(udev);7474+ if (!usb_get_dev(udev))7475 return -ENODEV;7676+7777+ if (pm_runtime_get_if_active(&udev->dev) != 1) {7878+ ret = -EBUSY;7979+ goto err_rpm;7580 }76817777- if (udev->state == USB_STATE_SUSPENDED ||7878- udev->offload_at_suspend) {7979- usb_unlock_device(udev);8080- return -EBUSY;8181- }8282+ spin_lock(&udev->offload_lock);82838383- /*8484- * offload_usage could only be modified when the device is active, since8585- * it will alter the suspend flow of the device.8686- */8787- ret = usb_autoresume_device(udev);8888- if (ret < 0) {8989- usb_unlock_device(udev);9090- return ret;8484+ if (udev->offload_pm_locked) {8585+ ret = -EAGAIN;8686+ goto err;9187 }92889389 /* Drop the count when it wasn't 0, ignore the operation otherwise. */9490 if (udev->offload_usage)9591 udev->offload_usage--;9696- usb_autosuspend_device(udev);9797- usb_unlock_device(udev);9292+9393+err:9494+ spin_unlock(&udev->offload_lock);9595+ pm_runtime_put_autosuspend(&udev->dev);9696+err_rpm:9797+ usb_put_dev(udev);98989999 return ret;100100}···106112 * management.107113 *108114 * The caller must hold @udev's device lock. In addition, the caller should109109- * ensure downstream usb devices are all either suspended or marked as110110- * "offload_at_suspend" to ensure the correctness of the return value.115115+ * ensure the device itself and the downstream usb devices are all marked as116116+ * "offload_pm_locked" to ensure the correctness of the return value.111117 *112118 * Returns true on any offload activity, false otherwise.113119 */114120bool usb_offload_check(struct usb_device *udev) __must_hold(&udev->dev->mutex)115121{116122 struct usb_device *child;117117- bool active;123123+ bool active = false;118124 int port1;125125+126126+ if (udev->offload_usage)127127+ return true;119128120129 usb_hub_for_each_child(udev, port1, child) {121130 usb_lock_device(child);122131 active = usb_offload_check(child);123132 usb_unlock_device(child);133133+124134 if (active)125125- return true;135135+ break;126136 }127137128128- return !!udev->offload_usage;138138+ return active;129139}130140EXPORT_SYMBOL_GPL(usb_offload_check);141141+142142+/**143143+ * usb_offload_set_pm_locked - set the PM lock state of a USB device144144+ * @udev: the USB device to modify145145+ * @locked: the new lock state146146+ *147147+ * Setting @locked to true prevents offload_usage from being modified. This148148+ * ensures that offload activities cannot be started or stopped during critical149149+ * power management transitions, maintaining a stable state for the duration150150+ * of the transition.151151+ */152152+void usb_offload_set_pm_locked(struct usb_device *udev, bool locked)153153+{154154+ spin_lock(&udev->offload_lock);155155+ udev->offload_pm_locked = locked;156156+ spin_unlock(&udev->offload_lock);157157+}158158+EXPORT_SYMBOL_GPL(usb_offload_set_pm_locked);
+11-1
drivers/usb/core/phy.c
···114114struct usb_phy_roothub *usb_phy_roothub_alloc_usb3_phy(struct device *dev)115115{116116 struct usb_phy_roothub *phy_roothub;117117- int num_phys;117117+ int num_phys, usb2_phy_index;118118119119 if (!IS_ENABLED(CONFIG_GENERIC_PHY))120120 return NULL;···122122 num_phys = of_count_phandle_with_args(dev->of_node, "phys",123123 "#phy-cells");124124 if (num_phys <= 0)125125+ return NULL;126126+127127+ /*128128+ * If 'usb2-phy' is not present, usb_phy_roothub_alloc() added129129+ * all PHYs to the primary HCD's phy_roothub already, so skip130130+ * adding 'usb3-phy' here to avoid double use of that.131131+ */132132+ usb2_phy_index = of_property_match_string(dev->of_node, "phy-names",133133+ "usb2-phy");134134+ if (usb2_phy_index < 0)125135 return NULL;126136127137 phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL);
···11111212/* #define VERBOSE_DEBUG */13131414+#include <linux/cleanup.h>1415#include <linux/slab.h>1516#include <linux/kernel.h>1617#include <linux/module.h>···666665667666 struct f_rndis_opts *rndis_opts;668667 struct usb_os_desc_table *os_desc_table __free(kfree) = NULL;668668+ struct net_device *net __free(detach_gadget) = NULL;669669 struct usb_request *request __free(free_usb_request) = NULL;670670671671 if (!can_support_rndis(c))···680678 return -ENOMEM;681679 }682680683683- rndis_iad_descriptor.bFunctionClass = rndis_opts->class;684684- rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass;685685- rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol;681681+ scoped_guard(mutex, &rndis_opts->lock) {682682+ rndis_iad_descriptor.bFunctionClass = rndis_opts->class;683683+ rndis_iad_descriptor.bFunctionSubClass = rndis_opts->subclass;684684+ rndis_iad_descriptor.bFunctionProtocol = rndis_opts->protocol;686685687687- /*688688- * in drivers/usb/gadget/configfs.c:configfs_composite_bind()689689- * configurations are bound in sequence with list_for_each_entry,690690- * in each configuration its functions are bound in sequence691691- * with list_for_each_entry, so we assume no race condition692692- * with regard to rndis_opts->bound access693693- */694694- if (!rndis_opts->bound) {695695- gether_set_gadget(rndis_opts->net, cdev->gadget);696696- status = gether_register_netdev(rndis_opts->net);697697- if (status)698698- return status;699699- rndis_opts->bound = true;686686+ if (rndis_opts->bind_count == 0 && !rndis_opts->borrowed_net) {687687+ if (!device_is_registered(&rndis_opts->net->dev)) {688688+ gether_set_gadget(rndis_opts->net, cdev->gadget);689689+ status = gether_register_netdev(rndis_opts->net);690690+ } else691691+ status = gether_attach_gadget(rndis_opts->net, cdev->gadget);692692+693693+ if (status)694694+ return status;695695+ net = rndis_opts->net;696696+ }700697 }701698702699 us = usb_gstrings_attach(cdev, rndis_strings,···794793 }795794 rndis->notify_req = no_free_ptr(request);796795796796+ rndis_opts->bind_count++;797797+ retain_and_null_ptr(net);798798+797799 /* NOTE: all that is done without knowing or caring about798800 * the network link ... which is unavailable to this code799801 * until we're activated via set_alt().···813809 struct f_rndis_opts *opts;814810815811 opts = container_of(f, struct f_rndis_opts, func_inst);816816- if (opts->bound)812812+ if (device_is_registered(&opts->net->dev))817813 gether_cleanup(netdev_priv(opts->net));818814 else819815 free_netdev(opts->net);820820- opts->borrowed_net = opts->bound = true;816816+ opts->borrowed_net = true;821817 opts->net = net;822818}823819EXPORT_SYMBOL_GPL(rndis_borrow_net);···875871876872 opts = container_of(f, struct f_rndis_opts, func_inst);877873 if (!opts->borrowed_net) {878878- if (opts->bound)874874+ if (device_is_registered(&opts->net->dev))879875 gether_cleanup(netdev_priv(opts->net));880876 else881877 free_netdev(opts->net);···944940static void rndis_unbind(struct usb_configuration *c, struct usb_function *f)945941{946942 struct f_rndis *rndis = func_to_rndis(f);943943+ struct f_rndis_opts *rndis_opts;944944+945945+ rndis_opts = container_of(f->fi, struct f_rndis_opts, func_inst);947946948947 kfree(f->os_desc_table);949948 f->os_desc_n = 0;···954947955948 kfree(rndis->notify_req->buf);956949 usb_ep_free_request(rndis->notify, rndis->notify_req);950950+951951+ rndis_opts->bind_count--;952952+ if (rndis_opts->bind_count == 0 && !rndis_opts->borrowed_net)953953+ gether_detach_gadget(rndis_opts->net);957954}958955959956static struct usb_function *rndis_alloc(struct usb_function_instance *fi)
+35-28
drivers/usb/gadget/function/f_subset.c
···66 * Copyright (C) 2008 Nokia Corporation77 */8899+#include <linux/cleanup.h>910#include <linux/slab.h>1011#include <linux/kernel.h>1112#include <linux/module.h>···299298 struct usb_ep *ep;300299301300 struct f_gether_opts *gether_opts;301301+ struct net_device *net __free(detach_gadget) = NULL;302302303303 gether_opts = container_of(f->fi, struct f_gether_opts, func_inst);304304305305- /*306306- * in drivers/usb/gadget/configfs.c:configfs_composite_bind()307307- * configurations are bound in sequence with list_for_each_entry,308308- * in each configuration its functions are bound in sequence309309- * with list_for_each_entry, so we assume no race condition310310- * with regard to gether_opts->bound access311311- */312312- if (!gether_opts->bound) {313313- mutex_lock(&gether_opts->lock);314314- gether_set_gadget(gether_opts->net, cdev->gadget);315315- status = gether_register_netdev(gether_opts->net);316316- mutex_unlock(&gether_opts->lock);317317- if (status)318318- return status;319319- gether_opts->bound = true;320320- }305305+ scoped_guard(mutex, &gether_opts->lock)306306+ if (gether_opts->bind_count == 0 && !gether_opts->bound) {307307+ if (!device_is_registered(&gether_opts->net->dev)) {308308+ gether_set_gadget(gether_opts->net, cdev->gadget);309309+ status = gether_register_netdev(gether_opts->net);310310+ } else311311+ status = gether_attach_gadget(gether_opts->net, cdev->gadget);312312+313313+ if (status)314314+ return status;315315+ net = gether_opts->net;316316+ }321317322318 us = usb_gstrings_attach(cdev, geth_strings,323319 ARRAY_SIZE(geth_string_defs));···327329 /* allocate instance-specific interface IDs */328330 status = usb_interface_id(c, f);329331 if (status < 0)330330- goto fail;332332+ return status;331333 subset_data_intf.bInterfaceNumber = status;332332-333333- status = -ENODEV;334334335335 /* allocate instance-specific endpoints */336336 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc);337337 if (!ep)338338- goto fail;338338+ return -ENODEV;339339 geth->port.in_ep = ep;340340341341 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc);342342 if (!ep)343343- goto fail;343343+ return -ENODEV;344344 geth->port.out_ep = ep;345345346346 /* support all relevant hardware speeds... we expect that when···356360 status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function,357361 ss_eth_function, ss_eth_function);358362 if (status)359359- goto fail;363363+ return status;360364361365 /* NOTE: all that is done without knowing or caring about362366 * the network link ... which is unavailable to this code363367 * until we're activated via set_alt().364368 */365369370370+ gether_opts->bind_count++;371371+ retain_and_null_ptr(net);372372+366373 DBG(cdev, "CDC Subset: IN/%s OUT/%s\n",367374 geth->port.in_ep->name, geth->port.out_ep->name);368375 return 0;369369-370370-fail:371371- ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);372372-373373- return status;374376}375377376378static inline struct f_gether_opts *to_f_gether_opts(struct config_item *item)···411417 struct f_gether_opts *opts;412418413419 opts = container_of(f, struct f_gether_opts, func_inst);414414- if (opts->bound)420420+ if (device_is_registered(&opts->net->dev))415421 gether_cleanup(netdev_priv(opts->net));416422 else417423 free_netdev(opts->net);···443449static void geth_free(struct usb_function *f)444450{445451 struct f_gether *eth;452452+ struct f_gether_opts *opts;453453+454454+ opts = container_of(f->fi, struct f_gether_opts, func_inst);446455447456 eth = func_to_geth(f);457457+ scoped_guard(mutex, &opts->lock)458458+ opts->refcnt--;448459 kfree(eth);449460}450461451462static void geth_unbind(struct usb_configuration *c, struct usb_function *f)452463{464464+ struct f_gether_opts *opts;465465+466466+ opts = container_of(f->fi, struct f_gether_opts, func_inst);467467+453468 geth_string_defs[0].id = 0;454469 usb_free_all_descriptors(f);470470+471471+ opts->bind_count--;472472+ if (opts->bind_count == 0 && !opts->bound)473473+ gether_detach_gadget(opts->net);455474}456475457476static struct usb_function *geth_alloc(struct usb_function_instance *fi)
+37-10
drivers/usb/gadget/function/f_uac1_legacy.c
···360360static void f_audio_complete(struct usb_ep *ep, struct usb_request *req)361361{362362 struct f_audio *audio = req->context;363363- int status = req->status;364364- u32 data = 0;365363 struct usb_ep *out_ep = audio->out_ep;366364367367- switch (status) {368368-369369- case 0: /* normal completion? */370370- if (ep == out_ep)365365+ switch (req->status) {366366+ case 0:367367+ if (ep == out_ep) {371368 f_audio_out_ep_complete(ep, req);372372- else if (audio->set_con) {373373- memcpy(&data, req->buf, req->length);374374- audio->set_con->set(audio->set_con, audio->set_cmd,375375- le16_to_cpu(data));369369+ } else if (audio->set_con) {370370+ struct usb_audio_control *con = audio->set_con;371371+ u8 type = con->type;372372+ u32 data;373373+ bool valid_request = false;374374+375375+ switch (type) {376376+ case UAC_FU_MUTE: {377377+ u8 value;378378+379379+ if (req->actual == sizeof(value)) {380380+ memcpy(&value, req->buf, sizeof(value));381381+ data = value;382382+ valid_request = true;383383+ }384384+ break;385385+ }386386+ case UAC_FU_VOLUME: {387387+ __le16 value;388388+389389+ if (req->actual == sizeof(value)) {390390+ memcpy(&value, req->buf, sizeof(value));391391+ data = le16_to_cpu(value);392392+ valid_request = true;393393+ }394394+ break;395395+ }396396+ }397397+398398+ if (valid_request)399399+ con->set(con, audio->set_cmd, data);400400+ else401401+ usb_ep_set_halt(ep);402402+376403 audio->set_con = NULL;377404 }378405 break;
+36-3
drivers/usb/gadget/function/f_uvc.c
···413413{414414 int ret;415415416416+ guard(mutex)(&uvc->lock);417417+ if (uvc->func_unbound) {418418+ dev_dbg(&uvc->vdev.dev, "skipping function deactivate (unbound)\n");419419+ return;420420+ }421421+416422 if ((ret = usb_function_deactivate(&uvc->func)) < 0)417423 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);418424}···437431438432static DEVICE_ATTR_RO(function_name);439433434434+static void uvc_vdev_release(struct video_device *vdev)435435+{436436+ struct uvc_device *uvc = video_get_drvdata(vdev);437437+438438+ /* Signal uvc_function_unbind() that the video device has been released */439439+ if (uvc->vdev_release_done)440440+ complete(uvc->vdev_release_done);441441+}442442+440443static int441444uvc_register_video(struct uvc_device *uvc)442445{···458443 uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;459444 uvc->vdev.fops = &uvc_v4l2_fops;460445 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops;461461- uvc->vdev.release = video_device_release_empty;446446+ uvc->vdev.release = uvc_vdev_release;462447 uvc->vdev.vfl_dir = VFL_DIR_TX;463448 uvc->vdev.lock = &uvc->video.mutex;464449 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;···674659 int ret = -EINVAL;675660676661 uvcg_info(f, "%s()\n", __func__);662662+ scoped_guard(mutex, &uvc->lock)663663+ uvc->func_unbound = false;677664678665 opts = fi_to_f_uvc_opts(f->fi);679666 /* Sanity check the streaming endpoint module parameters. */···1005988static void uvc_function_unbind(struct usb_configuration *c,1006989 struct usb_function *f)1007990{991991+ DECLARE_COMPLETION_ONSTACK(vdev_release_done);1008992 struct usb_composite_dev *cdev = c->cdev;1009993 struct uvc_device *uvc = to_uvc(f);1010994 struct uvc_video *video = &uvc->video;1011995 long wait_ret = 1;996996+ bool connected;10129971013998 uvcg_info(f, "%s()\n", __func__);999999+ scoped_guard(mutex, &uvc->lock) {10001000+ uvc->func_unbound = true;10011001+ uvc->vdev_release_done = &vdev_release_done;10021002+ connected = uvc->func_connected;10031003+ }1014100410151005 kthread_cancel_work_sync(&video->hw_submit);10161006···10301006 * though the video device removal uevent. Allow some time for the10311007 * application to close out before things get deleted.10321008 */10331033- if (uvc->func_connected) {10091009+ if (connected) {10341010 uvcg_dbg(f, "waiting for clean disconnect\n");10351011 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue,10361012 uvc->func_connected == false, msecs_to_jiffies(500));···10411017 video_unregister_device(&uvc->vdev);10421018 v4l2_device_unregister(&uvc->v4l2_dev);1043101910441044- if (uvc->func_connected) {10201020+ scoped_guard(mutex, &uvc->lock)10211021+ connected = uvc->func_connected;10221022+10231023+ if (connected) {10451024 /*10461025 * Wait for the release to occur to ensure there are no longer any10471026 * pending operations that may cause panics when resources are cleaned···10551028 uvc->func_connected == false, msecs_to_jiffies(1000));10561029 uvcg_dbg(f, "done waiting for release with ret: %ld\n", wait_ret);10571030 }10311031+10321032+ /* Wait for the video device to be released */10331033+ wait_for_completion(&vdev_release_done);10341034+ uvc->vdev_release_done = NULL;1058103510591036 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);10601037 kfree(uvc->control_buf);···10781047 return ERR_PTR(-ENOMEM);1079104810801049 mutex_init(&uvc->video.mutex);10501050+ mutex_init(&uvc->lock);10511051+ uvc->func_unbound = true;10811052 uvc->state = UVC_STATE_DISCONNECTED;10821053 init_waitqueue_head(&uvc->func_connected_queue);10831054 opts = fi_to_f_uvc_opts(fi);
+15-6
drivers/usb/gadget/function/u_ecm.h
···15151616#include <linux/usb/composite.h>17171818+/**1919+ * struct f_ecm_opts - ECM function options2020+ * @func_inst: USB function instance.2121+ * @net: The net_device associated with the ECM function.2222+ * @bound: True if the net_device is shared and pre-registered during the2323+ * legacy composite driver's bind phase (e.g., multi.c). If false,2424+ * the ECM function will register the net_device during its own2525+ * bind phase.2626+ * @bind_count: Tracks the number of configurations the ECM function is2727+ * bound to, preventing double-registration of the @net device.2828+ * @lock: Protects the data from concurrent access by configfs read/write2929+ * and create symlink/remove symlink operations.3030+ * @refcnt: Reference counter for the function instance.3131+ */1832struct f_ecm_opts {1933 struct usb_function_instance func_inst;2034 struct net_device *net;2135 bool bound;3636+ int bind_count;22372323- /*2424- * Read/write access to configfs attributes is handled by configfs.2525- *2626- * This is to protect the data from concurrent access by read/write2727- * and create symlink/remove symlink.2828- */2938 struct mutex lock;3039 int refcnt;3140};
+15-6
drivers/usb/gadget/function/u_eem.h
···15151616#include <linux/usb/composite.h>17171818+/**1919+ * struct f_eem_opts - EEM function options2020+ * @func_inst: USB function instance.2121+ * @net: The net_device associated with the EEM function.2222+ * @bound: True if the net_device is shared and pre-registered during the2323+ * legacy composite driver's bind phase (e.g., multi.c). If false,2424+ * the EEM function will register the net_device during its own2525+ * bind phase.2626+ * @bind_count: Tracks the number of configurations the EEM function is2727+ * bound to, preventing double-registration of the @net device.2828+ * @lock: Protects the data from concurrent access by configfs read/write2929+ * and create symlink/remove symlink operations.3030+ * @refcnt: Reference counter for the function instance.3131+ */1832struct f_eem_opts {1933 struct usb_function_instance func_inst;2034 struct net_device *net;2135 bool bound;3636+ int bind_count;22372323- /*2424- * Read/write access to configfs attributes is handled by configfs.2525- *2626- * This is to protect the data from concurrent access by read/write2727- * and create symlink/remove symlink.2828- */2938 struct mutex lock;3039 int refcnt;3140};
···15151616#include <linux/usb/composite.h>17171818+/**1919+ * struct f_gether_opts - subset function options2020+ * @func_inst: USB function instance.2121+ * @net: The net_device associated with the subset function.2222+ * @bound: True if the net_device is shared and pre-registered during the2323+ * legacy composite driver's bind phase (e.g., multi.c). If false,2424+ * the subset function will register the net_device during its own2525+ * bind phase.2626+ * @bind_count: Tracks the number of configurations the subset function is2727+ * bound to, preventing double-registration of the @net device.2828+ * @lock: Protects the data from concurrent access by configfs read/write2929+ * and create symlink/remove symlink operations.3030+ * @refcnt: Reference counter for the function instance.3131+ */1832struct f_gether_opts {1933 struct usb_function_instance func_inst;2034 struct net_device *net;2135 bool bound;2222-2323- /*2424- * Read/write access to configfs attributes is handled by configfs.2525- *2626- * This is to protect the data from concurrent access by read/write2727- * and create symlink/remove symlink.2828- */3636+ int bind_count;2937 struct mutex lock;3038 int refcnt;3139};
+15-6
drivers/usb/gadget/function/u_ncm.h
···15151616#include <linux/usb/composite.h>17171818+/**1919+ * struct f_ncm_opts - NCM function options2020+ * @func_inst: USB function instance.2121+ * @net: The net_device associated with the NCM function.2222+ * @bind_count: Tracks the number of configurations the NCM function is2323+ * bound to, preventing double-registration of the @net device.2424+ * @ncm_interf_group: ConfigFS group for NCM interface.2525+ * @ncm_os_desc: USB OS descriptor for NCM.2626+ * @ncm_ext_compat_id: Extended compatibility ID.2727+ * @lock: Protects the data from concurrent access by configfs read/write2828+ * and create symlink/remove symlink operations.2929+ * @refcnt: Reference counter for the function instance.3030+ * @max_segment_size: Maximum segment size.3131+ */1832struct f_ncm_opts {1933 struct usb_function_instance func_inst;2034 struct net_device *net;···3723 struct config_group *ncm_interf_group;3824 struct usb_os_desc ncm_os_desc;3925 char ncm_ext_compat_id[16];4040- /*4141- * Read/write access to configfs attributes is handled by configfs.4242- *4343- * This is to protect the data from concurrent access by read/write4444- * and create symlink/remove symlink.4545- */2626+4627 struct mutex lock;4728 int refcnt;4829
+23-8
drivers/usb/gadget/function/u_rndis.h
···15151616#include <linux/usb/composite.h>17171818+/**1919+ * struct f_rndis_opts - RNDIS function options2020+ * @func_inst: USB function instance.2121+ * @vendor_id: Vendor ID.2222+ * @manufacturer: Manufacturer string.2323+ * @net: The net_device associated with the RNDIS function.2424+ * @bind_count: Tracks the number of configurations the RNDIS function is2525+ * bound to, preventing double-registration of the @net device.2626+ * @borrowed_net: True if the net_device is shared and pre-registered during2727+ * the legacy composite driver's bind phase (e.g., multi.c).2828+ * If false, the RNDIS function will register the net_device2929+ * during its own bind phase.3030+ * @rndis_interf_group: ConfigFS group for RNDIS interface.3131+ * @rndis_os_desc: USB OS descriptor for RNDIS.3232+ * @rndis_ext_compat_id: Extended compatibility ID.3333+ * @class: USB class.3434+ * @subclass: USB subclass.3535+ * @protocol: USB protocol.3636+ * @lock: Protects the data from concurrent access by configfs read/write3737+ * and create symlink/remove symlink operations.3838+ * @refcnt: Reference counter for the function instance.3939+ */1840struct f_rndis_opts {1941 struct usb_function_instance func_inst;2042 u32 vendor_id;2143 const char *manufacturer;2244 struct net_device *net;2323- bool bound;4545+ int bind_count;2446 bool borrowed_net;25472648 struct config_group *rndis_interf_group;···5230 u8 class;5331 u8 subclass;5432 u8 protocol;5555-5656- /*5757- * Read/write access to configfs attributes is handled by configfs.5858- *5959- * This is to protect the data from concurrent access by read/write6060- * and create symlink/remove symlink.6161- */6233 struct mutex lock;6334 int refcnt;6435};
···462462463463 /* Report reset and disconnect events to the driver */464464 if (dum->ints_enabled && (disconnect || reset)) {465465- stop_activity(dum);466465 ++dum->callback_usage;466466+ /*467467+ * stop_activity() can drop dum->lock, so it must468468+ * not come between the dum->ints_enabled test469469+ * and the ++dum->callback_usage.470470+ */471471+ stop_activity(dum);467472 spin_unlock(&dum->lock);468473 if (reset)469474 usb_gadget_udc_reset(&dum->gadget, dum->driver);···913908 spin_lock_irqsave(&dum->lock, flags);914909 dum->pullup = (value != 0);915910 set_link_state(dum_hcd);916916- if (value == 0) {917917- /*918918- * Emulate synchronize_irq(): wait for callbacks to finish.919919- * This seems to be the best place to emulate the call to920920- * synchronize_irq() that's in usb_gadget_remove_driver().921921- * Doing it in dummy_udc_stop() would be too late since it922922- * is called after the unbind callback and unbind shouldn't923923- * be invoked until all the other callbacks are finished.924924- */925925- while (dum->callback_usage > 0) {926926- spin_unlock_irqrestore(&dum->lock, flags);927927- usleep_range(1000, 2000);928928- spin_lock_irqsave(&dum->lock, flags);929929- }930930- }931911 spin_unlock_irqrestore(&dum->lock, flags);932912933913 usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));···935945936946 spin_lock_irq(&dum->lock);937947 dum->ints_enabled = enable;948948+ if (!enable) {949949+ /*950950+ * Emulate synchronize_irq(): wait for callbacks to finish.951951+ * This has to happen after emulated interrupts are disabled952952+ * (dum->ints_enabled is clear) and before the unbind callback,953953+ * just like the call to synchronize_irq() in954954+ * gadget/udc/core:gadget_unbind_driver().955955+ */956956+ while (dum->callback_usage > 0) {957957+ spin_unlock_irq(&dum->lock);958958+ usleep_range(1000, 2000);959959+ spin_lock_irq(&dum->lock);960960+ }961961+ }938962 spin_unlock_irq(&dum->lock);939963}940964···15381534 /* rescan to continue with any other queued i/o */15391535 if (rescan)15401536 goto top;15371537+15381538+ /* request not fully transferred; stop iterating to15391539+ * preserve data ordering across queued requests.15401540+ */15411541+ if (req->req.actual < req->req.length)15421542+ break;15411543 }15421544 return sent;15431545}
+2-2
drivers/usb/host/ehci-brcm.c
···3131 int res;32323333 /* Wait for next microframe (every 125 usecs) */3434- res = readl_relaxed_poll_timeout(&ehci->regs->frame_index, val,3535- val != frame_idx, 1, 130);3434+ res = readl_relaxed_poll_timeout_atomic(&ehci->regs->frame_index,3535+ val, val != frame_idx, 1, 130);3636 if (res)3737 ehci_err(ehci, "Error waiting for SOF\n");3838 udelay(delay);
+3-15
drivers/usb/host/xhci-sideband.c
···9393static void9494__xhci_sideband_remove_interrupter(struct xhci_sideband *sb)9595{9696- struct usb_device *udev;9797-9896 lockdep_assert_held(&sb->mutex);999710098 if (!sb->ir)···100102101103 xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir);102104 sb->ir = NULL;103103- udev = sb->vdev->udev;104104-105105- if (udev->state != USB_STATE_NOTATTACHED)106106- usb_offload_put(udev);107105}108106109107/* sideband api functions */···285291 * Allow other drivers, such as usb controller driver, to check if there are286292 * any sideband activity on the host controller. This information could be used287293 * for power management or other forms of resource management. The caller should288288- * ensure downstream usb devices are all either suspended or marked as289289- * "offload_at_suspend" to ensure the correctness of the return value.294294+ * ensure downstream usb devices are all marked as "offload_pm_locked" to ensure295295+ * the correctness of the return value.290296 *291297 * Returns true on any active sideband existence, false otherwise.292298 */···322328xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg,323329 bool ip_autoclear, u32 imod_interval, int intr_num)324330{325325- int ret = 0;326326- struct usb_device *udev;327327-328331 if (!sb || !sb->xhci)329332 return -ENODEV;330333···339348 if (!sb->ir)340349 return -ENOMEM;341350342342- udev = sb->vdev->udev;343343- ret = usb_offload_get(udev);344344-345351 sb->ir->ip_autoclear = ip_autoclear;346352347347- return ret;353353+ return 0;348354}349355EXPORT_SYMBOL_GPL(xhci_sideband_create_interrupter);350356
+5-2
drivers/usb/misc/usbio.c
···614614 usb_fill_bulk_urb(usbio->urb, udev, usbio->rx_pipe, usbio->rxbuf,615615 usbio->rxbuf_len, usbio_bulk_recv, usbio);616616 ret = usb_submit_urb(usbio->urb, GFP_KERNEL);617617- if (ret)618618- return dev_err_probe(dev, ret, "Submitting usb urb\n");617617+ if (ret) {618618+ dev_err_probe(dev, ret, "Submitting usb urb\n");619619+ goto err_free_urb;620620+ }619621620622 mutex_lock(&usbio->ctrl_mutex);621623···665663err_unlock:666664 mutex_unlock(&usbio->ctrl_mutex);667665 usb_kill_urb(usbio->urb);666666+err_free_urb:668667 usb_free_urb(usbio->urb);669668670669 return ret;
···686686687687 alt->adev.dev.bus = &typec_bus;688688689689- /* Plug alt modes need a class to generate udev events. */690690- if (is_typec_plug(parent))691691- alt->adev.dev.class = &typec_class;692692-693689 ret = device_register(&alt->adev.dev);694690 if (ret) {695691 dev_err(parent, "failed to register alternate mode (%d)\n",
+7-2
drivers/usb/typec/ucsi/ucsi.c
···4343 if (cci & UCSI_CCI_BUSY)4444 return;45454646- if (UCSI_CCI_CONNECTOR(cci))4747- ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci));4646+ if (UCSI_CCI_CONNECTOR(cci)) {4747+ if (UCSI_CCI_CONNECTOR(cci) <= ucsi->cap.num_connectors)4848+ ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci));4949+ else5050+ dev_err(ucsi->dev, "bogus connector number in CCI: %lu\n",5151+ UCSI_CCI_CONNECTOR(cci));5252+ }48534954 if (cci & UCSI_CCI_ACK_COMPLETE &&5055 test_and_clear_bit(ACK_PENDING, &ucsi->flags))
···646646}647647648648/**649649- * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them649649+ * __mpage_writepages - walk the list of dirty pages of the given address space650650+ * & writepage() all of them650651 * @mapping: address space structure to write651652 * @wbc: subtract the number of written pages from *@wbc->nr_to_write652653 * @get_block: the filesystem's block mapper function.654654+ * @write_folio: handler to call for each folio before calling655655+ * mpage_write_folio()653656 *654657 * This is a library function, which implements the writepages()655655- * address_space_operation.658658+ * address_space_operation. It calls @write_folio handler for each folio. If659659+ * the handler returns value > 0, it calls mpage_write_folio() to do the660660+ * folio writeback.656661 */657662int658658-mpage_writepages(struct address_space *mapping,659659- struct writeback_control *wbc, get_block_t get_block)663663+__mpage_writepages(struct address_space *mapping,664664+ struct writeback_control *wbc, get_block_t get_block,665665+ int (*write_folio)(struct folio *folio,666666+ struct writeback_control *wbc))660667{661668 struct mpage_data mpd = {662669 .get_block = get_block,···673666 int error;674667675668 blk_start_plug(&plug);676676- while ((folio = writeback_iter(mapping, wbc, folio, &error)))669669+ while ((folio = writeback_iter(mapping, wbc, folio, &error))) {670670+ if (write_folio) {671671+ error = write_folio(folio, wbc);672672+ /*673673+ * == 0 means folio is handled, < 0 means error. In674674+ * both cases hand back control to writeback_iter()675675+ */676676+ if (error <= 0)677677+ continue;678678+ /* Let mpage_write_folio() handle the folio. */679679+ }677680 error = mpage_write_folio(wbc, folio, &mpd);681681+ }678682 if (mpd.bio)679683 mpage_bio_submit_write(mpd.bio);680684 blk_finish_plug(&plug);681685 return error;682686}683683-EXPORT_SYMBOL(mpage_writepages);687687+EXPORT_SYMBOL(__mpage_writepages);
+4
fs/smb/client/fs_context.c
···588588 while (IS_DELIM(*cursor1))589589 cursor1++;590590591591+ /* exit in case of only delimiters */592592+ if (!*cursor1)593593+ return NULL;594594+591595 /* copy the first letter */592596 *cursor2 = *cursor1;593597
···18541854 * target hook is sleepable, we'll go through tasks trace RCU GP and18551855 * then "classic" RCU GP; this need for chaining tasks trace and18561856 * classic RCU GPs is designated by setting bpf_link->sleepable flag18571857+ *18581858+ * For non-sleepable tracepoint links we go through SRCU gp instead,18591859+ * since RCU is not used in that case. Sleepable tracepoints still18601860+ * follow the scheme above.18571861 */18581862 void (*dealloc_deferred)(struct bpf_link *link);18591863 int (*detach)(struct bpf_link *link);
+3
include/linux/cgroup-defs.h
···609609 /* used to wait for offlining of csses */610610 wait_queue_head_t offline_waitq;611611612612+ /* used by cgroup_rmdir() to wait for dying tasks to leave */613613+ wait_queue_head_t dying_populated_waitq;614614+612615 /* used to schedule release agent */613616 struct work_struct release_agent_work;614617
+5-7
include/linux/gpio/gpio-nomadik.h
···114114}115115116116/**117117- * enum prcm_gpiocr_reg_index118118- * Used to reference an PRCM GPIOCR register address.117117+ * enum prcm_gpiocr_reg_index - Used to reference a PRCM GPIOCR register address.119118 */120119enum prcm_gpiocr_reg_index {121120 PRCM_IDX_GPIOCR1,···122123 PRCM_IDX_GPIOCR3123124};124125/**125125- * enum prcm_gpiocr_altcx_index126126- * Used to reference an Other alternate-C function.126126+ * enum prcm_gpiocr_altcx_index - Used to reference an Other alternate-C function.127127 */128128enum prcm_gpiocr_altcx_index {129129 PRCM_IDX_GPIOCR_ALTC1,···133135};134136135137/**136136- * struct prcm_gpio_altcx - Other alternate-C function138138+ * struct prcm_gpiocr_altcx - Other alternate-C function137139 * @used: other alternate-C function availability138140 * @reg_index: PRCM GPIOCR register index used to control the function139141 * @control_bit: PRCM GPIOCR bit used to control the function···145147} __packed;146148147149/**148148- * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin150150+ * struct prcm_gpiocr_altcx_pin_desc - Other alternate-C pin149151 * @pin: The pin number150152 * @altcx: array of other alternate-C[1-4] functions151153 */···191193 * numbering.192194 * @npins: The number of entries in @pins.193195 * @functions: The functions supported on this SoC.194194- * @nfunction: The number of entries in @functions.196196+ * @nfunctions: The number of entries in @functions.195197 * @groups: An array describing all pin groups the pin SoC supports.196198 * @ngroups: The number of entries in @groups.197199 * @altcx_pins: The pins that support Other alternate-C function on this SoC
+12
include/linux/iio/iio.h
···931931#define IIO_DECLARE_DMA_BUFFER_WITH_TS(type, name, count) \932932 __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(IIO_DMA_MINALIGN)933933934934+/**935935+ * IIO_DECLARE_QUATERNION() - Declare a quaternion element936936+ * @type: element type of the individual vectors937937+ * @name: identifier name938938+ *939939+ * Quaternions are a vector composed of 4 elements (W, X, Y, Z). Use this macro940940+ * to declare a quaternion element in a struct to ensure proper alignment in941941+ * an IIO buffer.942942+ */943943+#define IIO_DECLARE_QUATERNION(type, name) \944944+ type name[4] __aligned(sizeof(type) * 4)945945+934946struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);935947936948/* The information at the returned address is guaranteed to be cacheline aligned */
+2-1
include/linux/iommu.h
···980980static inline void iommu_iotlb_sync(struct iommu_domain *domain,981981 struct iommu_iotlb_gather *iotlb_gather)982982{983983- if (domain->ops->iotlb_sync)983983+ if (domain->ops->iotlb_sync &&984984+ likely(iotlb_gather->start < iotlb_gather->end))984985 domain->ops->iotlb_sync(domain, iotlb_gather);985986986987 iommu_iotlb_gather_init(iotlb_gather);
+2-2
include/linux/lis3lv02d.h
···3030 * @default_rate: Default sampling rate. 0 means reset default3131 * @setup_resources: Interrupt line setup call back function3232 * @release_resources: Interrupt line release call back function3333- * @st_min_limits[3]: Selftest acceptance minimum values3434- * @st_max_limits[3]: Selftest acceptance maximum values3333+ * @st_min_limits: Selftest acceptance minimum values (x, y, z)3434+ * @st_max_limits: Selftest acceptance maximum values (x, y, z)3535 * @irq2: Irq line 2 number3636 *3737 * Platform data is used to setup the sensor chip. Meaning of the different
···991010/**1111 * struct timbgpio_platform_data - Platform data of the Timberdale GPIO driver1212- * @gpio_base The number of the first GPIO pin, set to -1 for1212+ * @gpio_base: The number of the first GPIO pin, set to -1 for1313 * dynamic number allocation.1414- * @nr_pins Number of pins that is supported by the hardware (1-32)1515- * @irq_base If IRQ is supported by the hardware, this is the base1414+ * @nr_pins: Number of pins that is supported by the hardware (1-32)1515+ * @irq_base: If IRQ is supported by the hardware, this is the base1616 * number of IRQ:s. One IRQ per pin will be used. Set to1717 * -1 if IRQ:s is not supported.1818 */
+20
include/linux/tracepoint.h
···122122{123123 return tp->ext && tp->ext->faultable;124124}125125+/*126126+ * Run RCU callback with the appropriate grace period wait for non-faultable127127+ * tracepoints, e.g., those used in atomic context.128128+ */129129+static inline void call_tracepoint_unregister_atomic(struct rcu_head *rcu, rcu_callback_t func)130130+{131131+ call_srcu(&tracepoint_srcu, rcu, func);132132+}133133+/*134134+ * Run RCU callback with the appropriate grace period wait for faultable135135+ * tracepoints, e.g., those used in syscall context.136136+ */137137+static inline void call_tracepoint_unregister_syscall(struct rcu_head *rcu, rcu_callback_t func)138138+{139139+ call_rcu_tasks_trace(rcu, func);140140+}125141#else126142static inline void tracepoint_synchronize_unregister(void)127143{ }···145129{146130 return false;147131}132132+static inline void call_tracepoint_unregister_atomic(struct rcu_head *rcu, rcu_callback_t func)133133+{ }134134+static inline void call_tracepoint_unregister_syscall(struct rcu_head *rcu, rcu_callback_t func)135135+{ }148136#endif149137150138#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+8-2
include/linux/usb.h
···2121#include <linux/completion.h> /* for struct completion */2222#include <linux/sched.h> /* for current && schedule_timeout */2323#include <linux/mutex.h> /* for struct mutex */2424+#include <linux/spinlock.h> /* for spinlock_t */2425#include <linux/pm_runtime.h> /* for runtime PM */25262627struct usb_device;···637636 * @do_remote_wakeup: remote wakeup should be enabled638637 * @reset_resume: needs reset instead of resume639638 * @port_is_suspended: the upstream port is suspended (L2 or U3)640640- * @offload_at_suspend: offload activities during suspend is enabled.639639+ * @offload_pm_locked: prevents offload_usage changes during PM transitions.641640 * @offload_usage: number of offload activities happening on this usb device.641641+ * @offload_lock: protects offload_usage and offload_pm_locked642642 * @slot_id: Slot ID assigned by xHCI643643 * @l1_params: best effor service latency for USB2 L1 LPM state, and L1 timeout.644644 * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout.···728726 unsigned do_remote_wakeup:1;729727 unsigned reset_resume:1;730728 unsigned port_is_suspended:1;731731- unsigned offload_at_suspend:1;729729+ unsigned offload_pm_locked:1;732730 int offload_usage;731731+ spinlock_t offload_lock;733732 enum usb_link_tunnel_mode tunnel_mode;734733 struct device_link *usb4_link;735734···852849int usb_offload_get(struct usb_device *udev);853850int usb_offload_put(struct usb_device *udev);854851bool usb_offload_check(struct usb_device *udev);852852+void usb_offload_set_pm_locked(struct usb_device *udev, bool locked);855853#else856854857855static inline int usb_offload_get(struct usb_device *udev)···861857{ return 0; }862858static inline bool usb_offload_check(struct usb_device *udev)863859{ return false; }860860+static inline void usb_offload_set_pm_locked(struct usb_device *udev, bool locked)861861+{ }864862#endif865863866864extern int usb_disable_lpm(struct usb_device *udev);
···7979 if (io_has_work(ctx))8080 goto out_wake;8181 /* got events since we started waiting, min timeout is done */8282- if (iowq->cq_min_tail != READ_ONCE(ctx->rings->cq.tail))8383- goto out_wake;8484- /* if we have any events and min timeout expired, we're done */8585- if (io_cqring_events(ctx))8686- goto out_wake;8282+ scoped_guard(rcu) {8383+ struct io_rings *rings = io_get_rings(ctx);87848585+ if (iowq->cq_min_tail != READ_ONCE(rings->cq.tail))8686+ goto out_wake;8787+ /* if we have any events and min timeout expired, we're done */8888+ if (io_cqring_events(ctx))8989+ goto out_wake;9090+ }8891 /*8992 * If using deferred task_work running and application is waiting on9093 * more than one request, ensure we reset it now where we are switching···189186 struct ext_arg *ext_arg)190187{191188 struct io_wait_queue iowq;192192- struct io_rings *rings = ctx->rings;189189+ struct io_rings *rings;193190 ktime_t start_time;194194- int ret;191191+ int ret, nr_wait;195192196193 min_events = min_t(int, min_events, ctx->cq_entries);197194···204201205202 if (unlikely(test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)))206203 io_cqring_do_overflow_flush(ctx);207207- if (__io_cqring_events_user(ctx) >= min_events)204204+205205+ rcu_read_lock();206206+ rings = io_get_rings(ctx);207207+ if (__io_cqring_events_user(ctx) >= min_events) {208208+ rcu_read_unlock();208209 return 0;210210+ }209211210212 init_waitqueue_func_entry(&iowq.wq, io_wake_function);211213 iowq.wq.private = current;212214 INIT_LIST_HEAD(&iowq.wq.entry);213215 iowq.ctx = ctx;214214- iowq.cq_tail = READ_ONCE(ctx->rings->cq.head) + min_events;215215- iowq.cq_min_tail = READ_ONCE(ctx->rings->cq.tail);216216+ iowq.cq_tail = READ_ONCE(rings->cq.head) + min_events;217217+ iowq.cq_min_tail = READ_ONCE(rings->cq.tail);218218+ nr_wait = (int) iowq.cq_tail - READ_ONCE(rings->cq.tail);219219+ rcu_read_unlock();220220+ rings = NULL;216221 iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);217222 iowq.hit_timeout = 0;218223 iowq.min_timeout = ext_arg->min_time;···251240 trace_io_uring_cqring_wait(ctx, min_events);252241 do {253242 unsigned long check_cq;254254- int nr_wait;255255-256256- /* if min timeout has been hit, don't reset wait count */257257- if (!iowq.hit_timeout)258258- nr_wait = (int) iowq.cq_tail -259259- READ_ONCE(ctx->rings->cq.tail);260260- else261261- nr_wait = 1;262243263244 if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) {264245 atomic_set(&ctx->cq_wait_nr, nr_wait);···301298 break;302299 }303300 cond_resched();301301+302302+ /* if min timeout has been hit, don't reset wait count */303303+ if (!iowq.hit_timeout)304304+ scoped_guard(rcu)305305+ nr_wait = (int) iowq.cq_tail -306306+ READ_ONCE(io_get_rings(ctx)->cq.tail);307307+ else308308+ nr_wait = 1;304309 } while (1);305310306311 if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))307312 finish_wait(&ctx->cq_wait, &iowq.wq);308313 restore_saved_sigmask_unless(ret == -EINTR);309314310310- return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;315315+ guard(rcu)();316316+ return READ_ONCE(io_get_rings(ctx)->cq.head) == READ_ONCE(io_get_rings(ctx)->cq.tail) ? ret : 0;311317}
···32613261 bpf_link_dealloc(link);32623262}3263326332643264+static bool bpf_link_is_tracepoint(struct bpf_link *link)32653265+{32663266+ /*32673267+ * Only these combinations support a tracepoint bpf_link.32683268+ * BPF_LINK_TYPE_TRACING raw_tp progs are hardcoded to use32693269+ * bpf_raw_tp_link_lops and thus dealloc_deferred(), see32703270+ * bpf_raw_tp_link_attach().32713271+ */32723272+ return link->type == BPF_LINK_TYPE_RAW_TRACEPOINT ||32733273+ (link->type == BPF_LINK_TYPE_TRACING && link->attach_type == BPF_TRACE_RAW_TP);32743274+}32753275+32643276static void bpf_link_defer_dealloc_mult_rcu_gp(struct rcu_head *rcu)32653277{32663278 if (rcu_trace_implies_rcu_gp())···32913279 if (link->prog)32923280 ops->release(link);32933281 if (ops->dealloc_deferred) {32943294- /* Schedule BPF link deallocation, which will only then32823282+ /*32833283+ * Schedule BPF link deallocation, which will only then32953284 * trigger putting BPF program refcount.32963285 * If underlying BPF program is sleepable or BPF link's target32973286 * attach hookpoint is sleepable or otherwise requires RCU GPs32983287 * to ensure link and its underlying BPF program is not32993288 * reachable anymore, we need to first wait for RCU tasks33003300- * trace sync, and then go through "classic" RCU grace period32893289+ * trace sync, and then go through "classic" RCU grace period.32903290+ *32913291+ * For tracepoint BPF links, we need to go through SRCU grace32923292+ * period wait instead when non-faultable tracepoint is used. We32933293+ * don't need to chain SRCU grace period waits, however, for the32943294+ * faultable case, since it exclusively uses RCU Tasks Trace.33013295 */33023296 if (link->sleepable || (link->prog && link->prog->sleepable))33033297 call_rcu_tasks_trace(&link->rcu, bpf_link_defer_dealloc_mult_rcu_gp);32983298+ /* We need to do a SRCU grace period wait for non-faultable tracepoint BPF links. */32993299+ else if (bpf_link_is_tracepoint(link))33003300+ call_tracepoint_unregister_atomic(&link->rcu, bpf_link_defer_dealloc_rcu_gp);33043301 else33053302 call_rcu(&link->rcu, bpf_link_defer_dealloc_rcu_gp);33063303 } else if (ops->dealloc) {
+32-5
kernel/bpf/verifier.c
···617617 insn->imm == BPF_LOAD_ACQ;618618}619619620620+static bool is_atomic_fetch_insn(const struct bpf_insn *insn)621621+{622622+ return BPF_CLASS(insn->code) == BPF_STX &&623623+ BPF_MODE(insn->code) == BPF_ATOMIC &&624624+ (insn->imm & BPF_FETCH);625625+}626626+620627static int __get_spi(s32 off)621628{622629 return (-off - 1) / BPF_REG_SIZE;···44544447 * dreg still needs precision before this insn44554448 */44564449 }44574457- } else if (class == BPF_LDX || is_atomic_load_insn(insn)) {44584458- if (!bt_is_reg_set(bt, dreg))44504450+ } else if (class == BPF_LDX ||44514451+ is_atomic_load_insn(insn) ||44524452+ is_atomic_fetch_insn(insn)) {44534453+ u32 load_reg = dreg;44544454+44554455+ /*44564456+ * Atomic fetch operation writes the old value into44574457+ * a register (sreg or r0) and if it was tracked for44584458+ * precision, propagate to the stack slot like we do44594459+ * in regular ldx.44604460+ */44614461+ if (is_atomic_fetch_insn(insn))44624462+ load_reg = insn->imm == BPF_CMPXCHG ?44634463+ BPF_REG_0 : sreg;44644464+44654465+ if (!bt_is_reg_set(bt, load_reg))44594466 return 0;44604460- bt_clear_reg(bt, dreg);44674467+ bt_clear_reg(bt, load_reg);4461446844624469 /* scalars can only be spilled into stack w/o losing precision.44634470 * Load from any other memory can be zero extended.···79267905 } else if (reg->type == CONST_PTR_TO_MAP) {79277906 err = check_ptr_to_map_access(env, regs, regno, off, size, t,79287907 value_regno);79297929- } else if (base_type(reg->type) == PTR_TO_BUF) {79087908+ } else if (base_type(reg->type) == PTR_TO_BUF &&79097909+ !type_may_be_null(reg->type)) {79307910 bool rdonly_mem = type_is_rdonly_mem(reg->type);79317911 u32 *max_access;79327912···1993719915 * since someone could have accessed through (ptr - k), or1993819916 * even done ptr -= k in a register, to get a safe access.1993919917 */1994019940- if (rold->range > rcur->range)1991819918+ if (rold->range < 0 || rcur->range < 0) {1991919919+ /* special case for [BEYOND|AT]_PKT_END */1992019920+ if (rold->range != rcur->range)1992119921+ return false;1992219922+ } else if (rold->range > rcur->range) {1994119923 return false;1992419924+ }1994219925 /* If the offsets don't match, we can't trust our alignment;1994319926 * nor can we be sure that we won't fall out of range.1994419927 */
+85-3
kernel/cgroup/cgroup.c
···21262126#endif2127212721282128 init_waitqueue_head(&cgrp->offline_waitq);21292129+ init_waitqueue_head(&cgrp->dying_populated_waitq);21292130 INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent);21302131}21312132···62256224 return 0;62266225};6227622662276227+/**62286228+ * cgroup_drain_dying - wait for dying tasks to leave before rmdir62296229+ * @cgrp: the cgroup being removed62306230+ *62316231+ * cgroup.procs and cgroup.threads use css_task_iter which filters out62326232+ * PF_EXITING tasks so that userspace doesn't see tasks that have already been62336233+ * reaped via waitpid(). However, cgroup_has_tasks() - which tests whether the62346234+ * cgroup has non-empty css_sets - is only updated when dying tasks pass through62356235+ * cgroup_task_dead() in finish_task_switch(). This creates a window where62366236+ * cgroup.procs reads empty but cgroup_has_tasks() is still true, making rmdir62376237+ * fail with -EBUSY from cgroup_destroy_locked() even though userspace sees no62386238+ * tasks.62396239+ *62406240+ * This function aligns cgroup_has_tasks() with what userspace can observe. If62416241+ * cgroup_has_tasks() but the task iterator sees nothing (all remaining tasks are62426242+ * PF_EXITING), we wait for cgroup_task_dead() to finish processing them. As the62436243+ * window between PF_EXITING and cgroup_task_dead() is short, the wait is brief.62446244+ *62456245+ * This function only concerns itself with this cgroup's own dying tasks.62466246+ * Whether the cgroup has children is cgroup_destroy_locked()'s problem.62476247+ *62486248+ * Each cgroup_task_dead() kicks the waitqueue via cset->cgrp_links, and we62496249+ * retry the full check from scratch.62506250+ *62516251+ * Must be called with cgroup_mutex held.62526252+ */62536253+static int cgroup_drain_dying(struct cgroup *cgrp)62546254+ __releases(&cgroup_mutex) __acquires(&cgroup_mutex)62556255+{62566256+ struct css_task_iter it;62576257+ struct task_struct *task;62586258+ DEFINE_WAIT(wait);62596259+62606260+ lockdep_assert_held(&cgroup_mutex);62616261+retry:62626262+ if (!cgroup_has_tasks(cgrp))62636263+ return 0;62646264+62656265+ /* Same iterator as cgroup.threads - if any task is visible, it's busy */62666266+ css_task_iter_start(&cgrp->self, 0, &it);62676267+ task = css_task_iter_next(&it);62686268+ css_task_iter_end(&it);62696269+62706270+ if (task)62716271+ return -EBUSY;62726272+62736273+ /*62746274+ * All remaining tasks are PF_EXITING and will pass through62756275+ * cgroup_task_dead() shortly. Wait for a kick and retry.62766276+ *62776277+ * cgroup_has_tasks() can't transition from false to true while we're62786278+ * holding cgroup_mutex, but the true to false transition happens62796279+ * under css_set_lock (via cgroup_task_dead()). We must retest and62806280+ * prepare_to_wait() under css_set_lock. Otherwise, the transition62816281+ * can happen between our first test and prepare_to_wait(), and we62826282+ * sleep with no one to wake us.62836283+ */62846284+ spin_lock_irq(&css_set_lock);62856285+ if (!cgroup_has_tasks(cgrp)) {62866286+ spin_unlock_irq(&css_set_lock);62876287+ return 0;62886288+ }62896289+ prepare_to_wait(&cgrp->dying_populated_waitq, &wait,62906290+ TASK_UNINTERRUPTIBLE);62916291+ spin_unlock_irq(&css_set_lock);62926292+ mutex_unlock(&cgroup_mutex);62936293+ schedule();62946294+ finish_wait(&cgrp->dying_populated_waitq, &wait);62956295+ mutex_lock(&cgroup_mutex);62966296+ goto retry;62976297+}62986298+62286299int cgroup_rmdir(struct kernfs_node *kn)62296300{62306301 struct cgroup *cgrp;···63066233 if (!cgrp)63076234 return 0;6308623563096309- ret = cgroup_destroy_locked(cgrp);63106310- if (!ret)63116311- TRACE_CGROUP_PATH(rmdir, cgrp);62366236+ ret = cgroup_drain_dying(cgrp);62376237+ if (!ret) {62386238+ ret = cgroup_destroy_locked(cgrp);62396239+ if (!ret)62406240+ TRACE_CGROUP_PATH(rmdir, cgrp);62416241+ }6312624263136243 cgroup_kn_unlock(kn);63146244 return ret;···7071699570726996static void do_cgroup_task_dead(struct task_struct *tsk)70736997{69986998+ struct cgrp_cset_link *link;70746999 struct css_set *cset;70757000 unsigned long flags;70767001···70847007 /* matches the signal->live check in css_task_iter_advance() */70857008 if (thread_group_leader(tsk) && atomic_read(&tsk->signal->live))70867009 list_add_tail(&tsk->cg_list, &cset->dying_tasks);70107010+70117011+ /* kick cgroup_drain_dying() waiters, see cgroup_rmdir() */70127012+ list_for_each_entry(link, &cset->cgrp_links, cgrp_link)70137013+ if (waitqueue_active(&link->cgrp->dying_populated_waitq))70147014+ wake_up(&link->cgrp->dying_populated_waitq);7087701570887016 if (dl_task(tsk))70897017 dec_dl_tasks_cs(tsk);
+20-9
kernel/cgroup/cpuset.c
···29882988 struct cgroup_subsys_state *css;29892989 struct cpuset *cs, *oldcs;29902990 struct task_struct *task;29912991- bool cpus_updated, mems_updated;29912991+ bool setsched_check;29922992 int ret;2993299329942994 /* used later by cpuset_attach() */···30033003 if (ret)30043004 goto out_unlock;3005300530063006- cpus_updated = !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus);30073007- mems_updated = !nodes_equal(cs->effective_mems, oldcs->effective_mems);30063006+ /*30073007+ * Skip rights over task setsched check in v2 when nothing changes,30083008+ * migration permission derives from hierarchy ownership in30093009+ * cgroup_procs_write_permission()).30103010+ */30113011+ setsched_check = !cpuset_v2() ||30123012+ !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus) ||30133013+ !nodes_equal(cs->effective_mems, oldcs->effective_mems);30143014+30153015+ /*30163016+ * A v1 cpuset with tasks will have no CPU left only when CPU hotplug30173017+ * brings the last online CPU offline as users are not allowed to empty30183018+ * cpuset.cpus when there are active tasks inside. When that happens,30193019+ * we should allow tasks to migrate out without security check to make30203020+ * sure they will be able to run after migration.30213021+ */30223022+ if (!is_in_v2_mode() && cpumask_empty(oldcs->effective_cpus))30233023+ setsched_check = false;3008302430093025 cgroup_taskset_for_each(task, css, tset) {30103026 ret = task_can_attach(task);30113027 if (ret)30123028 goto out_unlock;3013302930143014- /*30153015- * Skip rights over task check in v2 when nothing changes,30163016- * migration permission derives from hierarchy ownership in30173017- * cgroup_procs_write_permission()).30183018- */30193019- if (!cpuset_v2() || (cpus_updated || mems_updated)) {30303030+ if (setsched_check) {30203031 ret = security_task_setscheduler(task);30213032 if (ret)30223033 goto out_unlock;
+2
kernel/power/em_netlink.c
···109109110110 id = nla_get_u32(info->attrs[DEV_ENERGYMODEL_A_PERF_DOMAIN_PERF_DOMAIN_ID]);111111 pd = em_perf_domain_get_by_id(id);112112+ if (!pd)113113+ return -EINVAL;112114113115 __em_nl_get_pd_size(pd, &msg_sz);114116 msg = genlmsg_new(msg_sz, GFP_KERNEL);
···11101110 p->scx.dsq = dsq;1111111111121112 /*11131113- * scx.ddsp_dsq_id and scx.ddsp_enq_flags are only relevant on the11141114- * direct dispatch path, but we clear them here because the direct11151115- * dispatch verdict may be overridden on the enqueue path during e.g.11161116- * bypass.11171117- */11181118- p->scx.ddsp_dsq_id = SCX_DSQ_INVALID;11191119- p->scx.ddsp_enq_flags = 0;11201120-11211121- /*11221113 * We're transitioning out of QUEUEING or DISPATCHING. store_release to11231114 * match waiters' load_acquire.11241115 */···12741283 p->scx.ddsp_enq_flags = enq_flags;12751284}1276128512861286+/*12871287+ * Clear @p direct dispatch state when leaving the scheduler.12881288+ *12891289+ * Direct dispatch state must be cleared in the following cases:12901290+ * - direct_dispatch(): cleared on the synchronous enqueue path, deferred12911291+ * dispatch keeps the state until consumed12921292+ * - process_ddsp_deferred_locals(): cleared after consuming deferred state,12931293+ * - do_enqueue_task(): cleared on enqueue fallbacks where the dispatch12941294+ * verdict is ignored (local/global/bypass)12951295+ * - dequeue_task_scx(): cleared after dispatch_dequeue(), covering deferred12961296+ * cancellation and holding_cpu races12971297+ * - scx_disable_task(): cleared for queued wakeup tasks, which are excluded by12981298+ * the scx_bypass() loop, so that stale state is not reused by a subsequent12991299+ * scheduler instance13001300+ */13011301+static inline void clear_direct_dispatch(struct task_struct *p)13021302+{13031303+ p->scx.ddsp_dsq_id = SCX_DSQ_INVALID;13041304+ p->scx.ddsp_enq_flags = 0;13051305+}13061306+12771307static void direct_dispatch(struct scx_sched *sch, struct task_struct *p,12781308 u64 enq_flags)12791309{12801310 struct rq *rq = task_rq(p);12811311 struct scx_dispatch_q *dsq =12821312 find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, p);13131313+ u64 ddsp_enq_flags;1283131412841315 touch_core_sched_dispatch(rq, p);12851316···13421329 return;13431330 }1344133113451345- dispatch_enqueue(sch, dsq, p,13461346- p->scx.ddsp_enq_flags | SCX_ENQ_CLEAR_OPSS);13321332+ ddsp_enq_flags = p->scx.ddsp_enq_flags;13331333+ clear_direct_dispatch(p);13341334+13351335+ dispatch_enqueue(sch, dsq, p, ddsp_enq_flags | SCX_ENQ_CLEAR_OPSS);13471336}1348133713491338static bool scx_rq_online(struct rq *rq)···14541439 */14551440 touch_core_sched(rq, p);14561441 refill_task_slice_dfl(sch, p);14421442+ clear_direct_dispatch(p);14571443 dispatch_enqueue(sch, dsq, p, enq_flags);14581444}14591445···16261610 sub_nr_running(rq, 1);1627161116281612 dispatch_dequeue(rq, p);16131613+ clear_direct_dispatch(p);16291614 return true;16301615}16311616···23102293 struct task_struct, scx.dsq_list.node))) {23112294 struct scx_sched *sch = scx_root;23122295 struct scx_dispatch_q *dsq;22962296+ u64 dsq_id = p->scx.ddsp_dsq_id;22972297+ u64 enq_flags = p->scx.ddsp_enq_flags;2313229823142299 list_del_init(&p->scx.dsq_list.node);23002300+ clear_direct_dispatch(p);2315230123162316- dsq = find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, p);23022302+ dsq = find_dsq_for_dispatch(sch, rq, dsq_id, p);23172303 if (!WARN_ON_ONCE(dsq->id != SCX_DSQ_LOCAL))23182318- dispatch_to_local_dsq(sch, rq, dsq, p,23192319- p->scx.ddsp_enq_flags);23042304+ dispatch_to_local_dsq(sch, rq, dsq, p, enq_flags);23202305 }23212306}23222307···24232404{24242405 struct scx_sched *sch = scx_root;2425240624262426- /* see kick_cpus_irq_workfn() */24072407+ /* see kick_sync_wait_bal_cb() */24272408 smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1);2428240924292410 update_curr_scx(rq);···24662447 switch_class(rq, next);24672448}2468244924502450+static void kick_sync_wait_bal_cb(struct rq *rq)24512451+{24522452+ struct scx_kick_syncs __rcu *ks = __this_cpu_read(scx_kick_syncs);24532453+ unsigned long *ksyncs = rcu_dereference_sched(ks)->syncs;24542454+ bool waited;24552455+ s32 cpu;24562456+24572457+ /*24582458+ * Drop rq lock and enable IRQs while waiting. IRQs must be enabled24592459+ * — a target CPU may be waiting for us to process an IPI (e.g. TLB24602460+ * flush) while we wait for its kick_sync to advance.24612461+ *24622462+ * Also, keep advancing our own kick_sync so that new kick_sync waits24632463+ * targeting us, which can start after we drop the lock, cannot form24642464+ * cyclic dependencies.24652465+ */24662466+retry:24672467+ waited = false;24682468+ for_each_cpu(cpu, rq->scx.cpus_to_sync) {24692469+ /*24702470+ * smp_load_acquire() pairs with smp_store_release() on24712471+ * kick_sync updates on the target CPUs.24722472+ */24732473+ if (cpu == cpu_of(rq) ||24742474+ smp_load_acquire(&cpu_rq(cpu)->scx.kick_sync) != ksyncs[cpu]) {24752475+ cpumask_clear_cpu(cpu, rq->scx.cpus_to_sync);24762476+ continue;24772477+ }24782478+24792479+ raw_spin_rq_unlock_irq(rq);24802480+ while (READ_ONCE(cpu_rq(cpu)->scx.kick_sync) == ksyncs[cpu]) {24812481+ smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1);24822482+ cpu_relax();24832483+ }24842484+ raw_spin_rq_lock_irq(rq);24852485+ waited = true;24862486+ }24872487+24882488+ if (waited)24892489+ goto retry;24902490+}24912491+24692492static struct task_struct *first_local_task(struct rq *rq)24702493{24712494 return list_first_entry_or_null(&rq->scx.local_dsq.list,···25212460 bool keep_prev;25222461 struct task_struct *p;2523246225242524- /* see kick_cpus_irq_workfn() */24632463+ /* see kick_sync_wait_bal_cb() */25252464 smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1);2526246525272466 rq_modified_begin(rq, &ext_sched_class);···25302469 balance_one(rq, prev);25312470 rq_repin_lock(rq, rf);25322471 maybe_queue_balance_callback(rq);24722472+24732473+ /*24742474+ * Defer to a balance callback which can drop rq lock and enable24752475+ * IRQs. Waiting directly in the pick path would deadlock against24762476+ * CPUs sending us IPIs (e.g. TLB flushes) while we wait for them.24772477+ */24782478+ if (unlikely(rq->scx.kick_sync_pending)) {24792479+ rq->scx.kick_sync_pending = false;24802480+ queue_balance_callback(rq, &rq->scx.kick_sync_bal_cb,24812481+ kick_sync_wait_bal_cb);24822482+ }2533248325342484 /*25352485 * If any higher-priority sched class enqueued a runnable task on···3033296130342962 lockdep_assert_rq_held(rq);30352963 WARN_ON_ONCE(scx_get_task_state(p) != SCX_TASK_ENABLED);29642964+29652965+ clear_direct_dispatch(p);3036296630372967 if (SCX_HAS_OP(sch, disable))30382968 SCX_CALL_OP_TASK(sch, SCX_KF_REST, disable, rq, p);···47874713 if (!cpumask_empty(rq->scx.cpus_to_wait))47884714 dump_line(&ns, " cpus_to_wait : %*pb",47894715 cpumask_pr_args(rq->scx.cpus_to_wait));47164716+ if (!cpumask_empty(rq->scx.cpus_to_sync))47174717+ dump_line(&ns, " cpus_to_sync : %*pb",47184718+ cpumask_pr_args(rq->scx.cpus_to_sync));4790471947914720 used = seq_buf_used(&ns);47924721 if (SCX_HAS_OP(sch, dump_cpu)) {···5687561056885611 if (cpumask_test_cpu(cpu, this_scx->cpus_to_wait)) {56895612 if (cur_class == &ext_sched_class) {56135613+ cpumask_set_cpu(cpu, this_scx->cpus_to_sync);56905614 ksyncs[cpu] = rq->scx.kick_sync;56915615 should_wait = true;56925692- } else {56935693- cpumask_clear_cpu(cpu, this_scx->cpus_to_wait);56945616 }56175617+ cpumask_clear_cpu(cpu, this_scx->cpus_to_wait);56955618 }5696561956975620 resched_curr(rq);···57465669 cpumask_clear_cpu(cpu, this_scx->cpus_to_kick_if_idle);57475670 }5748567157495749- if (!should_wait)57505750- return;57515751-57525752- for_each_cpu(cpu, this_scx->cpus_to_wait) {57535753- unsigned long *wait_kick_sync = &cpu_rq(cpu)->scx.kick_sync;57545754-57555755- /*57565756- * Busy-wait until the task running at the time of kicking is no57575757- * longer running. This can be used to implement e.g. core57585758- * scheduling.57595759- *57605760- * smp_cond_load_acquire() pairs with store_releases in57615761- * pick_task_scx() and put_prev_task_scx(). The former breaks57625762- * the wait if SCX's scheduling path is entered even if the same57635763- * task is picked subsequently. The latter is necessary to break57645764- * the wait when $cpu is taken by a higher sched class.57655765- */57665766- if (cpu != cpu_of(this_rq))57675767- smp_cond_load_acquire(wait_kick_sync, VAL != ksyncs[cpu]);57685768-57695769- cpumask_clear_cpu(cpu, this_scx->cpus_to_wait);56725672+ /*56735673+ * Can't wait in hardirq — kick_sync can't advance, deadlocking if56745674+ * CPUs wait for each other. Defer to kick_sync_wait_bal_cb().56755675+ */56765676+ if (should_wait) {56775677+ raw_spin_rq_lock(this_rq);56785678+ this_scx->kick_sync_pending = true;56795679+ resched_curr(this_rq);56805680+ raw_spin_rq_unlock(this_rq);57705681 }57715682}57725683···58595794 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_kick_if_idle, GFP_KERNEL, n));58605795 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_preempt, GFP_KERNEL, n));58615796 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_wait, GFP_KERNEL, n));57975797+ BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_sync, GFP_KERNEL, n));58625798 rq->scx.deferred_irq_work = IRQ_WORK_INIT_HARD(deferred_irq_workfn);58635799 rq->scx.kick_cpus_irq_work = IRQ_WORK_INIT_HARD(kick_cpus_irq_workfn);58645800
+20-13
kernel/sched/ext_idle.c
···543543 * piled up on it even if there is an idle core elsewhere on544544 * the system.545545 */546546- waker_node = cpu_to_node(cpu);546546+ waker_node = scx_cpu_node_if_enabled(cpu);547547 if (!(current->flags & PF_EXITING) &&548548 cpu_rq(cpu)->scx.local_dsq.nr == 0 &&549549 (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node == node)) &&···860860 * code.861861 *862862 * We can't simply check whether @p->migration_disabled is set in a863863- * sched_ext callback, because migration is always disabled for the current864864- * task while running BPF code.863863+ * sched_ext callback, because the BPF prolog (__bpf_prog_enter) may disable864864+ * migration for the current task while running BPF code.865865 *866866- * The prolog (__bpf_prog_enter) and epilog (__bpf_prog_exit) respectively867867- * disable and re-enable migration. For this reason, the current task868868- * inside a sched_ext callback is always a migration-disabled task.866866+ * Since the BPF prolog calls migrate_disable() only when CONFIG_PREEMPT_RCU867867+ * is enabled (via rcu_read_lock_dont_migrate()), migration_disabled == 1 for868868+ * the current task is ambiguous only in that case: it could be from the BPF869869+ * prolog rather than a real migrate_disable() call.869870 *870870- * Therefore, when @p->migration_disabled == 1, check whether @p is the871871- * current task or not: if it is, then migration was not disabled before872872- * entering the callback, otherwise migration was disabled.871871+ * Without CONFIG_PREEMPT_RCU, the BPF prolog never calls migrate_disable(),872872+ * so migration_disabled == 1 always means the task is truly873873+ * migration-disabled.874874+ *875875+ * Therefore, when migration_disabled == 1 and CONFIG_PREEMPT_RCU is enabled,876876+ * check whether @p is the current task or not: if it is, then migration was877877+ * not disabled before entering the callback, otherwise migration was disabled.873878 *874879 * Returns true if @p is migration-disabled, false otherwise.875880 */876881static bool is_bpf_migration_disabled(const struct task_struct *p)877882{878878- if (p->migration_disabled == 1)879879- return p != current;880880- else881881- return p->migration_disabled;883883+ if (p->migration_disabled == 1) {884884+ if (IS_ENABLED(CONFIG_PREEMPT_RCU))885885+ return p != current;886886+ return true;887887+ }888888+ return p->migration_disabled;882889}883890884891static s32 select_cpu_from_kfunc(struct scx_sched *sch, struct task_struct *p,
+3-7
kernel/sched/fair.c
···707707 * Called in:708708 * - place_entity() -- before enqueue709709 * - update_entity_lag() -- before dequeue710710- * - entity_tick()710710+ * - update_deadline() -- slice expiration711711 *712712 * This means it is one entry 'behind' but that puts it close enough to where713713 * the bound on entity_key() is at most two lag bounds.···11311131 * EEVDF: vd_i = ve_i + r_i / w_i11321132 */11331133 se->deadline = se->vruntime + calc_delta_fair(se->slice, se);11341134+ avg_vruntime(cfs_rq);1134113511351136 /*11361137 * The task has consumed its request, reschedule.···55945593 update_load_avg(cfs_rq, curr, UPDATE_TG);55955594 update_cfs_group(curr);5596559555975597- /*55985598- * Pulls along cfs_rq::zero_vruntime.55995599- */56005600- avg_vruntime(cfs_rq);56015601-56025596#ifdef CONFIG_SCHED_HRTICK56035597 /*56045598 * queued ticks are scheduled to match the slice, so don't bother···91249128 */91259129 if (entity_eligible(cfs_rq, se)) {91269130 se->vruntime = se->deadline;91279127- se->deadline += calc_delta_fair(se->slice, se);91319131+ update_deadline(cfs_rq, se);91289132 }91299133}91309134
···27522752 if (!is_kprobe_multi(prog))27532753 return -EINVAL;2754275427552755+ /* kprobe_multi is not allowed to be sleepable. */27562756+ if (prog->sleepable)27572757+ return -EINVAL;27582758+27552759 /* Writing to context is not allowed for kprobes. */27562760 if (prog->aux->kprobe_write_ctx)27572761 return -EINVAL;
+22-3
kernel/workqueue.c
···76997699 else77007700 ts = touched;7701770177027702- /* did we stall? */77027702+ /*77037703+ * Did we stall?77047704+ *77057705+ * Do a lockless check first to do not disturb the system.77067706+ *77077707+ * Prevent false positives by double checking the timestamp77087708+ * under pool->lock. The lock makes sure that the check reads77097709+ * an updated pool->last_progress_ts when this CPU saw77107710+ * an already updated pool->worklist above. It seems better77117711+ * than adding another barrier into __queue_work() which77127712+ * is a hotter path.77137713+ */77037714 if (time_after(now, ts + thresh)) {77157715+ scoped_guard(raw_spinlock_irqsave, &pool->lock) {77167716+ pool_ts = pool->last_progress_ts;77177717+ if (time_after(pool_ts, touched))77187718+ ts = pool_ts;77197719+ else77207720+ ts = touched;77217721+ }77227722+ if (!time_after(now, ts + thresh))77237723+ continue;77247724+77047725 lockup_detected = true;77057726 stall_time = jiffies_to_msecs(now - pool_ts) / 1000;77067727 max_stall_time = max(max_stall_time, stall_time);···77337712 pr_cont_pool_info(pool);77347713 pr_cont(" stuck for %us!\n", stall_time);77357714 }77367736-77377737-77387715 }7739771677407717 if (lockup_detected)
···298298 int err = 0;299299300300 sco_conn_lock(conn);301301- if (conn->sk)301301+ if (conn->sk || sco_pi(sk)->conn)302302 err = -EBUSY;303303 else304304 __sco_chan_add(conn, sk, parent);···353353354354 lock_sock(sk);355355356356+ /* Recheck state after reacquiring the socket lock, as another357357+ * thread may have changed it (e.g., closed the socket).358358+ */359359+ if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {360360+ release_sock(sk);361361+ hci_conn_drop(hcon);362362+ err = -EBADFD;363363+ goto unlock;364364+ }365365+356366 err = sco_chan_add(conn, sk, NULL);357367 if (err) {358368 release_sock(sk);369369+ hci_conn_drop(hcon);359370 goto unlock;360371 }361372···667656 addr->sa_family != AF_BLUETOOTH)668657 return -EINVAL;669658670670- if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)671671- return -EBADFD;672672-673673- if (sk->sk_type != SOCK_SEQPACKET)674674- err = -EINVAL;675675-676659 lock_sock(sk);660660+661661+ if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {662662+ release_sock(sk);663663+ return -EBADFD;664664+ }665665+666666+ if (sk->sk_type != SOCK_SEQPACKET) {667667+ release_sock(sk);668668+ return -EINVAL;669669+ }670670+677671 /* Set destination address and psm */678672 bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);679673 release_sock(sk);
+6-5
net/bluetooth/smp.c
···1018101810191019 smp_s1(smp->tk, smp->prnd, smp->rrnd, stk);1020102010211021- if (hcon->pending_sec_level == BT_SECURITY_HIGH)10221022- auth = 1;10231023- else10241024- auth = 0;10211021+ auth = test_bit(SMP_FLAG_MITM_AUTH, &smp->flags) ? 1 : 0;1025102210261023 /* Even though there's no _RESPONDER suffix this is the10271024 * responder STK we're adding for later lookup (the initiator···18231826 if (sec_level > conn->hcon->pending_sec_level)18241827 conn->hcon->pending_sec_level = sec_level;1825182818261826- /* If we need MITM check that it can be achieved */18291829+ /* If we need MITM check that it can be achieved. */18271830 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) {18281831 u8 method;18291832···18311834 req->io_capability);18321835 if (method == JUST_WORKS || method == JUST_CFM)18331836 return SMP_AUTH_REQUIREMENTS;18371837+18381838+ /* Force MITM bit if it isn't set by the initiator. */18391839+ auth |= SMP_AUTH_MITM;18401840+ rsp.auth_req |= SMP_AUTH_MITM;18341841 }1835184218361843 key_size = min(req->max_key_size, rsp.max_key_size);
+11-7
net/bridge/br_arp_nd_proxy.c
···251251252252static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,253253 struct sk_buff *request, struct neighbour *n,254254- __be16 vlan_proto, u16 vlan_tci, struct nd_msg *ns)254254+ __be16 vlan_proto, u16 vlan_tci)255255{256256 struct net_device *dev = request->dev;257257 struct net_bridge_vlan_group *vg;258258+ struct nd_msg *na, *ns;258259 struct sk_buff *reply;259259- struct nd_msg *na;260260 struct ipv6hdr *pip6;261261 int na_olen = 8; /* opt hdr + ETH_ALEN for target */262262 int ns_olen;···264264 u8 *daddr;265265 u16 pvid;266266267267- if (!dev)267267+ if (!dev || skb_linearize(request))268268 return;269269270270 len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) +···281281 skb_set_mac_header(reply, 0);282282283283 daddr = eth_hdr(request)->h_source;284284+ ns = (struct nd_msg *)(skb_network_header(request) +285285+ sizeof(struct ipv6hdr));284286285287 /* Do we need option processing ? */286288 ns_olen = request->len - (skb_network_offset(request) +287289 sizeof(struct ipv6hdr)) - sizeof(*ns);288290 for (i = 0; i < ns_olen - 1; i += (ns->opt[i + 1] << 3)) {289289- if (!ns->opt[i + 1]) {291291+ if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) {290292 kfree_skb(reply);291293 return;292294 }293295 if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) {294294- daddr = ns->opt + i + sizeof(struct nd_opt_hdr);296296+ if ((ns->opt[i + 1] << 3) >=297297+ sizeof(struct nd_opt_hdr) + ETH_ALEN)298298+ daddr = ns->opt + i + sizeof(struct nd_opt_hdr);295299 break;296300 }297301 }···476472 if (vid != 0)477473 br_nd_send(br, p, skb, n,478474 skb->vlan_proto,479479- skb_vlan_tag_get(skb), msg);475475+ skb_vlan_tag_get(skb));480476 else481481- br_nd_send(br, p, skb, n, 0, 0, msg);477477+ br_nd_send(br, p, skb, n, 0, 0);482478 replied = true;483479 }484480
···821821 *822822 */823823ip_set_id_t824824-ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)824824+ip_set_get_byname(struct net *net, const struct nlattr *name, struct ip_set **set)825825{826826 ip_set_id_t i, index = IPSET_INVALID_ID;827827 struct ip_set *s;···830830 rcu_read_lock();831831 for (i = 0; i < inst->ip_set_max; i++) {832832 s = rcu_dereference(inst->ip_set_list)[i];833833- if (s && STRNCMP(s->name, name)) {833833+ if (s && nla_strcmp(name, s->name) == 0) {834834 __ip_set_get(s);835835 index = i;836836 *set = s;
+1-1
net/netfilter/ipset/ip_set_hash_gen.h
···10981098 if (!test_bit(i, n->used))10991099 k++;11001100 }11011101- if (n->pos == 0 && k == 0) {11011101+ if (k == n->pos) {11021102 t->hregion[r].ext_size -= ext_size(n->size, dsize);11031103 rcu_assign_pointer(hbucket(t, key), NULL);11041104 kfree_rcu(n, rcu);
+2-2
net/netfilter/ipset/ip_set_list_set.c
···367367 ret = ip_set_get_extensions(set, tb, &ext);368368 if (ret)369369 return ret;370370- e.id = ip_set_get_byname(map->net, nla_data(tb[IPSET_ATTR_NAME]), &s);370370+ e.id = ip_set_get_byname(map->net, tb[IPSET_ATTR_NAME], &s);371371 if (e.id == IPSET_INVALID_ID)372372 return -IPSET_ERR_NAME;373373 /* "Loop detection" */···389389390390 if (tb[IPSET_ATTR_NAMEREF]) {391391 e.refid = ip_set_get_byname(map->net,392392- nla_data(tb[IPSET_ATTR_NAMEREF]),392392+ tb[IPSET_ATTR_NAMEREF],393393 &s);394394 if (e.refid == IPSET_INVALID_ID) {395395 ret = -IPSET_ERR_NAMEREF;
+1-1
net/netfilter/nf_conntrack_helper.c
···415415 */416416 synchronize_rcu();417417418418- nf_ct_expect_iterate_destroy(expect_iter_me, NULL);418418+ nf_ct_expect_iterate_destroy(expect_iter_me, me);419419 nf_ct_iterate_destroy(unhelp, me);420420421421 /* nf_ct_iterate_destroy() does an unconditional synchronize_rcu() as
···501501 par->match->table, par->table);502502 return -EINVAL;503503 }504504+505505+ /* NFPROTO_UNSPEC implies NF_INET_* hooks which do not overlap with506506+ * NF_ARP_IN,OUT,FORWARD, allow explicit extensions with NFPROTO_ARP507507+ * support.508508+ */509509+ if (par->family == NFPROTO_ARP &&510510+ par->match->family != NFPROTO_ARP) {511511+ pr_info_ratelimited("%s_tables: %s match: not valid for this family\n",512512+ xt_prefix[par->family], par->match->name);513513+ return -EINVAL;514514+ }504515 if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) {505516 char used[64], allow[64];506517···10271016 par->target->table, par->table);10281017 return -EINVAL;10291018 }10191019+10201020+ /* NFPROTO_UNSPEC implies NF_INET_* hooks which do not overlap with10211021+ * NF_ARP_IN,OUT,FORWARD, allow explicit extensions with NFPROTO_ARP10221022+ * support.10231023+ */10241024+ if (par->family == NFPROTO_ARP &&10251025+ par->target->family != NFPROTO_ARP) {10261026+ pr_info_ratelimited("%s_tables: %s target: not valid for this family\n",10271027+ xt_prefix[par->family], par->target->name);10281028+ return -EINVAL;10291029+ }10301030+10301031 if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) {10311032 char used[64], allow[64];10321033
+6
net/netfilter/xt_cgroup.c
···65656666 info->priv = NULL;6767 if (info->has_path) {6868+ if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path))6969+ return -ENAMETOOLONG;7070+6871 cgrp = cgroup_get_from_path(info->path);6972 if (IS_ERR(cgrp)) {7073 pr_info_ratelimited("invalid path, errno=%ld\n",···105102106103 info->priv = NULL;107104 if (info->has_path) {105105+ if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path))106106+ return -ENAMETOOLONG;107107+108108 cgrp = cgroup_get_from_path(info->path);109109 if (IS_ERR(cgrp)) {110110 pr_info_ratelimited("invalid path, errno=%ld\n",
+5
net/netfilter/xt_rateest.c
···9191 goto err1;9292 }93939494+ if (strnlen(info->name1, sizeof(info->name1)) >= sizeof(info->name1))9595+ return -ENAMETOOLONG;9696+ if (strnlen(info->name2, sizeof(info->name2)) >= sizeof(info->name2))9797+ return -ENAMETOOLONG;9898+9499 ret = -ENOENT;95100 est1 = xt_rateest_lookup(par->net, info->name1);96101 if (!est1)
+13-18
net/qrtr/af_qrtr.c
···118118 * @ep: endpoint119119 * @ref: reference count for node120120 * @nid: node id121121- * @qrtr_tx_flow: tree of qrtr_tx_flow, keyed by node << 32 | port121121+ * @qrtr_tx_flow: xarray of qrtr_tx_flow, keyed by node << 32 | port122122 * @qrtr_tx_lock: lock for qrtr_tx_flow inserts123123 * @rx_queue: receive queue124124 * @item: list item for broadcast list···129129 struct kref ref;130130 unsigned int nid;131131132132- struct radix_tree_root qrtr_tx_flow;132132+ struct xarray qrtr_tx_flow;133133 struct mutex qrtr_tx_lock; /* for qrtr_tx_flow */134134135135 struct sk_buff_head rx_queue;···172172 struct qrtr_tx_flow *flow;173173 unsigned long flags;174174 void __rcu **slot;175175+ unsigned long index;175176176177 spin_lock_irqsave(&qrtr_nodes_lock, flags);177178 /* If the node is a bridge for other nodes, there are possibly···190189 skb_queue_purge(&node->rx_queue);191190192191 /* Free tx flow counters */193193- radix_tree_for_each_slot(slot, &node->qrtr_tx_flow, &iter, 0) {194194- flow = *slot;195195- radix_tree_iter_delete(&node->qrtr_tx_flow, &iter, slot);192192+ xa_for_each(&node->qrtr_tx_flow, index, flow)196193 kfree(flow);197197- }194194+ xa_destroy(&node->qrtr_tx_flow);198195 kfree(node);199196}200197···227228228229 key = remote_node << 32 | remote_port;229230230230- rcu_read_lock();231231- flow = radix_tree_lookup(&node->qrtr_tx_flow, key);232232- rcu_read_unlock();231231+ flow = xa_load(&node->qrtr_tx_flow, key);233232 if (flow) {234233 spin_lock(&flow->resume_tx.lock);235234 flow->pending = 0;···266269 return 0;267270268271 mutex_lock(&node->qrtr_tx_lock);269269- flow = radix_tree_lookup(&node->qrtr_tx_flow, key);272272+ flow = xa_load(&node->qrtr_tx_flow, key);270273 if (!flow) {271274 flow = kzalloc_obj(*flow);272275 if (flow) {273276 init_waitqueue_head(&flow->resume_tx);274274- if (radix_tree_insert(&node->qrtr_tx_flow, key, flow)) {277277+ if (xa_err(xa_store(&node->qrtr_tx_flow, key, flow,278278+ GFP_KERNEL))) {275279 kfree(flow);276280 flow = NULL;277281 }···324326 unsigned long key = (u64)dest_node << 32 | dest_port;325327 struct qrtr_tx_flow *flow;326328327327- rcu_read_lock();328328- flow = radix_tree_lookup(&node->qrtr_tx_flow, key);329329- rcu_read_unlock();329329+ flow = xa_load(&node->qrtr_tx_flow, key);330330 if (flow) {331331 spin_lock_irq(&flow->resume_tx.lock);332332 flow->tx_failed = 1;···595599 node->nid = QRTR_EP_NID_AUTO;596600 node->ep = ep;597601598598- INIT_RADIX_TREE(&node->qrtr_tx_flow, GFP_KERNEL);602602+ xa_init(&node->qrtr_tx_flow);599603 mutex_init(&node->qrtr_tx_lock);600604601605 qrtr_node_assign(node, nid);···623627 struct qrtr_tx_flow *flow;624628 struct sk_buff *skb;625629 unsigned long flags;630630+ unsigned long index;626631 void __rcu **slot;627632628633 mutex_lock(&node->ep_lock);···646649647650 /* Wake up any transmitters waiting for resume-tx from the node */648651 mutex_lock(&node->qrtr_tx_lock);649649- radix_tree_for_each_slot(slot, &node->qrtr_tx_flow, &iter, 0) {650650- flow = *slot;652652+ xa_for_each(&node->qrtr_tx_flow, index, flow)651653 wake_up_interruptible_all(&flow->resume_tx);652652- }653654 mutex_unlock(&node->qrtr_tx_lock);654655655656 qrtr_node_release(node);
+6-1
net/rds/ib_rdma.c
···604604 return ibmr;605605 }606606607607- if (conn)607607+ if (conn) {608608 ic = conn->c_transport_data;609609+ if (!ic || !ic->i_cm_id || !ic->i_cm_id->qp) {610610+ ret = -ENODEV;611611+ goto out;612612+ }613613+ }609614610615 if (!rds_ibdev->mr_8k_pool || !rds_ibdev->mr_1m_pool) {611616 ret = -ENODEV;
···503503 }504504505505 if (TC_H_MAJ(baseclass) == 0) {506506- struct Qdisc *q = tcf_block_q(tp->chain->block);506506+ struct tcf_block *block = tp->chain->block;507507+ struct Qdisc *q;507508509509+ if (tcf_block_shared(block)) {510510+ NL_SET_ERR_MSG(extack,511511+ "Must specify baseclass when attaching flow filter to block");512512+ goto err2;513513+ }514514+515515+ q = tcf_block_q(block);508516 baseclass = TC_H_MAKE(q->handle, baseclass);509517 }510518 if (TC_H_MIN(baseclass) == 0)
+12-2
net/sched/cls_fw.c
···247247 struct nlattr *tb[TCA_FW_MAX + 1];248248 int err;249249250250- if (!opt)251251- return handle ? -EINVAL : 0; /* Succeed if it is old method. */250250+ if (!opt) {251251+ if (handle)252252+ return -EINVAL;253253+254254+ if (tcf_block_shared(tp->chain->block)) {255255+ NL_SET_ERR_MSG(extack,256256+ "Must specify mark when attaching fw filter to block");257257+ return -EINVAL;258258+ }259259+260260+ return 0; /* Succeed if it is old method. */261261+ }252262253263 err = nla_parse_nested_deprecated(tb, TCA_FW_MAX, opt, fw_policy,254264 NULL);
+2-2
net/sched/sch_hfsc.c
···555555rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y)556556{557557 u64 y1, y2, dx, dy;558558- u32 dsm;558558+ u64 dsm;559559560560 if (isc->sm1 <= isc->sm2) {561561 /* service curve is convex */···598598 */599599 dx = (y1 - y) << SM_SHIFT;600600 dsm = isc->sm1 - isc->sm2;601601- do_div(dx, dsm);601601+ dx = div64_u64(dx, dsm);602602 /*603603 * check if (x, y1) belongs to the 1st segment of rtsc.604604 * if so, add the offset.
+3-2
net/sched/sch_netem.c
···519519 goto finish_segs;520520 }521521522522- skb->data[get_random_u32_below(skb_headlen(skb))] ^=523523- 1<<get_random_u32_below(8);522522+ if (skb_headlen(skb))523523+ skb->data[get_random_u32_below(skb_headlen(skb))] ^=524524+ 1 << get_random_u32_below(8);524525 }525526526527 if (unlikely(q->t_len >= sch->limit)) {
+1
net/vmw_vsock/af_vsock.c
···29282928 net->vsock.mode = vsock_net_child_mode(current->nsproxy->net_ns);2929292929302930 net->vsock.child_ns_mode = net->vsock.mode;29312931+ net->vsock.child_ns_mode_locked = 0;29312932}2932293329332934static __net_init int vsock_sysctl_init_net(struct net *net)
+6-3
net/x25/x25_in.c
···3434 struct sk_buff *skbo, *skbn = skb;3535 struct x25_sock *x25 = x25_sk(sk);36363737+ /* make sure we don't overflow */3838+ if (x25->fraglen + skb->len > USHRT_MAX)3939+ return 1;4040+3741 if (more) {3842 x25->fraglen += skb->len;3943 skb_queue_tail(&x25->fragment_queue, skb);···4844 if (x25->fraglen > 0) { /* End of fragment */4945 int len = x25->fraglen + skb->len;50465151- if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){5252- kfree_skb(skb);4747+ skbn = alloc_skb(len, GFP_ATOMIC);4848+ if (!skbn)5349 return 1;5454- }55505651 skb_queue_tail(&x25->fragment_queue, skb);5752
···11+/* SPDX-License-Identifier: GPL-2.0 */22+/*33+ * Test SCX_KICK_WAIT forward progress under cyclic wait pressure.44+ *55+ * SCX_KICK_WAIT busy-waits until the target CPU enters the scheduling path.66+ * If multiple CPUs form a wait cycle (A waits for B, B waits for C, C waits77+ * for A), all CPUs deadlock unless the implementation breaks the cycle.88+ *99+ * This test creates that scenario: three CPUs are arranged in a ring. The BPF1010+ * scheduler's ops.enqueue() kicks the next CPU in the ring with SCX_KICK_WAIT1111+ * on every enqueue. Userspace pins 4 worker threads per CPU that loop calling1212+ * sched_yield(), generating a steady stream of enqueues and thus sustained1313+ * A->B->C->A kick_wait cycle pressure. The test passes if the system remains1414+ * responsive for 5 seconds without the scheduler being killed by the watchdog.1515+ */1616+#define _GNU_SOURCE1717+1818+#include <bpf/bpf.h>1919+#include <errno.h>2020+#include <pthread.h>2121+#include <sched.h>2222+#include <scx/common.h>2323+#include <stdint.h>2424+#include <string.h>2525+#include <time.h>2626+#include <unistd.h>2727+2828+#include "scx_test.h"2929+#include "cyclic_kick_wait.bpf.skel.h"3030+3131+#define WORKERS_PER_CPU 43232+#define NR_TEST_CPUS 33333+#define NR_WORKERS (NR_TEST_CPUS * WORKERS_PER_CPU)3434+3535+struct worker_ctx {3636+ pthread_t tid;3737+ int cpu;3838+ volatile bool stop;3939+ volatile __u64 iters;4040+ bool started;4141+};4242+4343+static void *worker_fn(void *arg)4444+{4545+ struct worker_ctx *worker = arg;4646+ cpu_set_t mask;4747+4848+ CPU_ZERO(&mask);4949+ CPU_SET(worker->cpu, &mask);5050+5151+ if (sched_setaffinity(0, sizeof(mask), &mask))5252+ return (void *)(uintptr_t)errno;5353+5454+ while (!worker->stop) {5555+ sched_yield();5656+ worker->iters++;5757+ }5858+5959+ return NULL;6060+}6161+6262+static int join_worker(struct worker_ctx *worker)6363+{6464+ void *ret;6565+ struct timespec ts;6666+ int err;6767+6868+ if (!worker->started)6969+ return 0;7070+7171+ if (clock_gettime(CLOCK_REALTIME, &ts))7272+ return -errno;7373+7474+ ts.tv_sec += 2;7575+ err = pthread_timedjoin_np(worker->tid, &ret, &ts);7676+ if (err == ETIMEDOUT)7777+ pthread_detach(worker->tid);7878+ if (err)7979+ return -err;8080+8181+ if ((uintptr_t)ret)8282+ return -(int)(uintptr_t)ret;8383+8484+ return 0;8585+}8686+8787+static enum scx_test_status setup(void **ctx)8888+{8989+ struct cyclic_kick_wait *skel;9090+9191+ skel = cyclic_kick_wait__open();9292+ SCX_FAIL_IF(!skel, "Failed to open skel");9393+ SCX_ENUM_INIT(skel);9494+9595+ *ctx = skel;9696+ return SCX_TEST_PASS;9797+}9898+9999+static enum scx_test_status run(void *ctx)100100+{101101+ struct cyclic_kick_wait *skel = ctx;102102+ struct worker_ctx workers[NR_WORKERS] = {};103103+ struct bpf_link *link = NULL;104104+ enum scx_test_status status = SCX_TEST_PASS;105105+ int test_cpus[NR_TEST_CPUS];106106+ int nr_cpus = 0;107107+ cpu_set_t mask;108108+ int ret, i;109109+110110+ if (sched_getaffinity(0, sizeof(mask), &mask)) {111111+ SCX_ERR("Failed to get affinity (%d)", errno);112112+ return SCX_TEST_FAIL;113113+ }114114+115115+ for (i = 0; i < CPU_SETSIZE; i++) {116116+ if (CPU_ISSET(i, &mask))117117+ test_cpus[nr_cpus++] = i;118118+ if (nr_cpus == NR_TEST_CPUS)119119+ break;120120+ }121121+122122+ if (nr_cpus < NR_TEST_CPUS)123123+ return SCX_TEST_SKIP;124124+125125+ skel->rodata->test_cpu_a = test_cpus[0];126126+ skel->rodata->test_cpu_b = test_cpus[1];127127+ skel->rodata->test_cpu_c = test_cpus[2];128128+129129+ if (cyclic_kick_wait__load(skel)) {130130+ SCX_ERR("Failed to load skel");131131+ return SCX_TEST_FAIL;132132+ }133133+134134+ link = bpf_map__attach_struct_ops(skel->maps.cyclic_kick_wait_ops);135135+ if (!link) {136136+ SCX_ERR("Failed to attach scheduler");137137+ return SCX_TEST_FAIL;138138+ }139139+140140+ for (i = 0; i < NR_WORKERS; i++)141141+ workers[i].cpu = test_cpus[i / WORKERS_PER_CPU];142142+143143+ for (i = 0; i < NR_WORKERS; i++) {144144+ ret = pthread_create(&workers[i].tid, NULL, worker_fn, &workers[i]);145145+ if (ret) {146146+ SCX_ERR("Failed to create worker thread %d (%d)", i, ret);147147+ status = SCX_TEST_FAIL;148148+ goto out;149149+ }150150+ workers[i].started = true;151151+ }152152+153153+ sleep(5);154154+155155+ if (skel->data->uei.kind != EXIT_KIND(SCX_EXIT_NONE)) {156156+ SCX_ERR("Scheduler exited unexpectedly (kind=%llu code=%lld)",157157+ (unsigned long long)skel->data->uei.kind,158158+ (long long)skel->data->uei.exit_code);159159+ status = SCX_TEST_FAIL;160160+ }161161+162162+out:163163+ for (i = 0; i < NR_WORKERS; i++)164164+ workers[i].stop = true;165165+166166+ for (i = 0; i < NR_WORKERS; i++) {167167+ ret = join_worker(&workers[i]);168168+ if (ret && status == SCX_TEST_PASS) {169169+ SCX_ERR("Failed to join worker thread %d (%d)", i, ret);170170+ status = SCX_TEST_FAIL;171171+ }172172+ }173173+174174+ if (link)175175+ bpf_link__destroy(link);176176+177177+ return status;178178+}179179+180180+static void cleanup(void *ctx)181181+{182182+ struct cyclic_kick_wait *skel = ctx;183183+184184+ cyclic_kick_wait__destroy(skel);185185+}186186+187187+struct scx_test cyclic_kick_wait = {188188+ .name = "cyclic_kick_wait",189189+ .description = "Verify SCX_KICK_WAIT forward progress under a 3-CPU wait cycle",190190+ .setup = setup,191191+ .run = run,192192+ .cleanup = cleanup,193193+};194194+REGISTER_SCX_TEST(&cyclic_kick_wait)