1. 08 Apr, 2020 12 commits
    • Sebastian Andrzej Siewior's avatar
      workqueue: Remove the warning in wq_worker_sleeping() · 62849a96
      Sebastian Andrzej Siewior authored
      The kernel test robot triggered a warning with the following race:
         task-ctx A                            interrupt-ctx B
       worker
        -> process_one_work()
          -> work_item()
            -> schedule();
               -> sched_submit_work()
                 -> wq_worker_sleeping()
                   -> ->sleeping = 1
                     atomic_dec_and_test(nr_running)
               __schedule();                *interrupt*
                                             async_page_fault()
                                             -> local_irq_enable();
                                             -> schedule();
                                                -> sched_submit_work()
                                                  -> wq_worker_sleeping()
                                                     -> if (WARN_ON(->sleeping)) return
                                                -> __schedule()
                                                  ->  sched_update_worker()
                                                    -> wq_worker_running()
                                                       -> atomic_inc(nr_running);
                                                       -> ->sleeping = 0;
      
            ->  sched_update_worker()
              -> wq_worker_running()
                if (!->sleeping) return
      
      In this context the warning is pointless everything is fine.
      An interrupt before wq_worker_sleeping() will perform the ->sleeping
      assignment (0 -> 1 > 0) twice.
      An interrupt after wq_worker_sleeping() will trigger the warning and
      nr_running will be decremented (by A) and incremented once (only by B, A
      will skip it). This is the case until the ->sleeping is zeroed again in
      wq_worker_running().
      
      Remove the WARN statement because this condition may happen. Document
      that preemption around wq_worker_sleeping() needs to be disabled to
      protect ->sleeping and not just as an optimisation.
      
      Fixes: 6d25be57 ("sched/core, workqueues: Distangle worker accounting from rq lock")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Link: https://lkml.kernel.org/r/20200327074308.GY11705@shao2-debian
      62849a96
    • Aubrey Li's avatar
      sched/fair: Fix negative imbalance in imbalance calculation · 111688ca
      Aubrey Li authored
      A negative imbalance value was observed after imbalance calculation,
      this happens when the local sched group type is group_fully_busy,
      and the average load of local group is greater than the selected
      busiest group. Fix this problem by comparing the average load of the
      local and busiest group before imbalance calculation formula.
      Suggested-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Reviewed-by: default avatarPhil Auld <pauld@redhat.com>
      Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Acked-by: default avatarMel Gorman <mgorman@suse.de>
      Signed-off-by: default avatarAubrey Li <aubrey.li@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lkml.kernel.org/r/1585201349-70192-1-git-send-email-aubrey.li@intel.com
      111688ca
    • Huaixin Chang's avatar
      sched/fair: Fix race between runtime distribution and assignment · 26a8b127
      Huaixin Chang authored
      Currently, there is a potential race between distribute_cfs_runtime()
      and assign_cfs_rq_runtime(). Race happens when cfs_b->runtime is read,
      distributes without holding lock and finds out there is not enough
      runtime to charge against after distribution. Because
      assign_cfs_rq_runtime() might be called during distribution, and use
      cfs_b->runtime at the same time.
      
      Fibtest is the tool to test this race. Assume all gcfs_rq is throttled
      and cfs period timer runs, slow threads might run and sleep, returning
      unused cfs_rq runtime and keeping min_cfs_rq_runtime in their local
      pool. If all this happens sufficiently quickly, cfs_b->runtime will drop
      a lot. If runtime distributed is large too, over-use of runtime happens.
      
      A runtime over-using by about 70 percent of quota is seen when we
      test fibtest on a 96-core machine. We run fibtest with 1 fast thread and
      95 slow threads in test group, configure 10ms quota for this group and
      see the CPU usage of fibtest is 17.0%, which is far more than the
      expected 10%.
      
      On a smaller machine with 32 cores, we also run fibtest with 96
      threads. CPU usage is more than 12%, which is also more than expected
      10%. This shows that on similar workloads, this race do affect CPU
      bandwidth control.
      
      Solve this by holding lock inside distribute_cfs_runtime().
      
      Fixes: c06f04c7 ("sched: Fix potential near-infinite distribute_cfs_runtime() loop")
      Reviewed-by: default avatarBen Segall <bsegall@google.com>
      Signed-off-by: default avatarHuaixin Chang <changhuaixin@linux.alibaba.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/lkml/20200325092602.22471-1-changhuaixin@linux.alibaba.com/
      26a8b127
    • Valentin Schneider's avatar
      sched/fair: Align rq->avg_idle and rq->avg_scan_cost · d76343c6
      Valentin Schneider authored
      sched/core.c uses update_avg() for rq->avg_idle and sched/fair.c uses an
      open-coded version (with the exact same decay factor) for
      rq->avg_scan_cost. On top of that, select_idle_cpu() expects to be able to
      compare these two fields.
      
      The only difference between the two is that rq->avg_scan_cost is computed
      using a pure division rather than a shift. Turns out it actually matters,
      first of all because the shifted value can be negative, and the standard
      has this to say about it:
      
        """
        The result of E1 >> E2 is E1 right-shifted E2 bit positions. [...] If E1
        has a signed type and a negative value, the resulting value is
        implementation-defined.
        """
      
      Not only this, but (arithmetic) right shifting a negative value (using 2's
      complement) is *not* equivalent to dividing it by the corresponding power
      of 2. Let's look at a few examples:
      
        -4      -> 0xF..FC
        -4 >> 3 -> 0xF..FF == -1 != -4 / 8
      
        -8      -> 0xF..F8
        -8 >> 3 -> 0xF..FF == -1 == -8 / 8
      
        -9      -> 0xF..F7
        -9 >> 3 -> 0xF..FE == -2 != -9 / 8
      
      Make update_avg() use a division, and export it to the private scheduler
      header to reuse it where relevant. Note that this still lets compilers use
      a shift here, but should prevent any unwanted surprise. The disassembly of
      select_idle_cpu() remains unchanged on arm64, and ttwu_do_wakeup() gains 2
      instructions; the diff sort of looks like this:
      
        - sub x1, x1, x0
        + subs x1, x1, x0 // set condition codes
        + add x0, x1, #0x7
        + csel x0, x0, x1, mi // x0 = x1 < 0 ? x0 : x1
          add x0, x3, x0, asr #3
      
      which does the right thing (i.e. gives us the expected result while still
      using an arithmetic shift)
      Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lkml.kernel.org/r/20200330090127.16294-1-valentin.schneider@arm.com
      d76343c6
    • Linus Torvalds's avatar
      Merge tag 'drm-next-2020-04-08' of git://anongit.freedesktop.org/drm/drm · f5e94d10
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "This is a set of fixes that have queued up, I think I might have
        another pull with some more before rc1 but I'd like to dequeue what I
        have now just in case Easter is more eggciting that expected.
      
        The main thing in here is a fix for a longstanding nouveau power
        management issues on certain laptops, it should help runtime
        suspend/resume for a lot of people.
      
        There is also a reverted patch for some drm_mm behaviour in atomic
        contexts.
      
        Summary:
      
        core:
         - revert drm_mm atomic patch
         - dt binding fixes
      
        fbcon:
         - null ptr error fix
      
        i915:
         - GVT fixes
      
        nouveau:
         - runpm fix
         - svm fixes
      
        amdgpu:
         - HDCP fixes
         - gfx10 fix
         - Misc display fixes
         - BACO fixes
      
        amdkfd:
         - Fix memory leak
      
        vboxvideo:
         - remove conflicting fbs
      
        vc4:
         - mode validation fix
      
        xen:
         - fix PTR_ERR usage"
      
      * tag 'drm-next-2020-04-08' of git://anongit.freedesktop.org/drm/drm: (41 commits)
        drm/nouveau/kms/nv50-: wait for FIFO space on PIO channels
        drm/nouveau/nvif: protect waits against GPU falling off the bus
        drm/nouveau/nvif: access PTIMER through usermode class, if available
        drm/nouveau/gr/gp107,gp108: implement workaround for HW hanging during init
        drm/nouveau: workaround runpm fail by disabling PCI power management on certain intel bridges
        drm/nouveau/svm: remove useless SVM range check
        drm/nouveau/svm: check for SVM initialized before migrating
        drm/nouveau/svm: fix vma range check for migration
        drm/nouveau: remove checks for return value of debugfs functions
        drm/nouveau/ttm: evict other IO mappings when running out of BAR1 space
        drm/amdkfd: kfree the wrong pointer
        drm/amd/display: increase HDCP authentication delay
        drm/amd/display: Correctly cancel future watchdog and callback events
        drm/amd/display: Don't try hdcp1.4 when content_type is set to type1
        drm/amd/powerplay: move the ASIC specific nbio operation out of smu_v11_0.c
        drm/amd/powerplay: drop redundant BIF doorbell interrupt operations
        drm/amd/display: Fix dcn21 num_states
        drm/amd/display: Enable BT2020 in COLOR_ENCODING property
        drm/amd/display: LFC not working on 2.0x range monitors (v2)
        drm/amd/display: Support plane level CTM
        ...
      f5e94d10
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · 9ebe5422
      Linus Torvalds authored
      Pull input updates from Dmitry Torokhov:
       "An update to the Goodix touchscreen driver to enable it work properly
        on various Bay Trail and Cherry Trail devices, and a few other
        assorted changes"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (26 commits)
        Input: update SPDX tag for input-event-codes.h
        Input: i8042 - add Acer Aspire 5738z to nomux list
        Input: goodix - fix compilation when ACPI support is disabled
        dt-bindings: touchscreen: Convert edt-ft5x06 to json-schema
        Input: of_touchscreen - explicitly choose axis
        Input: goodix - support gt9147 touchpanel
        dt-bindings: touchscreen: goodix: support of gt9147
        Input: goodix - add support for Goodix GT917S
        Input: goodix - use string-based chip ID
        dt-bindings: input: touchscreen: add compatible string for Goodix GT917S
        Input: goodix - add support for more then one touch-key
        Input: goodix - fix spurious key release events
        Input: goodix - try to reset the controller if the i2c-test fails
        Input: goodix - restore config on resume if necessary
        Input: goodix - make goodix_send_cfg() take a raw buffer as argument
        Input: goodix - add minimum firmware size check
        Input: goodix - save a copy of the config from goodix_read_config()
        Input: goodix - move defines to above struct goodix_ts_data declaration
        Input: goodix - add support for controlling the IRQ pin through ACPI methods
        Input: goodix - add support for getting IRQ + reset GPIOs on Bay Trail devices
        ...
      9ebe5422
    • Linus Torvalds's avatar
      Merge tag 'thermal-v5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux · 34183ddd
      Linus Torvalds authored
      Pull thermal updates from Daniel Lezcano:
      
       - Convert tsens configuration DT binding to yaml (Rajeshwari)
      
       - Add interrupt support on the rcar sensor (Niklas Söderlund)
      
       - Add a new Spreadtrum thermal driver (Baolin Wang)
      
       - Add thermal binding for the fsl scu board, a new API to retrieve the
         sensor id bound to the thermal zone and i.MX system controller sensor
         (Anson Huang))
      
       - Remove warning log when a deferred probe is requested on Exynos
         (Marek Szyprowski)
      
       - Add the thermal monitoring unit support for imx8mm with its DT
         bindings (Anson Huang)
      
       - Rephrase the Kconfig text for clarity (Linus Walleij)
      
       - Use the gpio descriptor for the ti-soc-thermal (Linus Walleij)
      
       - Align msg structure to 4 bytes for i.MX SC, fix the Kconfig
         dependency, add the __may_be unused annotation for PM functions and
         the COMPILE_TEST option for imx8mm (Anson Huang)
      
       - Fix a dependency on regmap in Kconfig for qoriq (Yuantian Tang)
      
       - Add DT binding and support for the rcar gen3 r8a77961 and improve the
         error path on the rcar init function (Niklas Söderlund)
      
       - Cleanup and improvements for the tsens Qcom sensor (Amit Kucheria)
      
       - Improve code by removing lock and caching values in the rcar thermal
         sensor (Niklas Söderlund)
      
       - Cleanup in the qoriq drivers and add a call to
         imx_thermal_unregister_legacy_cooling in the removal function (Anson
         Huang)
      
       - Remove redundant 'maxItems' in tsens and sprd DT bindings (Rob
         Herring)
      
       - Change the thermal DT bindings by making the cooling-maps optional
         (Yuantian Tang)
      
       - Add Tiger Lake support (Sumeet Pawnikar)
      
       - Use scnprintf() for avoiding potential buffer overflow (Takashi Iwai)
      
       - Make pkg_temp_lock a raw_spinlock_t(Clark Williams)
      
       - Fix incorrect data types by changing them to signed on i.MX SC (Anson
         Huang)
      
       - Replace zero-length array with flexible-array member (Gustavo A. R.
         Silva)
      
       - Add support for i.MX8MP in the driver and in the DT bindings (Anson
         Huang)
      
       - Fix return value of the cpufreq_set_cur_state() function (Willy
         Wolff)
      
       - Remove abusing and scary WARN_ON in the cpufreq cooling device
         (Daniel Lezcano)
      
       - Fix build warning of incorrect argument type reported by sparse on
         imx8mm (Anson Huang)
      
       - Fix stub for the devfreq cooling device (Martin Blumenstingl)
      
       - Fix cpu idle cooling documentation (Sergey Vidishev)
      
      * tag 'thermal-v5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (52 commits)
        Documentation: cpu-idle-cooling: Fix diagram for 33% duty cycle
        thermal: devfreq_cooling: inline all stubs for CONFIG_DEVFREQ_THERMAL=n
        thermal: imx8mm: Fix build warning of incorrect argument type
        thermal/drivers/cpufreq_cooling: Remove abusing WARN_ON
        thermal/drivers/cpufreq_cooling: Fix return of cpufreq_set_cur_state
        thermal: imx8mm: Add i.MX8MP support
        dt-bindings: thermal: imx8mm-thermal: Add support for i.MX8MP
        thermal: qcom: tsens.h: Replace zero-length array with flexible-array member
        thermal: imx_sc_thermal: Fix incorrect data type
        thermal: int340x_thermal: Use scnprintf() for avoiding potential buffer overflow
        thermal: int340x: processor_thermal: Add Tiger Lake support
        thermal/x86_pkg_temp: Make pkg_temp_lock a raw_spinlock_t
        dt-bindings: thermal: make cooling-maps property optional
        dt-bindings: thermal: qcom-tsens: Remove redundant 'maxItems'
        dt-bindings: thermal: sprd: Remove redundant 'maxItems'
        thermal: imx: Calling imx_thermal_unregister_legacy_cooling() in .remove
        thermal: qoriq: Sort includes alphabetically
        thermal: qoriq: Use devm_add_action_or_reset() to handle all cleanups
        thermal: rcar_thermal: Remove lock in rcar_thermal_get_current_temp()
        thermal: rcar_thermal: Do not store ctemp in rcar_thermal_priv
        ...
      34183ddd
    • Linus Torvalds's avatar
      Merge tag 'mfd-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd · 8645f09b
      Linus Torvalds authored
      Pull mfd updates from Lee Jones:
       "New Drivers:
         - Add support for IQS620A/621/622/624/625 Azoteq IQS62X Sensors
      
        New Device Support:
         - Add support for ADC, IRQ, Regulator, RTC and WDT to Ricoh RN5T618 PMIC
         - Add support for Comet Lake to Intel LPSS
      
        New Functionality:
         - Add support for Charger Detection to Spreadtrum SC27xx PMICs
         - Add support for Interrupt Polarity to Dialog Semi DA9062/61 PMIC
         - Add ACPI enumeration support to Diolan DLN2 USB Adaptor
      
        Fix-ups:
         - Device Tree; iqs62x, rn5t618, cros_ec_dev, stm32-lptimer, rohm,bd71837, rohm,bd71847
         - I2C registration; rn5t618
         - Kconfig; MFD_CPCAP, AB8500_CORE, MFD_WM8994, MFD_WM97xx, MFD_STPMIC1
         - Use flexible-array members; omap-usb-tll, qcom-pm8xxx
         - Remove unnecessary casts; omap-usb-host, omap-usb-tll
         - Power (suspend/resume/poweroff) enhancements; rk808
         - Improve error/sanity checking; dln2
         - Use snprintf(); aat2870-core
      
        Bug Fixes:
         - Fix PCI IDs in intel-lpss-pci"
      
      * tag 'mfd-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (33 commits)
        mfd: intel-lpss: Fix Intel Elkhart Lake LPSS I2C input clock
        mfd: aat2870: Use scnprintf() for avoiding potential buffer overflow
        mfd: dln2: Allow to be enumerated via ACPI
        mfd: da9062: Add support for interrupt polarity defined in device tree
        dt-bindings: bd718x7: Yamlify and add BD71850
        mfd: dln2: Fix sanity checking for endpoints
        mfd: intel-lpss: Add Intel Comet Lake PCH-V PCI IDs
        mfd: sc27xx: Add USB charger type detection support
        dt-bindings: mfd: Document STM32 low power timer bindings
        mfd: rk808: Convert RK805 to shutdown/suspend hooks
        mfd: rk808: Reduce shutdown duplication
        mfd: rk808: Stop using syscore ops
        mfd: rk808: Ensure suspend/resume hooks always work
        mfd: rk808: Always use poweroff when requested
        mfd: omap: Remove useless cast for driver.name
        mfd: Kconfig: Fix some misspelling of the word functionality
        mfd: pm8xxx: Replace zero-length array with flexible-array member
        mfd: omap-usb-tll: Replace zero-length array with flexible-array member
        mfd: cpcap: Fix compile if MFD_CORE is not selected
        mfd: cros_ec: Check DT node for usbpd-notify add
        ...
      8645f09b
    • Linus Torvalds's avatar
      Merge tag 'backlight-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight · b574beb6
      Linus Torvalds authored
      Pull backlight updates from Lee Jones:
       "Switch pwm_bl and corgi_lcd drivers to use GPIO descriptors"
      
      * tag 'backlight-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
        backlight: corgi: Convert to use GPIO descriptors
        backlight: pwm_bl: Switch to full GPIO descriptor
      b574beb6
    • Linus Torvalds's avatar
      Merge tag 'leds-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds · 38e2c63e
      Linus Torvalds authored
      Pull LED updates from Pavel Machek:
       "One new driver, some driver changes, and some late minute cleanups --
        but those are just whitespace so should be okay.
      
        There are some major changes being prepared (multicolor, triggers) so
        the next release likely will be more interesting"
      
      * tag 'leds-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds:
        leds: core: Fix warning message when init_data
        leds: make functions easier to understand
        leds: sort Makefile entries
        leds: old enums are not really applicable to new code
        leds: ip30: label power LED as such
        leds: lm3532: make bitfield 'enabled' unsigned
        leds: leds-pwm: Replace zero-length array with flexible-array member
        leds: leds-is31fl32xx: Replace zero-length array with flexible-array member
        leds: pwm: remove useless pwm_period_ns
        leds: pwm: remove header
        leds: pwm: convert to atomic PWM API
        leds: pwm: simplify if condition
        leds: add SGI IP30 led support
        leds: lm3697: fix spelling mistake "To" -> "Too"
        leds: leds-bd2802: remove set but not used variable 'pdata'
        leds: ns2: Convert to GPIO descriptors
        leds: ns2: Absorb platform data
      38e2c63e
    • Peter Xu's avatar
      mm/gup: Mark lock taken only after a successful retake · c7b6a566
      Peter Xu authored
      It's definitely incorrect to mark the lock as taken even if
      down_read_killable() failed.
      
      This wass overlooked when we switched from down_read() to
      down_read_killable() because down_read() won't fail while
      down_read_killable() could.
      
      Fixes: 71335f37 ("mm/gup: allow to react to fatal signals")
      Reported-by: syzbot+a8c70b7f3579fc0587dc@syzkaller.appspotmail.com
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c7b6a566
    • Peter Xu's avatar
      mm/mempolicy: Allow lookup_node() to handle fatal signal · ba841078
      Peter Xu authored
      lookup_node() uses gup to pin the page and get node information.  It
      checks against ret>=0 assuming the page will be filled in.  However it's
      also possible that gup will return zero, for example, when the thread is
      quickly killed with a fatal signal.  Teach lookup_node() to gracefully
      return an error -EFAULT if it happens.
      
      Meanwhile, initialize "page" to NULL to avoid potential risk of
      exploiting the pointer.
      
      Fixes: 4426e945 ("mm/gup: allow VM_FAULT_RETRY for multiple times")
      Reported-by: syzbot+693dc11fcb53120b5559@syzkaller.appspotmail.com
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ba841078
  2. 07 Apr, 2020 28 commits