Skip to content
Permalink
Potin-Lai/usb-…
Switch branches/tags

Commits on Feb 8, 2022

  1. usb: typec: fusb302: add support of supported_pd_rev

    Add support for passing supported PD rev to TCPM.
    If "supported-pd-rev" property exist, then return supported_pd_rev as
    defined value in DTS, otherwise return PD_MAX_REV
    
    Example of DTS:
    
    fusb302: typec-portc@22 {
        compatible = "fcs,fusb302";
        reg = <0x22>;
        ...
        supported-pd-rev=<1>; // PD_REV20
        ...
    };
    
    Signed-off-by: Potin Lai <potin.lai@quantatw.com>
    potinlai authored and intel-lab-lkp committed Feb 8, 2022
  2. usb: typec: tcpm: add interface for passing supported_pd_rev from tcp…

    …c_dev
    
    Current TCPM allways assume using PD_MAX_REV for negotiation,
    but for some USB controller only support PD 2.0, adding an interface
    for passing supported_pd_rev from tcpc_dev.
    
    Signed-off-by: Potin Lai <potin.lai@quantatw.com>
    potinlai authored and intel-lab-lkp committed Feb 8, 2022
  3. arm64: dts: ipq6018: Use reference clock to set dwc3 period

    Instead of manually setting snps,ref-clock-period-ns, we can let the
    driver calculate it automatically from the "ref" clock. I haven't
    reviewed this board's schematics, so please let me know if this is the
    wrong 24MHz clock to use.
    
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-8-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  4. arm64: dts: zynqmp: Move USB clocks to dwc3 node

    These clocks are not used by the dwc3-xilinx driver except to
    enable/disable them. Move them to the dwc3 node so its driver can use
    them to configure the reference clock period.
    
    Tested-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Robert Hancock <robert.hancock@calian.com>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-7-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  5. usb: dwc3: Add snps,ref-clock-frequency-hz property for ACPI

    This property allows setting the reference clock frequency properly for
    ACPI-based systems. It is not documented under dt-bindings, since it is
    not intended for use on DT-based systems. DT-based systems should use
    the clocks property instead.
    
    Frequency is preferred over period since it has greater precision when
    used in calculations.
    
    Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-6-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  6. usb: dwc3: Program GFLADJ

    GUCTL.REFCLKPER can only account for clock frequencies with integer
    periods. To address this, program REFCLK_FLADJ with the relative error
    caused by period truncation. The formula given in the register reference
    has been rearranged to allow calculation based on rate (instead of
    period), and to allow for fixed-point arithmetic.
    
    Additionally, calculate a value for 240MHZDECR. This configures a
    simulated 240Mhz clock using a counter with one fractional bit (PLS1).
    
    This register is programmed only for versions >= 2.50a, since this is
    the check also used by commit db2be4e ("usb: dwc3: Add frame length
    adjustment quirk").
    
    Tested-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-5-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  7. usb: dwc3: Calculate REFCLKPER based on reference clock

    Instead of using a special property to determine the reference clock
    period, use the rate of the reference clock. When we have a legacy
    snps,ref-clock-period-ns property and no reference clock, use it
    instead. Fractional clocks are not currently supported, and will be
    dealt with in the next commit.
    
    Tested-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-4-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  8. usb: dwc3: Get clocks individually

    Instead of grabbing all clocks in bulk, grab them individually. This will
    allow us to get the frequency or otherwise deal with discrete clocks. This
    may break some platforms if they use a clock which doesn't use one of the
    documented names.
    
    Reviewed-by: Robert Hancock <robert.hancock@calian.com>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-3-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022
  9. dt-bindings: usb: dwc3: Deprecate snps,ref-clock-period-ns

    This property is redundant because we can determine the correct value for
    REFCLKPER based on the "ref" clock. Deprecate it, and encourage users to
    provide a clock instead. This also restricts the minimum and maximum to the
    values documented in the register reference [1].
    
    [1] https://www.xilinx.com/html_docs/registers/ug1087/usb3_xhci___guctl.html
    
    Reviewed-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Sean Anderson <sean.anderson@seco.com>
    Link: https://lore.kernel.org/r/20220127200636.1456175-2-sean.anderson@seco.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-anderson-seco authored and gregkh committed Feb 8, 2022

Commits on Feb 4, 2022

  1. usb: gadget: f_uac2: Neaten and reduce size of afunc_validate_opts

    Remove the repetition and reduce the object size a bit.
    
    $ size drivers/usb/gadget/function/f_uac2.o* (x86-64 defconfig with gadget)
       text	   data	    bss	    dec	    hex	filename
      24515	   3136	     16	  27667	   6c13	drivers/usb/gadget/function/f_uac2.o.new
      24817	   3136	     16	  27969	   6d41	drivers/usb/gadget/function/f_uac2.o.old
    
    Signed-off-by: Joe Perches <joe@perches.com>
    Link: https://lore.kernel.org/r/2132d97ca8d4dd5ac9426cc23af95e819079b02c.camel@perches.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    JoePerches authored and gregkh committed Feb 4, 2022
  2. usb: gadget: f_uac2: change maxpctksize/maxpcktsize to wMaxPacketSize

    The spelling of maxpctksize and maxpcktsize is inconsistent, rename them
    both to wMaxPacketSize instead.
    
    Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
    Link: https://lore.kernel.org/r/20220202104058.590312-1-colin.i.king@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ColinIanKing authored and gregkh committed Feb 4, 2022

Commits on Jan 31, 2022

  1. usb: gadget: f_uac2: Add speed names to bInterval dbg/warn

    Add speed names for better clarity of dgb/warn messages from max packet
    size/bInterval checks.
    
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220127114331.41367-5-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 31, 2022
  2. usb: gadget: f_uac2: Optionally determine bInterval for HS and SS

    Allow setting configfs params p_hs_bint/c_hs_bint to 0. If they are set
    to 0, determine the largest bInterval (4 to 1) for which the required
    bandwidth of the max samplerate fits the max allowed packet size. If the
    required bandwidth exceeds max bandwidth for single-packet mode
    (ep->mc=1), keep bInterval at 1.
    
    The FS speed is left at fixed bInterval=1.
    
    If for any speed the required bandwidth exceeds the max bandwidth
    corresponding to the selected/determined bInterval, print a warning.
    
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220127114331.41367-4-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 31, 2022
  3. usb: gadget: audio: Add HS/SS bInterval params for UAC2

    Allow configuring the existing f_uac2 configfs bInterval params through
    parameters of the gaudio module.
    
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220127114331.41367-3-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 31, 2022
  4. usb: gadget: f_uac2: Add HS/SS bInterval to configfs

    Allow configuring the HS/SS bInterval through configfs, via
    parameters p_hs_bint/c_hs_bint separately for playback/capture.
    
    The default param values are left at the original 4.
    
    Suggested-by: John Keeping <john@metanate.com>
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220127114331.41367-2-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 31, 2022
  5. usb: udc: Fix typo in comment

    Replace disbale with disable
    
    Signed-off-by: tangmeng <tangmeng@uniontech.com>
    Link: https://lore.kernel.org/r/20220127071619.31812-1-tangmeng@uniontech.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    imtangmeng authored and gregkh committed Jan 31, 2022
  6. USB: ACPI: Replace acpi_bus_get_device()

    Replace acpi_bus_get_device() that is going to be dropped with
    acpi_fetch_acpi_dev().
    
    No intentional functional impact.
    
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://lore.kernel.org/r/1899393.PYKUYFuaPT@kreacher
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    rafaeljw authored and gregkh committed Jan 31, 2022
  7. Merge tag 'v5.17-rc2' into usb-next

    We need the USB fixes in here as well.
    
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed Jan 31, 2022

Commits on Jan 30, 2022

  1. Linux 5.17-rc2

    torvalds committed Jan 30, 2022
  2. Merge tag 'irq_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/s…

    …cm/linux/kernel/git/tip/tip
    
    Pull irq fixes from Borislav Petkov:
    
     - Drop an unused private data field in the AIC driver
    
     - Various fixes to the realtek-rtl driver
    
     - Make the GICv3 ITS driver compile again in !SMP configurations
    
     - Force reset of the GICv3 ITSs at probe time to avoid issues during kexec
    
     - Yet another kfree/bitmap_free conversion
    
     - Various DT updates (Renesas, SiFive)
    
    * tag 'irq_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      dt-bindings: interrupt-controller: sifive,plic: Group interrupt tuples
      dt-bindings: interrupt-controller: sifive,plic: Fix number of interrupts
      dt-bindings: irqchip: renesas-irqc: Add R-Car V3U support
      irqchip/gic-v3-its: Reset each ITS's BASERn register before probe
      irqchip/gic-v3-its: Fix build for !SMP
      irqchip/loongson-pch-ms: Use bitmap_free() to free bitmap
      irqchip/realtek-rtl: Service all pending interrupts
      irqchip/realtek-rtl: Fix off-by-one in routing
      irqchip/realtek-rtl: Map control data to virq
      irqchip/apple-aic: Drop unused ipi_hwirq field
    torvalds committed Jan 30, 2022
  3. Merge tag 'perf_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/…

    …scm/linux/kernel/git/tip/tip
    
    Pull perf fixes from Borislav Petkov:
    
     - Prevent accesses to the per-CPU cgroup context list from another CPU
       except the one it belongs to, to avoid list corruption
    
     - Make sure parent events are always woken up to avoid indefinite hangs
       in the traced workload
    
    * tag 'perf_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      perf/core: Fix cgroup event list management
      perf: Always wake the parent event
    torvalds committed Jan 30, 2022
  4. Merge tag 'sched_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub…

    …/scm/linux/kernel/git/tip/tip
    
    Pull scheduler fix from Borislav Petkov:
     "Make sure the membarrier-rseq fence commands are part of the reported
      set when querying membarrier(2) commands through MEMBARRIER_CMD_QUERY"
    
    * tag 'sched_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      sched/membarrier: Fix membarrier-rseq fence command missing from query bitmask
    torvalds committed Jan 30, 2022
  5. Merge tag 'x86_urgent_for_v5.17_rc2' of git://git.kernel.org/pub/scm/…

    …linux/kernel/git/tip/tip
    
    Pull x86 fixes from Borislav Petkov:
    
     - Add another Intel CPU model to the list of CPUs supporting the
       processor inventory unique number
    
     - Allow writing to MCE thresholding sysfs files again - a previous
       change had accidentally disabled it and no one noticed. Goes to show
       how much is this stuff used
    
    * tag 'x86_urgent_for_v5.17_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      x86/cpu: Add Xeon Icelake-D to list of CPUs that support PPIN
      x86/MCE/AMD: Allow thresholding interface updates after init
    torvalds committed Jan 30, 2022
  6. Merge branch 'akpm' (patches from Andrew)

    Merge misc fixes from Andrew Morton:
     "12 patches.
    
      Subsystems affected by this patch series: sysctl, binfmt, ia64, mm
      (memory-failure, folios, kasan, and psi), selftests, and ocfs2"
    
    * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
      ocfs2: fix a deadlock when commit trans
      jbd2: export jbd2_journal_[grab|put]_journal_head
      psi: fix "defined but not used" warnings when CONFIG_PROC_FS=n
      psi: fix "no previous prototype" warnings when CONFIG_CGROUPS=n
      mm, kasan: use compare-exchange operation to set KASAN page tag
      kasan: test: fix compatibility with FORTIFY_SOURCE
      tools/testing/scatterlist: add missing defines
      mm: page->mapping folio->mapping should have the same offset
      memory-failure: fetch compound_head after pgmap_pfn_valid()
      ia64: make IA64_MCA_RECOVERY bool instead of tristate
      binfmt_misc: fix crash when load/unload module
      include/linux/sysctl.h: fix register_sysctl_mount_point() return type
    torvalds committed Jan 30, 2022
  7. ocfs2: fix a deadlock when commit trans

    commit 6f1b228 introduces a regression which can deadlock as
    follows:
    
      Task1:                              Task2:
      jbd2_journal_commit_transaction     ocfs2_test_bg_bit_allocatable
      spin_lock(&jh->b_state_lock)        jbd_lock_bh_journal_head
      __jbd2_journal_remove_checkpoint    spin_lock(&jh->b_state_lock)
      jbd2_journal_put_journal_head
      jbd_lock_bh_journal_head
    
    Task1 and Task2 lock bh->b_state and jh->b_state_lock in different
    order, which finally result in a deadlock.
    
    So use jbd2_journal_[grab|put]_journal_head instead in
    ocfs2_test_bg_bit_allocatable() to fix it.
    
    Link: https://lkml.kernel.org/r/20220121071205.100648-3-joseph.qi@linux.alibaba.com
    Fixes: 6f1b228 ("ocfs2: fix race between searching chunks and release journal_head from buffer_head")
    Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Reported-by: Gautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
    Tested-by: Gautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
    Reported-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
    Cc: "Theodore Ts'o" <tytso@mit.edu>
    Cc: Andreas Dilger <adilger.kernel@dilger.ca>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    josephhz authored and torvalds committed Jan 30, 2022
  8. jbd2: export jbd2_journal_[grab|put]_journal_head

    Patch series "ocfs2: fix a deadlock case".
    
    This fixes a deadlock case in ocfs2.  We firstly export jbd2 symbols
    jbd2_journal_[grab|put]_journal_head as preparation and later use them
    in ocfs2 insread of jbd_[lock|unlock]_bh_journal_head to fix the
    deadlock.
    
    This patch (of 2):
    
    This exports symbols jbd2_journal_[grab|put]_journal_head, which will be
    used outside modules, e.g.  ocfs2.
    
    Link: https://lkml.kernel.org/r/20220121071205.100648-2-joseph.qi@linux.alibaba.com
    Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: Andreas Dilger <adilger.kernel@dilger.ca>
    Cc: Gautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
    Cc: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
    Cc: "Theodore Ts'o" <tytso@mit.edu>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    josephhz authored and torvalds committed Jan 30, 2022
  9. psi: fix "defined but not used" warnings when CONFIG_PROC_FS=n

    When CONFIG_PROC_FS is disabled psi code generates the following
    warnings:
    
      kernel/sched/psi.c:1364:30: warning: 'psi_cpu_proc_ops' defined but not used [-Wunused-const-variable=]
          1364 | static const struct proc_ops psi_cpu_proc_ops = {
               |                              ^~~~~~~~~~~~~~~~
      kernel/sched/psi.c:1355:30: warning: 'psi_memory_proc_ops' defined but not used [-Wunused-const-variable=]
          1355 | static const struct proc_ops psi_memory_proc_ops = {
               |                              ^~~~~~~~~~~~~~~~~~~
      kernel/sched/psi.c:1346:30: warning: 'psi_io_proc_ops' defined but not used [-Wunused-const-variable=]
          1346 | static const struct proc_ops psi_io_proc_ops = {
               |                              ^~~~~~~~~~~~~~~
    
    Make definitions of these structures and related functions conditional
    on CONFIG_PROC_FS config.
    
    Link: https://lkml.kernel.org/r/20220119223940.787748-3-surenb@google.com
    Fixes: 0e94682 ("psi: introduce psi monitor")
    Signed-off-by: Suren Baghdasaryan <surenb@google.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Acked-by: Johannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    surenbaghdasaryan authored and torvalds committed Jan 30, 2022
  10. psi: fix "no previous prototype" warnings when CONFIG_CGROUPS=n

    When CONFIG_CGROUPS is disabled psi code generates the following
    warnings:
    
      kernel/sched/psi.c:1112:21: warning: no previous prototype for 'psi_trigger_create' [-Wmissing-prototypes]
          1112 | struct psi_trigger *psi_trigger_create(struct psi_group *group,
               |                     ^~~~~~~~~~~~~~~~~~
      kernel/sched/psi.c:1182:6: warning: no previous prototype for 'psi_trigger_destroy' [-Wmissing-prototypes]
          1182 | void psi_trigger_destroy(struct psi_trigger *t)
               |      ^~~~~~~~~~~~~~~~~~~
      kernel/sched/psi.c:1249:10: warning: no previous prototype for 'psi_trigger_poll' [-Wmissing-prototypes]
          1249 | __poll_t psi_trigger_poll(void **trigger_ptr,
               |          ^~~~~~~~~~~~~~~~
    
    Change the declarations of these functions in the header to provide the
    prototypes even when they are unused.
    
    Link: https://lkml.kernel.org/r/20220119223940.787748-2-surenb@google.com
    Fixes: 0e94682 ("psi: introduce psi monitor")
    Signed-off-by: Suren Baghdasaryan <surenb@google.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Acked-by: Johannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    surenbaghdasaryan authored and torvalds committed Jan 30, 2022
  11. mm, kasan: use compare-exchange operation to set KASAN page tag

    It has been reported that the tag setting operation on newly-allocated
    pages can cause the page flags to be corrupted when performed
    concurrently with other flag updates as a result of the use of
    non-atomic operations.
    
    Fix the problem by using a compare-exchange loop to update the tag.
    
    Link: https://lkml.kernel.org/r/20220120020148.1632253-1-pcc@google.com
    Link: https://linux-review.googlesource.com/id/I456b24a2b9067d93968d43b4bb3351c0cec63101
    Fixes: 2813b9c ("kasan, mm, arm64: tag non slab memory allocated via pagealloc")
    Signed-off-by: Peter Collingbourne <pcc@google.com>
    Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    pcc authored and torvalds committed Jan 30, 2022
  12. kasan: test: fix compatibility with FORTIFY_SOURCE

    With CONFIG_FORTIFY_SOURCE enabled, string functions will also perform
    dynamic checks using __builtin_object_size(ptr), which when failed will
    panic the kernel.
    
    Because the KASAN test deliberately performs out-of-bounds operations,
    the kernel panics with FORTIFY_SOURCE, for example:
    
     | kernel BUG at lib/string_helpers.c:910!
     | invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
     | CPU: 1 PID: 137 Comm: kunit_try_catch Tainted: G    B             5.16.0-rc3+ #3
     | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
     | RIP: 0010:fortify_panic+0x19/0x1b
     | ...
     | Call Trace:
     |  kmalloc_oob_in_memset.cold+0x16/0x16
     |  ...
    
    Fix it by also hiding `ptr` from the optimizer, which will ensure that
    __builtin_object_size() does not return a valid size, preventing
    fortified string functions from panicking.
    
    Link: https://lkml.kernel.org/r/20220124160744.1244685-1-elver@google.com
    Signed-off-by: Marco Elver <elver@google.com>
    Reported-by: Nico Pache <npache@redhat.com>
    Reviewed-by: Nico Pache <npache@redhat.com>
    Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Brendan Higgins <brendanhiggins@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    melver authored and torvalds committed Jan 30, 2022
  13. tools/testing/scatterlist: add missing defines

    The cited commits replaced preemptible with pagefault_disabled and
    flush_kernel_dcache_page with flush_dcache_page respectively, hence need
    to update the corresponding defines in the test.
    
      scatterlist.c: In function ‘sg_miter_stop’:
      scatterlist.c:919:4: warning: implicit declaration of function ‘flush_dcache_page’ [-Wimplicit-function-declaration]
          flush_dcache_page(miter->page);
          ^~~~~~~~~~~~~~~~~
      In file included from linux/scatterlist.h:8:0,
                       from scatterlist.c:9:
      scatterlist.c:922:18: warning: implicit declaration of function ‘pagefault_disabled’ [-Wimplicit-function-declaration]
          WARN_ON_ONCE(!pagefault_disabled());
                        ^
      linux/mm.h:23:25: note: in definition of macro ‘WARN_ON_ONCE’
        int __ret_warn_on = !!(condition);                      \
                               ^~~~~~~~~
    
    Link: https://lkml.kernel.org/r/20220118082105.1737320-1-maorg@nvidia.com
    Fixes: 723aca2 ("mm/scatterlist: replace the !preemptible warning in sg_miter_stop()")
    Fixes: 0e84f5d ("scatterlist: replace flush_kernel_dcache_page with flush_dcache_page")
    Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
    Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    maorgottlieb authored and torvalds committed Jan 30, 2022
  14. mm: page->mapping folio->mapping should have the same offset

    As with the other members of folio, the offset of page->mapping and
    folio->mapping must be the same.  The compile-time check was
    inadvertently removed during development.  Add it back.
    
    [willy@infradead.org: changelog redo]
    
    Link: https://lkml.kernel.org/r/20220104011734.21714-1-richard.weiyang@gmail.com
    Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    RichardWeiYang authored and torvalds committed Jan 30, 2022
  15. memory-failure: fetch compound_head after pgmap_pfn_valid()

    memory_failure_dev_pagemap() at the moment assumes base pages (e.g.
    dax_lock_page()).  For devmap with compound pages fetch the
    compound_head in case a tail page memory failure is being handled.
    
    Currently this is a nop, but in the advent of compound pages in
    dev_pagemap it allows memory_failure_dev_pagemap() to keep working.
    
    Without this fix memory-failure handling (i.e.  MCEs on pmem) with
    device-dax configured namespaces will regress (and crash).
    
    Link: https://lkml.kernel.org/r/20211202204422.26777-2-joao.m.martins@oracle.com
    Reported-by: Jane Chu <jane.chu@oracle.com>
    Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
    Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Reviewed-by: Muchun Song <songmuchun@bytedance.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    jpemartins authored and torvalds committed Jan 30, 2022
  16. ia64: make IA64_MCA_RECOVERY bool instead of tristate

    In linux-next, IA64_MCA_RECOVERY uses the (new) function
    make_task_dead(), which is not exported for use by modules.  Instead of
    exporting it for one user, convert IA64_MCA_RECOVERY to be a bool
    Kconfig symbol.
    
    In a config file from "kernel test robot <lkp@intel.com>" for a
    different problem, this linker error was exposed when
    CONFIG_IA64_MCA_RECOVERY=m.
    
    Fixes this build error:
    
      ERROR: modpost: "make_task_dead" [arch/ia64/kernel/mca_recovery.ko] undefined!
    
    Link: https://lkml.kernel.org/r/20220124213129.29306-1-rdunlap@infradead.org
    Fixes: 0e25498 ("exit: Add and use make_task_dead.")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Suggested-by: Christoph Hellwig <hch@infradead.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Cc: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    rddunlap authored and torvalds committed Jan 30, 2022
  17. binfmt_misc: fix crash when load/unload module

    We should unregister the table upon module unload otherwise something
    horrible will happen when we load binfmt_misc module again.  Also note
    that we should keep value returned by register_sysctl_mount_point() and
    release it later, otherwise it will leak.
    
    Also, per Christian's comment, to fully restore the old behavior that
    won't break userspace the check(binfmt_misc_header) should be
    eliminated.
    
    To reproduce:
      modprobe binfmt_misc
      modprobe -r binfmt_misc
      modprobe binfmt_misc
      modprobe -r binfmt_misc
      modprobe binfmt_misc
    
    resulting in
    
      modprobe: can't load module binfmt_misc (kernel/fs/binfmt_misc.ko): Cannot allocate memory
    
    and an unhappy kernel:
    
      binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
      binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
      BUG: unable to handle page fault for address: fffffbfff8004802
      Call Trace:
        init_misc_binfmt+0x2d/0x1000 [binfmt_misc]
    
    Link: https://lkml.kernel.org/r/20220124181812.1869535-2-ztong0001@gmail.com
    Fixes: 3ba442d ("fs: move binfmt_misc sysctl to its own file")
    Signed-off-by: Tong Zhang <ztong0001@gmail.com>
    Co-developed-by: Christian Brauner<brauner@kernel.org>
    Acked-by: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Eric Biederman <ebiederm@xmission.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Iurii Zaikin <yzaikin@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    lzto authored and torvalds committed Jan 30, 2022
Older