1. 05 Oct, 2019 40 commits
    • Darius Rad's avatar
      media: rc: imon: Allow iMON RC protocol for ffdc 7e device · 19a1fa14
      Darius Rad authored
      [ Upstream commit b20a6e29 ]
      
      Allow selecting the IR protocol, MCE or iMON, for a device that
      identifies as follows (with config id 0x7e):
      
      15c2:ffdc SoundGraph Inc. iMON PAD Remote Controller
      
      As the driver is structured to default to iMON when both RC
      protocols are supported, existing users of this device (using MCE
      protocol) will need to manually switch to MCE (RC-6) protocol from
      userspace (with ir-keytable, sysfs).
      Signed-off-by: default avatarDarius Rad <alpha@area49.net>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19a1fa14
    • Sean Young's avatar
      media: em28xx: modules workqueue not inited for 2nd device · a527d3d4
      Sean Young authored
      [ Upstream commit 46e4a266 ]
      
      syzbot reports an error on flush_request_modules() for the second device.
      This workqueue was never initialised so simply remove the offending line.
      
      usb 1-1: USB disconnect, device number 2
      em28xx 1-1:1.153: Disconnecting em28xx #1
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 12 at kernel/workqueue.c:3031
      __flush_work.cold+0x2c/0x36 kernel/workqueue.c:3031
      Kernel panic - not syncing: panic_on_warn set ...
      CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.3.0-rc2+ #25
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Workqueue: usb_hub_wq hub_event
      Call Trace:
        __dump_stack lib/dump_stack.c:77 [inline]
        dump_stack+0xca/0x13e lib/dump_stack.c:113
        panic+0x2a3/0x6da kernel/panic.c:219
        __warn.cold+0x20/0x4a kernel/panic.c:576
        report_bug+0x262/0x2a0 lib/bug.c:186
        fixup_bug arch/x86/kernel/traps.c:179 [inline]
        fixup_bug arch/x86/kernel/traps.c:174 [inline]
        do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
        do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
        invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1026
      RIP: 0010:__flush_work.cold+0x2c/0x36 kernel/workqueue.c:3031
      Code: 9a 22 00 48 c7 c7 20 e4 c5 85 e8 d9 3a 0d 00 0f 0b 45 31 e4 e9 98 86
      ff ff e8 51 9a 22 00 48 c7 c7 20 e4 c5 85 e8 be 3a 0d 00 <0f> 0b 45 31 e4
      e9 7d 86 ff ff e8 36 9a 22 00 48 c7 c7 20 e4 c5 85
      RSP: 0018:ffff8881da20f720 EFLAGS: 00010286
      RAX: 0000000000000024 RBX: dffffc0000000000 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffffffff8128a0fd RDI: ffffed103b441ed6
      RBP: ffff8881da20f888 R08: 0000000000000024 R09: fffffbfff11acd9a
      R10: fffffbfff11acd99 R11: ffffffff88d66ccf R12: 0000000000000000
      R13: 0000000000000001 R14: ffff8881c6685df8 R15: ffff8881d2a85b78
        flush_request_modules drivers/media/usb/em28xx/em28xx-cards.c:3325 [inline]
        em28xx_usb_disconnect.cold+0x280/0x2a6
      drivers/media/usb/em28xx/em28xx-cards.c:4023
        usb_unbind_interface+0x1bd/0x8a0 drivers/usb/core/driver.c:423
        __device_release_driver drivers/base/dd.c:1120 [inline]
        device_release_driver_internal+0x404/0x4c0 drivers/base/dd.c:1151
        bus_remove_device+0x2dc/0x4a0 drivers/base/bus.c:556
        device_del+0x420/0xb10 drivers/base/core.c:2288
        usb_disable_device+0x211/0x690 drivers/usb/core/message.c:1237
        usb_disconnect+0x284/0x8d0 drivers/usb/core/hub.c:2199
        hub_port_connect drivers/usb/core/hub.c:4949 [inline]
        hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
        port_event drivers/usb/core/hub.c:5359 [inline]
        hub_event+0x1454/0x3640 drivers/usb/core/hub.c:5441
        process_one_work+0x92b/0x1530 kernel/workqueue.c:2269
        process_scheduled_works kernel/workqueue.c:2331 [inline]
        worker_thread+0x7ab/0xe20 kernel/workqueue.c:2417
        kthread+0x318/0x420 kernel/kthread.c:255
        ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
      Kernel Offset: disabled
      Rebooting in 86400 seconds..
      
      Fixes: be7fd3c3 ("media: em28xx: Hauppauge DualHD second tuner functionality)
      Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
      Reviewed-by: default avatarBrad Love <brad@nextdimension.cc>
      Reported-by: syzbot+b7f57261c521087d89bb@syzkaller.appspotmail.com
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a527d3d4
    • Geert Uytterhoeven's avatar
      media: fdp1: Reduce FCP not found message level to debug · 6a1c59a7
      Geert Uytterhoeven authored
      [ Upstream commit 4fd22938 ]
      
      When support for the IPMMU is not enabled, the FDP driver may be
      probe-deferred multiple times, causing several messages to be printed
      like:
      
          rcar_fdp1 fe940000.fdp1: FCP not found (-517)
          rcar_fdp1 fe944000.fdp1: FCP not found (-517)
      
      Fix this by reducing the message level to debug level, as is done in the
      VSP1 driver.
      
      Fixes: 4710b752 ("[media] v4l: Add Renesas R-Car FDP1 Driver")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6a1c59a7
    • Matthias Brugger's avatar
      media: mtk-mdp: fix reference count on old device tree · e3f5f626
      Matthias Brugger authored
      [ Upstream commit 864919ea ]
      
      of_get_next_child() increments the reference count of the returning
      device_node. Decrement it in the check if we are using the old or the
      new DTB.
      
      Fixes: ba1f1f70 ("[media] media: mtk-mdp: Fix mdp device tree")
      Signed-off-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
      Acked-by: default avatarHoulong Wei <houlong.wei@mediatek.com>
      [hverkuil-cisco@xs4all.nl: use node instead of parent as temp variable]
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3f5f626
    • Arnaldo Carvalho de Melo's avatar
      perf test vfs_getname: Disable ~/.perfconfig to get default output · 066afce8
      Arnaldo Carvalho de Melo authored
      [ Upstream commit 4fe94ce1 ]
      
      To get the expected output we have to ignore whatever changes the user
      has in its ~/.perfconfig file, so set PERF_CONFIG to /dev/null to
      achieve that.
      
      Before:
      
        # egrep 'trace|show_' ~/.perfconfig
        [trace]
        	show_zeros = yes
        	show_duration = no
        	show_timestamp = no
        	show_arg_names = no
        	show_prefix = yes
        # echo $PERF_CONFIG
      
        # perf test "trace + vfs_getname"
        70: Check open filename arg using perf trace + vfs_getname: FAILED!
        # export PERF_CONFIG=/dev/null
        # perf test "trace + vfs_getname"
        70: Check open filename arg using perf trace + vfs_getname: Ok
        #
      
      After:
      
        # egrep 'trace|show_' ~/.perfconfig
        [trace]
        	show_zeros = yes
        	show_duration = no
        	show_timestamp = no
        	show_arg_names = no
        	show_prefix = yes
        # echo $PERF_CONFIG
      
        # perf test "trace + vfs_getname"
        70: Check open filename arg using perf trace + vfs_getname: Ok
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Link: https://lkml.kernel.org/n/tip-3up27pexg5i3exuzqrvt4m8u@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      066afce8
    • Arnaldo Carvalho de Melo's avatar
      perf config: Honour $PERF_CONFIG env var to specify alternate .perfconfig · 96b61fe7
      Arnaldo Carvalho de Melo authored
      [ Upstream commit 61a461fc ]
      
      We had this comment in Documentation/perf_counter/config.c, i.e. since
      when we got this from the git sources, but never really did that
      getenv("PERF_CONFIG"), do it now as I need to disable whatever
      ~/.perfconfig root has so that tests parsing tool output are done for
      the expected default output or that we specify an alternate config file
      that when read will make the tools produce expected output.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Fixes: 07800601 ("perf_counter tools: add in basic glue from Git")
      Link: https://lkml.kernel.org/n/tip-jo209zac9rut0dz1rqvbdlgm@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96b61fe7
    • Hans Verkuil's avatar
      media: gspca: zero usb_buf on error · db751f6d
      Hans Verkuil authored
      [ Upstream commit 4843a543 ]
      
      If reg_r() fails, then gspca_dev->usb_buf was left uninitialized,
      and some drivers used the contents of that buffer in logic.
      
      This caused several syzbot errors:
      
      https://syzkaller.appspot.com/bug?extid=397fd082ce5143e2f67d
      https://syzkaller.appspot.com/bug?extid=1a35278dd0ebfb3a038a
      https://syzkaller.appspot.com/bug?extid=06ddf1788cfd048c5e82
      
      I analyzed the gspca drivers and zeroed the buffer where needed.
      
      Reported-and-tested-by: syzbot+1a35278dd0ebfb3a038a@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+397fd082ce5143e2f67d@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+06ddf1788cfd048c5e82@syzkaller.appspotmail.com
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      db751f6d
    • Peter Zijlstra's avatar
      idle: Prevent late-arriving interrupts from disrupting offline · 51111023
      Peter Zijlstra authored
      [ Upstream commit e78a7614 ]
      
      Scheduling-clock interrupts can arrive late in the CPU-offline process,
      after idle entry and the subsequent call to cpuhp_report_idle_dead().
      Once execution passes the call to rcu_report_dead(), RCU is ignoring
      the CPU, which results in lockdep complaints when the interrupt handler
      uses RCU:
      
      ------------------------------------------------------------------------
      
      =============================
      WARNING: suspicious RCU usage
      5.2.0-rc1+ #681 Not tainted
      -----------------------------
      kernel/sched/fair.c:9542 suspicious rcu_dereference_check() usage!
      
      other info that might help us debug this:
      
      RCU used illegally from offline CPU!
      rcu_scheduler_active = 2, debug_locks = 1
      no locks held by swapper/5/0.
      
      stack backtrace:
      CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.2.0-rc1+ #681
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011
      Call Trace:
       <IRQ>
       dump_stack+0x5e/0x8b
       trigger_load_balance+0xa8/0x390
       ? tick_sched_do_timer+0x60/0x60
       update_process_times+0x3b/0x50
       tick_sched_handle+0x2f/0x40
       tick_sched_timer+0x32/0x70
       __hrtimer_run_queues+0xd3/0x3b0
       hrtimer_interrupt+0x11d/0x270
       ? sched_clock_local+0xc/0x74
       smp_apic_timer_interrupt+0x79/0x200
       apic_timer_interrupt+0xf/0x20
       </IRQ>
      RIP: 0010:delay_tsc+0x22/0x50
      Code: ff 0f 1f 80 00 00 00 00 65 44 8b 05 18 a7 11 48 0f ae e8 0f 31 48 89 d6 48 c1 e6 20 48 09 c6 eb 0e f3 90 65 8b 05 fe a6 11 48 <41> 39 c0 75 18 0f ae e8 0f 31 48 c1 e2 20 48 09 c2 48 89 d0 48 29
      RSP: 0000:ffff8f92c0157ed0 EFLAGS: 00000212 ORIG_RAX: ffffffffffffff13
      RAX: 0000000000000005 RBX: ffff8c861f356400 RCX: ffff8f92c0157e64
      RDX: 000000321214c8cc RSI: 00000032120daa7f RDI: 0000000000260f15
      RBP: 0000000000000005 R08: 0000000000000005 R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000
      R13: 0000000000000000 R14: ffff8c861ee18000 R15: ffff8c861ee18000
       cpuhp_report_idle_dead+0x31/0x60
       do_idle+0x1d5/0x200
       ? _raw_spin_unlock_irqrestore+0x2d/0x40
       cpu_startup_entry+0x14/0x20
       start_secondary+0x151/0x170
       secondary_startup_64+0xa4/0xb0
      
      ------------------------------------------------------------------------
      
      This happens rarely, but can be forced by happen more often by
      placing delays in cpuhp_report_idle_dead() following the call to
      rcu_report_dead().  With this in place, the following rcutorture
      scenario reproduces the problem within a few minutes:
      
      tools/testing/selftests/rcutorture/bin/kvm.sh --cpus 8 --duration 5 --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" --configs "TREE04"
      
      This commit uses the crude but effective expedient of moving the disabling
      of interrupts within the idle loop to precede the cpu_is_offline()
      check.  It also invokes tick_nohz_idle_stop_tick() instead of
      tick_nohz_idle_stop_tick_protected() to shut off the scheduling-clock
      interrupt.
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      [ paulmck: Revert tick_nohz_idle_stop_tick_protected() removal, new callers. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51111023
    • Phil Auld's avatar
      sched/fair: Use rq_lock/unlock in online_fair_sched_group · 9addfbd4
      Phil Auld authored
      [ Upstream commit a46d14ec ]
      
      Enabling WARN_DOUBLE_CLOCK in /sys/kernel/debug/sched_features causes
      warning to fire in update_rq_clock. This seems to be caused by onlining
      a new fair sched group not using the rq lock wrappers.
      
        [] rq->clock_update_flags & RQCF_UPDATED
        [] WARNING: CPU: 5 PID: 54385 at kernel/sched/core.c:210 update_rq_clock+0xec/0x150
      
        [] Call Trace:
        []  online_fair_sched_group+0x53/0x100
        []  cpu_cgroup_css_online+0x16/0x20
        []  online_css+0x1c/0x60
        []  cgroup_apply_control_enable+0x231/0x3b0
        []  cgroup_mkdir+0x41b/0x530
        []  kernfs_iop_mkdir+0x61/0xa0
        []  vfs_mkdir+0x108/0x1a0
        []  do_mkdirat+0x77/0xe0
        []  do_syscall_64+0x55/0x1d0
        []  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Using the wrappers in online_fair_sched_group instead of the raw locking
      removes this warning.
      
      [ tglx: Use rq_*lock_irq() ]
      Signed-off-by: default avatarPhil Auld <pauld@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: https://lkml.kernel.org/r/20190801133749.11033-1-pauld@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      9addfbd4
    • Sudeep Holla's avatar
      firmware: arm_scmi: Check if platform has released shmem before using · 6e9d4502
      Sudeep Holla authored
      [ Upstream commit 9dc34d63 ]
      
      Sometimes platfom may take too long to respond to the command and OS
      might timeout before platform transfer the ownership of the shared
      memory region to the OS with the response.
      
      Since the mailbox channel associated with the channel is freed and new
      commands are dispatch on the same channel, OS needs to wait until it
      gets back the ownership. If not, either OS may end up overwriting the
      platform response for the last command(which is fine as OS timed out
      that command) or platform might overwrite the payload for the next
      command with the response for the old.
      
      The latter is problematic as platform may end up interpretting the
      response as the payload. In order to avoid such race, let's wait until
      the OS gets back the ownership before we prepare the shared memory with
      the payload for the next command.
      Reported-by: default avatarJim Quinlan <james.quinlan@broadcom.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6e9d4502
    • Xiaofei Tan's avatar
      efi: cper: print AER info of PCIe fatal error · 0dbdc198
      Xiaofei Tan authored
      [ Upstream commit b194a77f ]
      
      AER info of PCIe fatal error is not printed in the current driver.
      Because APEI driver will panic directly for fatal error, and can't
      run to the place of printing AER info.
      
      An example log is as following:
      {763}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 11
      {763}[Hardware Error]: event severity: fatal
      {763}[Hardware Error]:  Error 0, type: fatal
      {763}[Hardware Error]:   section_type: PCIe error
      {763}[Hardware Error]:   port_type: 0, PCIe end point
      {763}[Hardware Error]:   version: 4.0
      {763}[Hardware Error]:   command: 0x0000, status: 0x0010
      {763}[Hardware Error]:   device_id: 0000:82:00.0
      {763}[Hardware Error]:   slot: 0
      {763}[Hardware Error]:   secondary_bus: 0x00
      {763}[Hardware Error]:   vendor_id: 0x8086, device_id: 0x10fb
      {763}[Hardware Error]:   class_code: 000002
      Kernel panic - not syncing: Fatal hardware error!
      
      This issue was imported by the patch, '37448adf ("aerdrv: Move
      cper_print_aer() call out of interrupt context")'. To fix this issue,
      this patch adds print of AER info in cper_print_pcie() for fatal error.
      
      Here is the example log after this patch applied:
      {24}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 10
      {24}[Hardware Error]: event severity: fatal
      {24}[Hardware Error]:  Error 0, type: fatal
      {24}[Hardware Error]:   section_type: PCIe error
      {24}[Hardware Error]:   port_type: 0, PCIe end point
      {24}[Hardware Error]:   version: 4.0
      {24}[Hardware Error]:   command: 0x0546, status: 0x4010
      {24}[Hardware Error]:   device_id: 0000:01:00.0
      {24}[Hardware Error]:   slot: 0
      {24}[Hardware Error]:   secondary_bus: 0x00
      {24}[Hardware Error]:   vendor_id: 0x15b3, device_id: 0x1019
      {24}[Hardware Error]:   class_code: 000002
      {24}[Hardware Error]:   aer_uncor_status: 0x00040000, aer_uncor_mask: 0x00000000
      {24}[Hardware Error]:   aer_uncor_severity: 0x00062010
      {24}[Hardware Error]:   TLP Header: 000000c0 01010000 00000001 00000000
      Kernel panic - not syncing: Fatal hardware error!
      
      Fixes: 37448adf ("aerdrv: Move cper_print_aer() call out of interrupt context")
      Signed-off-by: default avatarXiaofei Tan <tanxiaofei@huawei.com>
      Reviewed-by: default avatarJames Morse <james.morse@arm.com>
      [ardb: put parens around terms of && operator]
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0dbdc198
    • Stephen Douthit's avatar
      EDAC, pnd2: Fix ioremap() size in dnv_rd_reg() · 4410b851
      Stephen Douthit authored
      [ Upstream commit 29a3388b ]
      
      Depending on how BIOS has marked the reserved region containing the 32KB
      MCHBAR you can get warnings like:
      
      resource sanity check: requesting [mem 0xfed10000-0xfed1ffff], which spans more than reserved [mem 0xfed10000-0xfed17fff]
      caller dnv_rd_reg+0xc8/0x240 [pnd2_edac] mapping multiple BARs
      
      Not all of the mmio regions used in dnv_rd_reg() are the same size.  The
      MCHBAR window is 32KB and the sideband ports are 64KB.  Pass the correct
      size to ioremap() depending on which resource we're reading from.
      Signed-off-by: default avatarStephen Douthit <stephend@silicom-usa.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4410b851
    • Alessio Balsini's avatar
      loop: Add LOOP_SET_DIRECT_IO to compat ioctl · cf8f20a1
      Alessio Balsini authored
      [ Upstream commit fdbe4eee ]
      
      Enabling Direct I/O with loop devices helps reducing memory usage by
      avoiding double caching.  32 bit applications running on 64 bits systems
      are currently not able to request direct I/O because is missing from the
      lo_compat_ioctl.
      
      This patch fixes the compatibility issue mentioned above by exporting
      LOOP_SET_DIRECT_IO as additional lo_compat_ioctl() entry.
      The input argument for this ioctl is a single long converted to a 1-bit
      boolean, so compatibility is preserved.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAlessio Balsini <balsini@android.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cf8f20a1
    • Jiri Slaby's avatar
      ACPI / processor: don't print errors for processorIDs == 0xff · 18e5e458
      Jiri Slaby authored
      [ Upstream commit 2c2b005f ]
      
      Some platforms define their processors in this manner:
          Device (SCK0)
          {
      	Name (_HID, "ACPI0004" /* Module Device */)  // _HID: Hardware ID
      	Name (_UID, "CPUSCK0")  // _UID: Unique ID
      	Processor (CP00, 0x00, 0x00000410, 0x06){}
      	Processor (CP01, 0x02, 0x00000410, 0x06){}
      	Processor (CP02, 0x04, 0x00000410, 0x06){}
      	Processor (CP03, 0x06, 0x00000410, 0x06){}
      	Processor (CP04, 0x01, 0x00000410, 0x06){}
      	Processor (CP05, 0x03, 0x00000410, 0x06){}
      	Processor (CP06, 0x05, 0x00000410, 0x06){}
      	Processor (CP07, 0x07, 0x00000410, 0x06){}
      	Processor (CP08, 0xFF, 0x00000410, 0x06){}
      	Processor (CP09, 0xFF, 0x00000410, 0x06){}
      	Processor (CP0A, 0xFF, 0x00000410, 0x06){}
      	Processor (CP0B, 0xFF, 0x00000410, 0x06){}
      ...
      
      The processors marked as 0xff are invalid, there are only 8 of them in
      this case.
      
      So do not print an error on ids == 0xff, just print an info message.
      Actually, we could return ENODEV even on the first CPU with ID 0xff, but
      ACPI spec does not forbid the 0xff value to be a processor ID. Given
      0xff could be a correct one, we would break working systems if we
      returned ENODEV.
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18e5e458
    • Randy Dunlap's avatar
      media: media/platform: fsl-viu.c: fix build for MICROBLAZE · 465bc6e8
      Randy Dunlap authored
      [ Upstream commit 6898dd58 ]
      
      arch/microblaze/ defines out_be32() and in_be32(), so don't do that
      again in the driver source.
      
      Fixes these build warnings:
      
      ../drivers/media/platform/fsl-viu.c:36: warning: "out_be32" redefined
      ../arch/microblaze/include/asm/io.h:50: note: this is the location of the previous definition
      ../drivers/media/platform/fsl-viu.c:37: warning: "in_be32" redefined
      ../arch/microblaze/include/asm/io.h:53: note: this is the location of the previous definition
      
      Fixes: 29d75068 ("media: fsl-viu: allow building it with COMPILE_TEST")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      465bc6e8
    • Guoqing Jiang's avatar
      md: don't set In_sync if array is frozen · 37153845
      Guoqing Jiang authored
      [ Upstream commit 062f5b2a ]
      
      When a disk is added to array, the following path is called in mdadm.
      
      Manage_subdevs -> sysfs_freeze_array
                     -> Manage_add
                     -> sysfs_set_str(&info, NULL, "sync_action","idle")
      
      Then from kernel side, Manage_add invokes the path (add_new_disk ->
      validate_super = super_1_validate) to set In_sync flag.
      
      Since In_sync means "device is in_sync with rest of array", and the new
      added disk need to resync thread to help the synchronization of data.
      And md_reap_sync_thread would call spare_active to set In_sync for the
      new added disk finally. So don't set In_sync if array is in frozen.
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      37153845
    • Guoqing Jiang's avatar
      md: don't call spare_active in md_reap_sync_thread if all member devices can't work · d38aff20
      Guoqing Jiang authored
      [ Upstream commit 0d8ed0e9 ]
      
      When add one disk to array, the md_reap_sync_thread is responsible
      to activate the spare and set In_sync flag for the new member in
      spare_active().
      
      But if raid1 has one member disk A, and disk B is added to the array.
      Then we offline A before all the datas are synchronized from A to B,
      obviously B doesn't have the latest data as A, but B is still marked
      with In_sync flag.
      
      So let's not call spare_active under the condition, otherwise B is
      still showed with 'U' state which is not correct.
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d38aff20
    • Yufen Yu's avatar
      md/raid1: end bio when the device faulty · 1cd972e0
      Yufen Yu authored
      [ Upstream commit eeba6809 ]
      
      When write bio return error, it would be added to conf->retry_list
      and wait for raid1d thread to retry write and acknowledge badblocks.
      
      In narrow_write_error(), the error bio will be split in the unit of
      badblock shift (such as one sector) and raid1d thread issues them
      one by one. Until all of the splited bio has finished, raid1d thread
      can go on processing other things, which is time consuming.
      
      But, there is a scene for error handling that is not necessary.
      When the device has been set faulty, flush_bio_list() may end
      bios in pending_bio_list with error status. Since these bios
      has not been issued to the device actually, error handlding to
      retry write and acknowledge badblocks make no sense.
      
      Even without that scene, when the device is faulty, badblocks info
      can not be written out to the device. Thus, we also no need to
      handle the error IO.
      Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1cd972e0
    • Qian Cai's avatar
      arm64/prefetch: fix a -Wtype-limits warning · 7d75275f
      Qian Cai authored
      [ Upstream commit b99286b0 ]
      
      The commit d5370f75 ("arm64: prefetch: add alternative pattern for
      CPUs without a prefetcher") introduced MIDR_IS_CPU_MODEL_RANGE() to be
      used in has_no_hw_prefetch() with rv_min=0 which generates a compilation
      warning from GCC,
      
      In file included from ./arch/arm64/include/asm/cache.h:8,
                     from ./include/linux/cache.h:6,
                     from ./include/linux/printk.h:9,
                     from ./include/linux/kernel.h:15,
                     from ./include/linux/cpumask.h:10,
                     from arch/arm64/kernel/cpufeature.c:11:
      arch/arm64/kernel/cpufeature.c: In function 'has_no_hw_prefetch':
      ./arch/arm64/include/asm/cputype.h:59:26: warning: comparison of
      unsigned expression >= 0 is always true [-Wtype-limits]
      _model == (model) && rv >= (rv_min) && rv <= (rv_max);  \
                              ^~
      arch/arm64/kernel/cpufeature.c:889:9: note: in expansion of macro
      'MIDR_IS_CPU_MODEL_RANGE'
      return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX,
             ^~~~~~~~~~~~~~~~~~~~~~~
      
      Fix it by converting MIDR_IS_CPU_MODEL_RANGE to a static inline
      function.
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d75275f
    • Kuninori Morimoto's avatar
      ASoC: rsnd: don't call clk_get_rate() under atomic context · 829bebdc
      Kuninori Morimoto authored
      [ Upstream commit 06e8f5c8 ]
      
      ADG is using clk_get_rate() under atomic context, thus, we might
      have scheduling issue.
      To avoid this issue, we need to get/keep clk rate under
      non atomic context.
      
      We need to handle ADG as special device at Renesas Sound driver.
      From SW point of view, we want to impletent it as
      rsnd_mod_ops :: prepare, but it makes code just complicate.
      
      To avoid complicated code/patch, this patch adds new clk_rate[] array,
      and keep clk IN rate when rsnd_adg_clk_enable() was called.
      Reported-by: default avatarLeon Kong <Leon.KONG@cn.bosch.com>
      Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Tested-by: default avatarLeon Kong <Leon.KONG@cn.bosch.com>
      Link: https://lore.kernel.org/r/87v9vb0xkp.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      829bebdc
    • Dan Carpenter's avatar
      EDAC/altera: Use the proper type for the IRQ status bits · f5bef62d
      Dan Carpenter authored
      [ Upstream commit 8faa1cf6 ]
      
      Smatch complains about the cast of a u32 pointer to unsigned long:
      
        drivers/edac/altera_edac.c:1878 altr_edac_a10_irq_handler()
        warn: passing casted pointer '&irq_status' to 'find_first_bit()'
      
      This code wouldn't work on a 64 bit big endian system because it would
      read past the end of &irq_status.
      
       [ bp: massage. ]
      
      Fixes: 13ab8448 ("EDAC, altera: Add ECC Manager IRQ controller support")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarThor Thayer <thor.thayer@linux.intel.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: kernel-janitors@vger.kernel.org
      Cc: linux-edac <linux-edac@vger.kernel.org>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Link: https://lkml.kernel.org/r/20190624134717.GA1754@mwandaSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      f5bef62d
    • chenzefeng's avatar
      ia64:unwind: fix double free for mod->arch.init_unw_table · 87bc43e2
      chenzefeng authored
      [ Upstream commit c5e5c48c ]
      
      The function free_module in file kernel/module.c as follow:
      
      void free_module(struct module *mod) {
      	......
      	module_arch_cleanup(mod);
      	......
      	module_arch_freeing_init(mod);
      	......
      }
      
      Both module_arch_cleanup and module_arch_freeing_init function
      would free the mod->arch.init_unw_table, which cause double free.
      
      Here, set mod->arch.init_unw_table = NULL after remove the unwind
      table to avoid double free.
      Signed-off-by: default avatarchenzefeng <chenzefeng2@huawei.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87bc43e2
    • Ard van Breemen's avatar
      ALSA: usb-audio: Skip bSynchAddress endpoint check if it is invalid · ca57eca3
      Ard van Breemen authored
      [ Upstream commit 1b34121d ]
      
      The Linux kernel assumes that get_endpoint(alts,0) and
      get_endpoint(alts,1) are eachothers feedback endpoints.
      To reassure that validity it will test bsynchaddress to comply with that
      assumption. But if the bsyncaddress is 0 (invalid), it will flag that as
      a wrong assumption and return an error.
      Fix: Skip the test if bSynchAddress is 0.
      Note: those with a valid bSynchAddress should have a code quirck added.
      Signed-off-by: default avatarArd van Breemen <ard@kwaak.net>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca57eca3
    • Vinod Koul's avatar
      base: soc: Export soc_device_register/unregister APIs · d76b5ac5
      Vinod Koul authored
      [ Upstream commit f7ccc7a3 ]
      
      Qcom Socinfo driver can be built as a module, so
      export these two APIs.
      Tested-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarVaishali Thakkar <vaishali.thakkar@linaro.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d76b5ac5
    • Oliver Neukum's avatar
      media: iguanair: add sanity checks · 4a75e77e
      Oliver Neukum authored
      [ Upstream commit ab1cbdf1 ]
      
      The driver needs to check the endpoint types, too, as opposed
      to the number of endpoints. This also requires moving the check earlier.
      
      Reported-by: syzbot+01a77b82edaa374068e1@syzkaller.appspotmail.com
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4a75e77e
    • Robert Richter's avatar
      EDAC/mc: Fix grain_bits calculation · fe8fc7d7
      Robert Richter authored
      [ Upstream commit 3724ace5 ]
      
      The grain in EDAC is defined as "minimum granularity for an error
      report, in bytes". The following calculation of the grain_bits in
      edac_mc is wrong:
      
      	grain_bits = fls_long(e->grain) + 1;
      
      Where grain_bits is defined as:
      
      	grain = 1 << grain_bits
      
      Example:
      
      	grain = 8	# 64 bit (8 bytes)
      	grain_bits = fls_long(8) + 1
      	grain_bits = 4 + 1 = 5
      
      	grain = 1 << grain_bits
      	grain = 1 << 5 = 32
      
      Replace it with the correct calculation:
      
      	grain_bits = fls_long(e->grain - 1);
      
      The example gives now:
      
      	grain_bits = fls_long(8 - 1)
      	grain_bits = fls_long(7)
      	grain_bits = 3
      
      	grain = 1 << 3 = 8
      
      Also, check if the hardware reports a reasonable grain != 0 and fallback
      with a warning to 1 byte granularity otherwise.
      
       [ bp: massage a bit. ]
      Signed-off-by: default avatarRobert Richter <rrichter@marvell.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Link: https://lkml.kernel.org/r/20190624150758.6695-2-rrichter@marvell.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe8fc7d7
    • Jia-Ju Bai's avatar
      ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls() · 55a98e87
      Jia-Ju Bai authored
      [ Upstream commit 2127c01b ]
      
      In build_adc_controls(), there is an if statement on line 773 to check
      whether ak->adc_info is NULL:
          if (! ak->adc_info ||
              ! ak->adc_info[mixer_ch].switch_name)
      
      When ak->adc_info is NULL, it is used on line 792:
          knew.name = ak->adc_info[mixer_ch].selector_name;
      
      Thus, a possible null-pointer dereference may occur.
      
      To fix this bug, referring to lines 773 and 774, ak->adc_info
      and ak->adc_info[mixer_ch].selector_name are checked before being used.
      
      This bug is found by a static analysis tool STCheck written by us.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      55a98e87
    • Takashi Iwai's avatar
      ALSA: hda - Show the fatal CORB/RIRB error more clearly · 1af6822f
      Takashi Iwai authored
      [ Upstream commit dd65f7e1 ]
      
      The last fallback of CORB/RIRB communication error recovery is to turn
      on the single command mode, and this last resort usually means that
      something is really screwed up.  Instead of a normal dev_err(), show
      the error more clearly with dev_WARN() with the caller stack trace.
      
      Also, show the bus-reset fallback also as an error, too.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1af6822f
    • Thomas Gleixner's avatar
      x86/apic: Soft disable APIC before initializing it · b40c15c2
      Thomas Gleixner authored
      [ Upstream commit 2640da4c ]
      
      If the APIC was already enabled on entry of setup_local_APIC() then
      disabling it soft via the SPIV register makes a lot of sense.
      
      That masks all LVT entries and brings it into a well defined state.
      
      Otherwise previously enabled LVTs which are not touched in the setup
      function stay unmasked and might surprise the just booting kernel.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20190722105219.068290579@linutronix.deSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      b40c15c2
    • Grzegorz Halat's avatar
      x86/reboot: Always use NMI fallback when shutdown via reboot vector IPI fails · ce7fdd5c
      Grzegorz Halat authored
      [ Upstream commit 747d5a1b ]
      
      A reboot request sends an IPI via the reboot vector and waits for all other
      CPUs to stop. If one or more CPUs are in critical regions with interrupts
      disabled then the IPI is not handled on those CPUs and the shutdown hangs
      if native_stop_other_cpus() is called with the wait argument set.
      
      Such a situation can happen when one CPU was stopped within a lock held
      section and another CPU is trying to acquire that lock with interrupts
      disabled. There are other scenarios which can cause such a lockup as well.
      
      In theory the shutdown should be attempted by an NMI IPI after the timeout
      period elapsed. Though the wait loop after sending the reboot vector IPI
      prevents this. It checks the wait request argument and the timeout. If wait
      is set, which is true for sys_reboot() then it won't fall through to the
      NMI shutdown method after the timeout period has finished.
      
      This was an oversight when the NMI shutdown mechanism was added to handle
      the 'reboot IPI is not working' situation. The mechanism was added to deal
      with stuck panic shutdowns, which do not have the wait request set, so the
      'wait request' case was probably not considered.
      
      Remove the wait check from the post reboot vector IPI wait loop and enforce
      that the wait loop in the NMI fallback path is invoked even if NMI IPIs are
      disabled or the registration of the NMI handler fails. That second wait
      loop will then hang if not all CPUs shutdown and the wait argument is set.
      
      [ tglx: Avoid the hard to parse line break in the NMI fallback path,
        	add comments and massage the changelog ]
      
      Fixes: 7d007d21 ("x86/reboot: Use NMI to assist in shutting down if IRQ fails")
      Signed-off-by: default avatarGrzegorz Halat <ghalat@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Don Zickus <dzickus@redhat.com>
      Link: https://lkml.kernel.org/r/20190628122813.15500-1-ghalat@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce7fdd5c
    • Juri Lelli's avatar
      sched/deadline: Fix bandwidth accounting at all levels after offline migration · 0f308569
      Juri Lelli authored
      [ Upstream commit 59d06cea ]
      
      If a task happens to be throttled while the CPU it was running on gets
      hotplugged off, the bandwidth associated with the task is not correctly
      migrated with it when the replenishment timer fires (offline_migration).
      
      Fix things up, for this_bw, running_bw and total_bw, when replenishment
      timer fires and task is migrated (dl_task_offline_migration()).
      Tested-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: bristot@redhat.com
      Cc: claudio@evidence.eu.com
      Cc: lizefan@huawei.com
      Cc: longman@redhat.com
      Cc: luca.abeni@santannapisa.it
      Cc: mathieu.poirier@linaro.org
      Cc: rostedt@goodmis.org
      Cc: tj@kernel.org
      Cc: tommaso.cucinotta@santannapisa.it
      Link: https://lkml.kernel.org/r/20190719140000.31694-5-juri.lelli@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0f308569
    • Thomas Gleixner's avatar
      x86/apic: Make apic_pending_intr_clear() more robust · d29c7b8b
      Thomas Gleixner authored
      [ Upstream commit cc8bf191 ]
      
      In course of developing shorthand based IPI support issues with the
      function which tries to clear eventually pending ISR bits in the local APIC
      were observed.
      
        1) O-day testing triggered the WARN_ON() in apic_pending_intr_clear().
      
           This warning is emitted when the function fails to clear pending ISR
           bits or observes pending IRR bits which are not delivered to the CPU
           after the stale ISR bit(s) are ACK'ed.
      
           Unfortunately the function only emits a WARN_ON() and fails to dump
           the IRR/ISR content. That's useless for debugging.
      
           Feng added spot on debug printk's which revealed that the stale IRR
           bit belonged to the APIC timer interrupt vector, but adding ad hoc
           debug code does not help with sporadic failures in the field.
      
           Rework the loop so the full IRR/ISR contents are saved and on failure
           dumped.
      
        2) The loop termination logic is interesting at best.
      
           If the machine has no TSC or cpu_khz is not known yet it tries 1
           million times to ack stale IRR/ISR bits. What?
      
           With TSC it uses the TSC to calculate the loop termination. It takes a
           timestamp at entry and terminates the loop when:
      
           	  (rdtsc() - start_timestamp) >= (cpu_hkz << 10)
      
           That's roughly one second.
      
           Both methods are problematic. The APIC has 256 vectors, which means
           that in theory max. 256 IRR/ISR bits can be set. In practice this is
           impossible and the chance that more than a few bits are set is close
           to zero.
      
           With the pure loop based approach the 1 million retries are complete
           overkill.
      
           With TSC this can terminate too early in a guest which is running on a
           heavily loaded host even with only a couple of IRR/ISR bits set. The
           reason is that after acknowledging the highest priority ISR bit,
           pending IRRs must get serviced first before the next round of
           acknowledge can take place as the APIC (real and virtualized) does not
           honour EOI without a preceeding interrupt on the CPU. And every APIC
           read/write takes a VMEXIT if the APIC is virtualized. While trying to
           reproduce the issue 0-day reported it was observed that the guest was
           scheduled out long enough under heavy load that it terminated after 8
           iterations.
      
           Make the loop terminate after 512 iterations. That's plenty enough
           in any case and does not take endless time to complete.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20190722105219.158847694@linutronix.deSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      d29c7b8b
    • Juri Lelli's avatar
      sched/core: Fix CPU controller for !RT_GROUP_SCHED · f381d3d2
      Juri Lelli authored
      [ Upstream commit a07db5c0 ]
      
      On !CONFIG_RT_GROUP_SCHED configurations it is currently not possible to
      move RT tasks between cgroups to which CPU controller has been attached;
      but it is oddly possible to first move tasks around and then make them
      RT (setschedule to FIFO/RR).
      
      E.g.:
      
        # mkdir /sys/fs/cgroup/cpu,cpuacct/group1
        # chrt -fp 10 $$
        # echo $$ > /sys/fs/cgroup/cpu,cpuacct/group1/tasks
        bash: echo: write error: Invalid argument
        # chrt -op 0 $$
        # echo $$ > /sys/fs/cgroup/cpu,cpuacct/group1/tasks
        # chrt -fp 10 $$
        # cat /sys/fs/cgroup/cpu,cpuacct/group1/tasks
        2345
        2598
        # chrt -p 2345
        pid 2345's current scheduling policy: SCHED_FIFO
        pid 2345's current scheduling priority: 10
      
      Also, as Michal noted, it is currently not possible to enable CPU
      controller on unified hierarchy with !CONFIG_RT_GROUP_SCHED (if there
      are any kernel RT threads in root cgroup, they can't be migrated to the
      newly created CPU controller's root in cgroup_update_dfl_csses()).
      
      Existing code comes with a comment saying the "we don't support RT-tasks
      being in separate groups". Such comment is however stale and belongs to
      pre-RT_GROUP_SCHED times. Also, it doesn't make much sense for
      !RT_GROUP_ SCHED configurations, since checks related to RT bandwidth
      are not performed at all in these cases.
      
      Make moving RT tasks between CPU controller groups viable by removing
      special case check for RT (and DEADLINE) tasks.
      Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarMichal Koutný <mkoutny@suse.com>
      Reviewed-by: default avatarDaniel Bristot de Oliveira <bristot@redhat.com>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: lizefan@huawei.com
      Cc: longman@redhat.com
      Cc: luca.abeni@santannapisa.it
      Cc: rostedt@goodmis.org
      Link: https://lkml.kernel.org/r/20190719063455.27328-1-juri.lelli@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f381d3d2
    • Vincent Guittot's avatar
      sched/fair: Fix imbalance due to CPU affinity · 417cf53b
      Vincent Guittot authored
      [ Upstream commit f6cad8df ]
      
      The load_balance() has a dedicated mecanism to detect when an imbalance
      is due to CPU affinity and must be handled at parent level. In this case,
      the imbalance field of the parent's sched_group is set.
      
      The description of sg_imbalanced() gives a typical example of two groups
      of 4 CPUs each and 4 tasks each with a cpumask covering 1 CPU of the first
      group and 3 CPUs of the second group. Something like:
      
      	{ 0 1 2 3 } { 4 5 6 7 }
      	        *     * * *
      
      But the load_balance fails to fix this UC on my octo cores system
      made of 2 clusters of quad cores.
      
      Whereas the load_balance is able to detect that the imbalanced is due to
      CPU affinity, it fails to fix it because the imbalance field is cleared
      before letting parent level a chance to run. In fact, when the imbalance is
      detected, the load_balance reruns without the CPU with pinned tasks. But
      there is no other running tasks in the situation described above and
      everything looks balanced this time so the imbalance field is immediately
      cleared.
      
      The imbalance field should not be cleared if there is no other task to move
      when the imbalance is detected.
      Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/1561996022-28829-1-git-send-email-vincent.guittot@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      417cf53b
    • Paul E. McKenney's avatar
      time/tick-broadcast: Fix tick_broadcast_offline() lockdep complaint · 7cebdfa6
      Paul E. McKenney authored
      [ Upstream commit 84ec3a07 ]
      
      time/tick-broadcast: Fix tick_broadcast_offline() lockdep complaint
      
      The TASKS03 and TREE04 rcutorture scenarios produce the following
      lockdep complaint:
      
      	WARNING: inconsistent lock state
      	5.2.0-rc1+ #513 Not tainted
      	--------------------------------
      	inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
      	migration/1/14 [HC0[0]:SC0[0]:HE1:SE1] takes:
      	(____ptrval____) (tick_broadcast_lock){?...}, at: tick_broadcast_offline+0xf/0x70
      	{IN-HARDIRQ-W} state was registered at:
      	  lock_acquire+0xb0/0x1c0
      	  _raw_spin_lock_irqsave+0x3c/0x50
      	  tick_broadcast_switch_to_oneshot+0xd/0x40
      	  tick_switch_to_oneshot+0x4f/0xd0
      	  hrtimer_run_queues+0xf3/0x130
      	  run_local_timers+0x1c/0x50
      	  update_process_times+0x1c/0x50
      	  tick_periodic+0x26/0xc0
      	  tick_handle_periodic+0x1a/0x60
      	  smp_apic_timer_interrupt+0x80/0x2a0
      	  apic_timer_interrupt+0xf/0x20
      	  _raw_spin_unlock_irqrestore+0x4e/0x60
      	  rcu_nocb_gp_kthread+0x15d/0x590
      	  kthread+0xf3/0x130
      	  ret_from_fork+0x3a/0x50
      	irq event stamp: 171
      	hardirqs last  enabled at (171): [<ffffffff8a201a37>] trace_hardirqs_on_thunk+0x1a/0x1c
      	hardirqs last disabled at (170): [<ffffffff8a201a53>] trace_hardirqs_off_thunk+0x1a/0x1c
      	softirqs last  enabled at (0): [<ffffffff8a264ee0>] copy_process.part.56+0x650/0x1cb0
      	softirqs last disabled at (0): [<0000000000000000>] 0x0
      
              [...]
      
      To reproduce, run the following rcutorture test:
      
       $ tools/testing/selftests/rcutorture/bin/kvm.sh --duration 5 --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" --configs "TASKS03 TREE04"
      
      It turns out that tick_broadcast_offline() was an innocent bystander.
      After all, interrupts are supposed to be disabled throughout
      take_cpu_down(), and therefore should have been disabled upon entry to
      tick_offline_cpu() and thus to tick_broadcast_offline().  This suggests
      that one of the CPU-hotplug notifiers was incorrectly enabling interrupts,
      and leaving them enabled on return.
      
      Some debugging code showed that the culprit was sched_cpu_dying().
      It had irqs enabled after return from sched_tick_stop().  Which in turn
      had irqs enabled after return from cancel_delayed_work_sync().  Which is a
      wrapper around __cancel_work_timer().  Which can sleep in the case where
      something else is concurrently trying to cancel the same delayed work,
      and as Thomas Gleixner pointed out on IRC, sleeping is a decidedly bad
      idea when you are invoked from take_cpu_down(), regardless of the state
      you leave interrupts in upon return.
      
      Code inspection located no reason why the delayed work absolutely
      needed to be canceled from sched_tick_stop():  The work is not
      bound to the outgoing CPU by design, given that the whole point is
      to collect statistics without disturbing the outgoing CPU.
      
      This commit therefore simply drops the cancel_delayed_work_sync() from
      sched_tick_stop().  Instead, a new ->state field is added to the tick_work
      structure so that the delayed-work handler function sched_tick_remote()
      can avoid reposting itself.  A cpu_is_offline() check is also added to
      sched_tick_remote() to avoid mucking with the state of an offlined CPU
      (though it does appear safe to do so).  The sched_tick_start() and
      sched_tick_stop() functions also update ->state, and sched_tick_start()
      also schedules the delayed work if ->state indicates that it is not
      already in flight.
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      [ paulmck: Apply Peter Zijlstra and Frederic Weisbecker atomics feedback. ]
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190625165238.GJ26519@linux.ibm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7cebdfa6
    • Fabio Estevam's avatar
      media: i2c: ov5640: Check for devm_gpiod_get_optional() error · 64f3fb5d
      Fabio Estevam authored
      [ Upstream commit 8791a102 ]
      
      The power down and reset GPIO are optional, but the return value
      from devm_gpiod_get_optional() needs to be checked and propagated
      in the case of error, so that probe deferral can work.
      Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64f3fb5d
    • Luke Nowakowski-Krijger's avatar
      media: hdpvr: Add device num check and handling · 6cc816dd
      Luke Nowakowski-Krijger authored
      [ Upstream commit d4a6a953 ]
      
      Add hdpvr device num check and error handling
      
      We need to increment the device count atomically before we checkout a
      device to make sure that we do not reach the max count, otherwise we get
      out-of-bounds errors as reported by syzbot.
      
      Reported-and-tested-by: syzbot+aac8d0d7205f112045d2@syzkaller.appspotmail.com
      Signed-off-by: default avatarLuke Nowakowski-Krijger <lnowakow@eng.ucsd.edu>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6cc816dd
    • Wen Yang's avatar
      media: exynos4-is: fix leaked of_node references · 8bc254d3
      Wen Yang authored
      [ Upstream commit da79bf41 ]
      
      The call to of_get_child_by_name returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      drivers/media/platform/exynos4-is/fimc-is.c:813:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 807, but without a corresponding object release within this function.
      drivers/media/platform/exynos4-is/fimc-is.c:870:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 807, but without a corresponding object release within this function.
      drivers/media/platform/exynos4-is/fimc-is.c:885:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 807, but without a corresponding object release within this function.
      drivers/media/platform/exynos4-is/media-dev.c:545:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 541, but without a corresponding object release within this function.
      drivers/media/platform/exynos4-is/media-dev.c:528:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 499, but without a corresponding object release within this function.
      drivers/media/platform/exynos4-is/media-dev.c:534:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 499, but without a corresponding object release within this function.
      Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8bc254d3
    • Sean Young's avatar
      media: mtk-cir: lower de-glitch counter for rc-mm protocol · 7ec72076
      Sean Young authored
      [ Upstream commit 5dd4b89d ]
      
      The rc-mm protocol can't be decoded by the mtk-cir since the de-glitch
      filter removes pulses/spaces shorter than 294 microseconds.
      
      Tested on a BananaPi R2.
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Acked-by: default avatarSean Wang <sean.wang@kernel.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ec72076
    • Arnd Bergmann's avatar
      media: dib0700: fix link error for dibx000_i2c_set_speed · 920acbff
      Arnd Bergmann authored
      [ Upstream commit 765bb861 ]
      
      When CONFIG_DVB_DIB9000 is disabled, we can still compile code that
      now fails to link against dibx000_i2c_set_speed:
      
      drivers/media/usb/dvb-usb/dib0700_devices.o: In function `dib01x0_pmu_update.constprop.7':
      dib0700_devices.c:(.text.unlikely+0x1c9c): undefined reference to `dibx000_i2c_set_speed'
      
      The call sites are both through dib01x0_pmu_update(), which gets passed
      an 'i2c' pointer from dib9000_get_i2c_master(), which has returned
      NULL. Checking this pointer seems to be a good idea anyway, and it avoids
      the link failure in most cases.
      
      Sean Young found another case that is not fixed by that, where certain
      gcc versions leave an unused function in place that causes the link error,
      but adding an explict IS_ENABLED() check also solves this.
      
      Fixes: b7f54910 ("V4L/DVB (4647): Added module for DiB0700 based devices")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      920acbff