1. 31 Dec, 2019 40 commits
    • Lingling Xu's avatar
      spi: sprd: adi: Add missing lock protection when rebooting · 3e3378f6
      Lingling Xu authored
      [ Upstream commit 91ea1d70 ]
      
      When rebooting the system, we should lock the watchdog after
      configuration to make sure the watchdog can reboot the system
      successfully.
      Signed-off-by: default avatarLingling Xu <ling_ling.xu@unisoc.com>
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
      Link: https://lore.kernel.org/r/7b04711127434555e3a1a86bc6be99860cd86668.1572257085.git.baolin.wang@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e3378f6
    • Thierry Reding's avatar
      drm/tegra: sor: Use correct SOR index on Tegra210 · 16015bd9
      Thierry Reding authored
      [ Upstream commit 24e64f86 ]
      
      The device tree bindings for the Tegra210 SOR don't require the
      controller instance to be defined, since the instance can be derived
      from the compatible string. The index is never used on Tegra210, so we
      got away with it not getting set. However, subsequent patches will
      change that, so make sure the proper index is used.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      16015bd9
    • Grygorii Strashko's avatar
      net: phy: dp83867: enable robust auto-mdix · 3d097861
      Grygorii Strashko authored
      [ Upstream commit 5a7f08c2 ]
      
      The link detection timeouts can be observed (or link might not be detected
      at all) when dp83867 PHY is configured in manual mode (speed/duplex).
      
      CFG3[9] Robust Auto-MDIX option allows to significantly improve link detection
      in case dp83867 is configured in manual mode and reduce link detection
      time.
      As per DM: "If link partners are configured to operational modes that are
      not supported by normal Auto MDI/MDIX mode (like Auto-Neg versus Force
      100Base-TX or Force 100Base-TX versus Force 100Base-TX), this Robust Auto
      MDI/MDIX mode allows MDI/MDIX resolution and prevents deadlock."
      
      Hence, enable this option by default as there are no known reasons
      not to do so.
      Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d097861
    • Nicholas Nunley's avatar
      i40e: initialize ITRN registers with correct values · b3e2e106
      Nicholas Nunley authored
      [ Upstream commit 998e5166 ]
      
      Since commit 92418fb1 ("i40e/i40evf: Use usec value instead of reg
      value for ITR defines") the driver tracks the interrupt throttling
      intervals in single usec units, although the actual ITRN/ITR0 registers are
      programmed in 2 usec units. Most register programming flows in the driver
      correctly handle the conversion, although it is currently not applied when
      the registers are initialized to their default values. Most of the time
      this doesn't present a problem since the default values are usually
      immediately overwritten through the standard adaptive throttling mechanism,
      or updated manually by the user, but if adaptive throttling is disabled and
      the interval values are left alone then the incorrect value will persist.
      
      Since the intended default interval of 50 usecs (vs. 100 usecs as
      programmed) performs better for most traffic workloads, this can lead to
      performance regressions.
      
      This patch adds the correct conversion when writing the initial values to
      the ITRN registers.
      Signed-off-by: default avatarNicholas Nunley <nicholas.d.nunley@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b3e2e106
    • Yunfeng Ye's avatar
      arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() · 3bb8863b
      Yunfeng Ye authored
      [ Upstream commit bfcef4ab ]
      
      In cases like suspend-to-disk and suspend-to-ram, a large number of CPU
      cores need to be shut down. At present, the CPU hotplug operation is
      serialised, and the CPU cores can only be shut down one by one. In this
      process, if PSCI affinity_info() does not return LEVEL_OFF quickly,
      cpu_psci_cpu_kill() needs to wait for 10ms. If hundreds of CPU cores
      need to be shut down, it will take a long time.
      
      Normally, there is no need to wait 10ms in cpu_psci_cpu_kill(). So
      change the wait interval from 10 ms to max 1 ms and use usleep_range()
      instead of msleep() for more accurate timer.
      
      In addition, reducing the time interval will increase the messages
      output, so remove the "Retry ..." message, instead, track time and
      output to the the sucessful message.
      Signed-off-by: default avatarYunfeng Ye <yeyunfeng@huawei.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3bb8863b
    • Guoqing Jiang's avatar
      md/bitmap: avoid race window between md_bitmap_resize and bitmap_file_clear_bit · 5d8a64e6
      Guoqing Jiang authored
      [ Upstream commit fadcbd29 ]
      
      We need to move "spin_lock_irq(&bitmap->counts.lock)" before unmap previous
      storage, otherwise panic like belows could happen as follows.
      
      [  902.353802] sdl: detected capacity change from 1077936128 to 3221225472
      [  902.616948] general protection fault: 0000 [#1] SMP
      [snip]
      [  902.618588] CPU: 12 PID: 33698 Comm: md0_raid1 Tainted: G           O    4.14.144-1-pserver #4.14.144-1.1~deb10
      [  902.618870] Hardware name: Supermicro SBA-7142G-T4/BHQGE, BIOS 3.00       10/24/2012
      [  902.619120] task: ffff9ae1860fc600 task.stack: ffffb52e4c704000
      [  902.619301] RIP: 0010:bitmap_file_clear_bit+0x90/0xd0 [md_mod]
      [  902.619464] RSP: 0018:ffffb52e4c707d28 EFLAGS: 00010087
      [  902.619626] RAX: ffe8008b0d061000 RBX: ffff9ad078c87300 RCX: 0000000000000000
      [  902.619792] RDX: ffff9ad986341868 RSI: 0000000000000803 RDI: ffff9ad078c87300
      [  902.619986] RBP: ffff9ad0ed7a8000 R08: 0000000000000000 R09: 0000000000000000
      [  902.620154] R10: ffffb52e4c707ec0 R11: ffff9ad987d1ed44 R12: ffff9ad0ed7a8360
      [  902.620320] R13: 0000000000000003 R14: 0000000000060000 R15: 0000000000000800
      [  902.620487] FS:  0000000000000000(0000) GS:ffff9ad987d00000(0000) knlGS:0000000000000000
      [  902.620738] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  902.620901] CR2: 000055ff12aecec0 CR3: 0000001005207000 CR4: 00000000000406e0
      [  902.621068] Call Trace:
      [  902.621256]  bitmap_daemon_work+0x2dd/0x360 [md_mod]
      [  902.621429]  ? find_pers+0x70/0x70 [md_mod]
      [  902.621597]  md_check_recovery+0x51/0x540 [md_mod]
      [  902.621762]  raid1d+0x5c/0xeb0 [raid1]
      [  902.621939]  ? try_to_del_timer_sync+0x4d/0x80
      [  902.622102]  ? del_timer_sync+0x35/0x40
      [  902.622265]  ? schedule_timeout+0x177/0x360
      [  902.622453]  ? call_timer_fn+0x130/0x130
      [  902.622623]  ? find_pers+0x70/0x70 [md_mod]
      [  902.622794]  ? md_thread+0x94/0x150 [md_mod]
      [  902.622959]  md_thread+0x94/0x150 [md_mod]
      [  902.623121]  ? wait_woken+0x80/0x80
      [  902.623280]  kthread+0x119/0x130
      [  902.623437]  ? kthread_create_on_node+0x60/0x60
      [  902.623600]  ret_from_fork+0x22/0x40
      [  902.624225] RIP: bitmap_file_clear_bit+0x90/0xd0 [md_mod] RSP: ffffb52e4c707d28
      
      Because mdadm was running on another cpu to do resize, so bitmap_resize was
      called to replace bitmap as below shows.
      
      PID: 38801  TASK: ffff9ad074a90e00  CPU: 0   COMMAND: "mdadm"
         [exception RIP: queued_spin_lock_slowpath+56]
         [snip]
      -- <NMI exception stack> --
       #5 [ffffb52e60f17c58] queued_spin_lock_slowpath at ffffffff9c0b27b8
       #6 [ffffb52e60f17c58] bitmap_resize at ffffffffc0399877 [md_mod]
       #7 [ffffb52e60f17d30] raid1_resize at ffffffffc0285bf9 [raid1]
       #8 [ffffb52e60f17d50] update_size at ffffffffc038a31a [md_mod]
       #9 [ffffb52e60f17d70] md_ioctl at ffffffffc0395ca4 [md_mod]
      
      And the procedure to keep resize bitmap safe is allocate new storage
      space, then quiesce, copy bits, replace bitmap, and re-start.
      
      However the daemon (bitmap_daemon_work) could happen even the array is
      quiesced, which means when bitmap_file_clear_bit is triggered by raid1d,
      then it thinks it should be fine to access store->filemap since
      counts->lock is held, but resize could change the storage without the
      protection of the lock.
      
      Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
      Cc: NeilBrown <neilb@suse.com>
      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>
      5d8a64e6
    • Sakari Ailus's avatar
      media: smiapp: Register sensor after enabling runtime PM on the device · 3e1e7489
      Sakari Ailus authored
      [ Upstream commit 90c9e4a4 ]
      
      Earlier it was possible that the parts of the driver that assumed runtime
      PM was enabled were being called before runtime PM was enabled in the
      driver's probe function. So enable runtime PM before registering the
      sub-device.
      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>
      3e1e7489
    • Thomas Gleixner's avatar
      x86/ioapic: Prevent inconsistent state when moving an interrupt · 00f0f294
      Thomas Gleixner authored
      [ Upstream commit df439342 ]
      
      There is an issue with threaded interrupts which are marked ONESHOT
      and using the fasteoi handler:
      
        if (IS_ONESHOT())
          mask_irq();
        ....
        cond_unmask_eoi_irq()
          chip->irq_eoi();
            if (setaffinity_pending) {
               mask_ioapic();
               ...
      	 move_affinity();
      	 unmask_ioapic();
            }
      
      So if setaffinity is pending the interrupt will be moved and then
      unconditionally unmasked at the ioapic level, which is wrong in two
      aspects:
      
       1) It should be kept masked up to the point where the threaded handler
          finished.
      
       2) The physical chip state and the software masked state are inconsistent
      
      Guard both the mask and the unmask with a check for the software masked
      state. If the line is marked masked then the ioapic line is also masked, so
      both mask_ioapic() and unmask_ioapic() can be skipped safely.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sebastian Siewior <bigeasy@linutronix.de>
      Fixes: 3aa551c9 ("genirq: add threaded interrupt handler support")
      Link: https://lkml.kernel.org/r/20191017101938.321393687@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      00f0f294
    • Corey Minyard's avatar
      ipmi: Don't allow device module unload when in use · f9d405a4
      Corey Minyard authored
      [ Upstream commit cbb79863 ]
      
      If something has the IPMI driver open, don't allow the device
      module to be unloaded.  Before it would unload and the user would
      get errors on use.
      
      This change is made on user request, and it makes it consistent
      with the I2C driver, which has the same behavior.
      
      It does change things a little bit with respect to kernel users.
      If the ACPI or IPMI watchdog (or any other kernel user) has
      created a user, then the device module cannot be unloaded.  Before
      it could be unloaded,
      
      This does not affect hot-plug.  If the device goes away (it's on
      something removable that is removed or is hot-removed via sysfs)
      then it still behaves as it did before.
      Reported-by: default avatartony camuso <tcamuso@redhat.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Tested-by: default avatartony camuso <tcamuso@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9d405a4
    • Chris Chiu's avatar
      rtl8xxxu: fix RTL8723BU connection failure issue after warm reboot · d7607502
      Chris Chiu authored
      [ Upstream commit 0eeb91ad ]
      
      The RTL8723BU has problems connecting to AP after each warm reboot.
      Sometimes it returns no scan result, and in most cases, it fails
      the authentication for unknown reason. However, it works totally
      fine after cold reboot.
      
      Compare the value of register SYS_CR and SYS_CLK_MAC_CLK_ENABLE
      for cold reboot and warm reboot, the registers imply that the MAC
      is already powered and thus some procedures are skipped during
      driver initialization. Double checked the vendor driver, it reads
      the SYS_CR and SYS_CLK_MAC_CLK_ENABLE also but doesn't skip any
      during initialization based on them. This commit only tells the
      RTL8723BU to do full initialization without checking MAC status.
      Signed-off-by: default avatarChris Chiu <chiu@endlessm.com>
      Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7607502
    • Kangjie Lu's avatar
      drm/gma500: fix memory disclosures due to uninitialized bytes · 7a284055
      Kangjie Lu authored
      [ Upstream commit ec3b7b6e ]
      
      "clock" may be copied to "best_clock". Initializing best_clock
      is not sufficient. The fix initializes clock as well to avoid
      memory disclosures and informaiton leaks.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191018044150.1899-1-kjlu@umn.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a284055
    • Leo Yan's avatar
      perf tests: Disable bp_signal testing for arm64 · c761b5ed
      Leo Yan authored
      [ Upstream commit 6a5f3d94 ]
      
      As there are several discussions for enabling perf breakpoint signal
      testing on arm64 platform: arm64 needs to rely on single-step to execute
      the breakpointed instruction and then reinstall the breakpoint exception
      handler.  But if we hook the breakpoint with a signal, the signal
      handler will do the stepping rather than the breakpointed instruction,
      this causes infinite loops as below:
      
               Kernel space              |            Userspace
        ---------------------------------|--------------------------------
                                         |  __test_function() -> hit
      				   |                       breakpoint
        breakpoint_handler()             |
          `-> user_enable_single_step()  |
        do_signal()                      |
                                         |  sig_handler() -> Step one
      				   |                instruction and
      				   |                trap to kernel
        single_step_handler()            |
          `-> reinstall_suspended_bps()  |
                                         |  __test_function() -> hit
      				   |     breakpoint again and
      				   |     repeat up flow infinitely
      
      As Will Deacon mentioned [1]: "that we require the overflow handler to
      do the stepping on arm/arm64, which is relied upon by GDB/ptrace. The
      hw_breakpoint code is a complete disaster so my preference would be to
      rip out the perf part and just implement something directly in ptrace,
      but it's a pretty horrible job".  Though Will commented this on arm
      architecture, but the comment also can apply on arm64 architecture.
      
      For complete information, I searched online and found a few years back,
      Wang Nan sent one patch 'arm64: Store breakpoint single step state into
      pstate' [2]; the patch tried to resolve this issue by avoiding single
      stepping in signal handler and defer to enable the signal stepping when
      return to __test_function().  The fixing was not merged due to the
      concern for missing to handle different usage cases.
      
      Based on the info, the most feasible way is to skip Perf breakpoint
      signal testing for arm64 and this could avoid the duplicate
      investigation efforts when people see the failure.  This patch skips
      this case on arm64 platform, which is same with arm architecture.
      
      [1] https://lkml.org/lkml/2018/11/15/205
      [2] https://lkml.org/lkml/2015/12/23/477Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brajeswar Ghosh <brajeswar.linux@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20191018085531.6348-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c761b5ed
    • Benjamin Berg's avatar
      x86/mce: Lower throttling MCE messages' priority to warning · 8d492e4b
      Benjamin Berg authored
      [ Upstream commit 9c3bafaa ]
      
      On modern CPUs it is quite normal that the temperature limits are
      reached and the CPU is throttled. In fact, often the thermal design is
      not sufficient to cool the CPU at full load and limits can quickly be
      reached when a burst in load happens. This will even happen with
      technologies like RAPL limitting the long term power consumption of
      the package.
      
      Also, these limits are "softer", as Srinivas explains:
      
      "CPU temperature doesn't have to hit max(TjMax) to get these warnings.
      OEMs ha[ve] an ability to program a threshold where a thermal interrupt
      can be generated. In some systems the offset is 20C+ (Read only value).
      
      In recent systems, there is another offset on top of it which can be
      programmed by OS, once some agent can adjust power limits dynamically.
      By default this is set to low by the firmware, which I guess the
      prime motivation of Benjamin to submit the patch."
      
      So these messages do not usually indicate a hardware issue (e.g.
      insufficient cooling). Log them as warnings to avoid confusion about
      their severity.
      
       [ bp: Massage commit mesage. ]
      Signed-off-by: default avatarBenjamin Berg <bberg@redhat.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Tested-by: default avatarChristian Kellner <ckellner@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-edac <linux-edac@vger.kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20191009155424.249277-1-bberg@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d492e4b
    • Song Liu's avatar
      bpf/stackmap: Fix deadlock with rq_lock in bpf_get_stack() · a7f4da87
      Song Liu authored
      [ Upstream commit eac9153f ]
      
      bpf stackmap with build-id lookup (BPF_F_STACK_BUILD_ID) can trigger A-A
      deadlock on rq_lock():
      
      rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
      [...]
      Call Trace:
       try_to_wake_up+0x1ad/0x590
       wake_up_q+0x54/0x80
       rwsem_wake+0x8a/0xb0
       bpf_get_stack+0x13c/0x150
       bpf_prog_fbdaf42eded9fe46_on_event+0x5e3/0x1000
       bpf_overflow_handler+0x60/0x100
       __perf_event_overflow+0x4f/0xf0
       perf_swevent_overflow+0x99/0xc0
       ___perf_sw_event+0xe7/0x120
       __schedule+0x47d/0x620
       schedule+0x29/0x90
       futex_wait_queue_me+0xb9/0x110
       futex_wait+0x139/0x230
       do_futex+0x2ac/0xa50
       __x64_sys_futex+0x13c/0x180
       do_syscall_64+0x42/0x100
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      This can be reproduced by:
      1. Start a multi-thread program that does parallel mmap() and malloc();
      2. taskset the program to 2 CPUs;
      3. Attach bpf program to trace_sched_switch and gather stackmap with
         build-id, e.g. with trace.py from bcc tools:
         trace.py -U -p <pid> -s <some-bin,some-lib> t:sched:sched_switch
      
      A sample reproducer is attached at the end.
      
      This could also trigger deadlock with other locks that are nested with
      rq_lock.
      
      Fix this by checking whether irqs are disabled. Since rq_lock and all
      other nested locks are irq safe, it is safe to do up_read() when irqs are
      not disable. If the irqs are disabled, postpone up_read() in irq_work.
      
      Fixes: 615755a7 ("bpf: extend stackmap to save binary_build_id+offset instead of address")
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20191014171223.357174-1-songliubraving@fb.com
      
      Reproducer:
      ============================ 8< ============================
      
      char *filename;
      
      void *worker(void *p)
      {
              void *ptr;
              int fd;
              char *pptr;
      
              fd = open(filename, O_RDONLY);
              if (fd < 0)
                      return NULL;
              while (1) {
                      struct timespec ts = {0, 1000 + rand() % 2000};
      
                      ptr = mmap(NULL, 4096 * 64, PROT_READ, MAP_PRIVATE, fd, 0);
                      usleep(1);
                      if (ptr == MAP_FAILED) {
                              printf("failed to mmap\n");
                              break;
                      }
                      munmap(ptr, 4096 * 64);
                      usleep(1);
                      pptr = malloc(1);
                      usleep(1);
                      pptr[0] = 1;
                      usleep(1);
                      free(pptr);
                      usleep(1);
                      nanosleep(&ts, NULL);
              }
              close(fd);
              return NULL;
      }
      
      int main(int argc, char *argv[])
      {
              void *ptr;
              int i;
              pthread_t threads[THREAD_COUNT];
      
              if (argc < 2)
                      return 0;
      
              filename = argv[1];
      
              for (i = 0; i < THREAD_COUNT; i++) {
                      if (pthread_create(threads + i, NULL, worker, NULL)) {
                              fprintf(stderr, "Error creating thread\n");
                              return 0;
                      }
              }
      
              for (i = 0; i < THREAD_COUNT; i++)
                      pthread_join(threads[i], NULL);
              return 0;
      }
      ============================ 8< ============================
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a7f4da87
    • Mattijs Korpershoek's avatar
      Bluetooth: hci_core: fix init for HCI_USER_CHANNEL · 512de42e
      Mattijs Korpershoek authored
      [ Upstream commit eb8c101e ]
      
      During the setup() stage, HCI device drivers expect the chip to
      acknowledge its setup() completion via vendor specific frames.
      
      If userspace opens() such HCI device in HCI_USER_CHANNEL [1] mode,
      the vendor specific frames are never tranmitted to the driver, as
      they are filtered in hci_rx_work().
      
      Allow HCI devices which operate in HCI_USER_CHANNEL mode to receive
      frames if the HCI device is is HCI_INIT state.
      
      [1] https://www.spinics.net/lists/linux-bluetooth/msg37345.html
      
      Fixes: 23500189 ("Bluetooth: Introduce new HCI socket channel for user operation")
      Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      512de42e
    • Szymon Janc's avatar
      Bluetooth: Workaround directed advertising bug in Broadcom controllers · 71aaa813
      Szymon Janc authored
      [ Upstream commit 4c371bb9 ]
      
      It appears that some Broadcom controllers (eg BCM20702A0) reject LE Set
      Advertising Parameters command if advertising intervals provided are not
      within range for undirected and low duty directed advertising.
      
      Workaround this bug by populating min and max intervals with 'valid'
      values.
      
      < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15
              Min advertising interval: 0.000 msec (0x0000)
              Max advertising interval: 0.000 msec (0x0000)
              Type: Connectable directed - ADV_DIRECT_IND (high duty cycle) (0x01)
              Own address type: Public (0x00)
              Direct address type: Random (0x01)
              Direct address: E2:F0:7B:9F:DC:F4 (Static)
              Channel map: 37, 38, 39 (0x07)
              Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Advertising Parameters (0x08|0x0006) ncmd 1
              Status: Invalid HCI Command Parameters (0x12)
      Signed-off-by: default avatarSzymon Janc <szymon.janc@codecoup.pl>
      Tested-by: default avatarSören Beye <linux@hypfer.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      71aaa813
    • Ben Dooks (Codethink)'s avatar
      Bluetooth: missed cpu_to_le16 conversion in hci_init4_req · 8829e883
      Ben Dooks (Codethink) authored
      [ Upstream commit 727ea61a ]
      
      It looks like in hci_init4_req() the request is being
      initialised from cpu-endian data but the packet is specified
      to be little-endian. This causes an warning from sparse due
      to __le16 to u16 conversion.
      
      Fix this by using cpu_to_le16() on the two fields in the packet.
      
      net/bluetooth/hci_core.c:845:27: warning: incorrect type in assignment (different base types)
      net/bluetooth/hci_core.c:845:27:    expected restricted __le16 [usertype] tx_len
      net/bluetooth/hci_core.c:845:27:    got unsigned short [usertype] le_max_tx_len
      net/bluetooth/hci_core.c:846:28: warning: incorrect type in assignment (different base types)
      net/bluetooth/hci_core.c:846:28:    expected restricted __le16 [usertype] tx_time
      net/bluetooth/hci_core.c:846:28:    got unsigned short [usertype] le_max_tx_time
      Signed-off-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8829e883
    • Miquel Raynal's avatar
      iio: adc: max1027: Reset the device at probe time · eec8f08d
      Miquel Raynal authored
      [ Upstream commit db033831 ]
      
      All the registers are configured by the driver, let's reset the chip
      at probe time, avoiding any conflict with a possible earlier
      configuration.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eec8f08d
    • Ingo Rohloff's avatar
      usb: usbfs: Suppress problematic bind and unbind uevents. · cba64672
      Ingo Rohloff authored
      [ Upstream commit abb0b3d9 ]
      
      commit 1455cf8d ("driver core: emit uevents when device is bound
      to a driver") added bind and unbind uevents when a driver is bound or
      unbound to a physical device.
      
      For USB devices which are handled via the generic usbfs layer (via
      libusb for example), this is problematic:
      Each time a user space program calls
         ioctl(usb_fd, USBDEVFS_CLAIMINTERFACE, &usb_intf_nr);
      and then later
         ioctl(usb_fd, USBDEVFS_RELEASEINTERFACE, &usb_intf_nr);
      The kernel will now produce a bind or unbind event, which does not
      really contain any useful information.
      
      This allows a user space program to run a DoS attack against programs
      which listen to uevents (in particular systemd/eudev/upowerd):
      A malicious user space program just has to call in a tight loop
      
         ioctl(usb_fd, USBDEVFS_CLAIMINTERFACE, &usb_intf_nr);
         ioctl(usb_fd, USBDEVFS_RELEASEINTERFACE, &usb_intf_nr);
      
      With this loop the malicious user space program floods the kernel and
      all programs listening to uevents with tons of bind and unbind
      events.
      
      This patch suppresses uevents for ioctls USBDEVFS_CLAIMINTERFACE and
      USBDEVFS_RELEASEINTERFACE.
      Signed-off-by: default avatarIngo Rohloff <ingo.rohloff@lauterbach.com>
      Link: https://lore.kernel.org/r/20191011115518.2801-1-ingo.rohloff@lauterbach.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cba64672
    • Jin Yao's avatar
      perf report: Add warning when libunwind not compiled in · 888d90b3
      Jin Yao authored
      [ Upstream commit 800d3f56 ]
      
      We received a user report that call-graph DWARF mode was enabled in
      'perf record' but 'perf report' didn't unwind the callstack correctly.
      The reason was, libunwind was not compiled in.
      
      We can use 'perf -vv' to check the compiled libraries but it would be
      valuable to report a warning to user directly (especially valuable for
      a perf newbie).
      
      The warning is:
      
      Warning:
      Please install libunwind development packages during the perf build.
      
      Both TUI and stdio are supported.
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191011022122.26369-1-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      888d90b3
    • Leo Yan's avatar
      perf test: Report failure for mmap events · 24c0a10b
      Leo Yan authored
      [ Upstream commit 6add129c ]
      
      When fail to mmap events in task exit case, it misses to set 'err' to
      -1; thus the testing will not report failure for it.
      
      This patch sets 'err' to -1 when fails to mmap events, thus Perf tool
      can report correct result.
      
      Fixes: d723a550 ("perf test: Add test case for checking number of EXIT events")
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20191011091942.29841-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      24c0a10b
    • Daniel Kurtz's avatar
      drm/bridge: dw-hdmi: Restore audio when setting a mode · 327e4160
      Daniel Kurtz authored
      [ Upstream commit fadfee3f ]
      
      When setting a new display mode, dw_hdmi_setup() calls
      dw_hdmi_enable_video_path(), which disables all hdmi clocks, including
      the audio clock.
      
      We should only (re-)enable the audio clock if audio was already enabled
      when setting the new mode.
      
      Without this patch, on RK3288, there will be HDMI audio on some monitors
      if i2s was played to headphone when the monitor was plugged.
      ACER H277HU and ASUS PB278 are two of the monitors showing this issue.
      Signed-off-by: default avatarCheng-Yi Chiang <cychiang@chromium.org>
      Signed-off-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
      Signed-off-by: default avatarYakir Yang <ykk@rock-chips.com>
      Reviewed-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191008102145.55134-1-cychiang@chromium.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      327e4160
    • Bjorn Andersson's avatar
      ath10k: Correct error handling of dma_map_single() · cdaf0577
      Bjorn Andersson authored
      [ Upstream commit d43810b2 ]
      
      The return value of dma_map_single() should be checked for errors using
      dma_mapping_error() and the skb has been dequeued so it needs to be
      freed.
      
      This was found when enabling CONFIG_DMA_API_DEBUG and it warned about the
      missing dma_mapping_error() call.
      
      Fixes: 1807da49 ("ath10k: wmi: add management tx by reference support over wmi")
      Reported-by: default avatarNiklas Cassel <niklas.cassel@linaro.org>
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cdaf0577
    • Sami Tolvanen's avatar
      x86/mm: Use the correct function type for native_set_fixmap() · 81c3dc63
      Sami Tolvanen authored
      [ Upstream commit f53e2cd0 ]
      
      We call native_set_fixmap indirectly through the function pointer
      struct pv_mmu_ops::set_fixmap, which expects the first parameter to be
      'unsigned' instead of 'enum fixed_addresses'. This patch changes the
      function type for native_set_fixmap to match the pointer, which fixes
      indirect call mismatches with Control-Flow Integrity (CFI) checking.
      Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H . Peter Anvin <hpa@zytor.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190913211402.193018-1-samitolvanen@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81c3dc63
    • Stephan Gerhold's avatar
      extcon: sm5502: Reset registers during initialization · 45a6c3fb
      Stephan Gerhold authored
      [ Upstream commit 69426350 ]
      
      On some devices (e.g. Samsung Galaxy A5 (2015)), the bootloader
      seems to keep interrupts enabled for SM5502 when booting Linux.
      Changing the cable state (i.e. plugging in a cable) - until the driver
      is loaded - will therefore produce an interrupt that is never read.
      
      In this situation, the cable state will be stuck forever on the
      initial state because SM5502 stops sending interrupts.
      This can be avoided by clearing those pending interrupts after
      the driver has been loaded.
      
      One way to do this is to reset all registers to default state
      by writing to SM5502_REG_RESET. This ensures that we start from
      a clean state, with all interrupts disabled.
      Suggested-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45a6c3fb
    • David Galiffi's avatar
      drm/amd/display: Fix dongle_caps containing stale information. · 59fc1675
      David Galiffi authored
      [ Upstream commit dd998291 ]
      
      [WHY]
      
      During detection:
      function: get_active_converter_info populates link->dpcd_caps.dongle_caps
      only when dpcd_rev >= DPCD_REV_11 and DWN_STRM_PORTX_TYPE is
      DOWN_STREAM_DETAILED_HDMI or DOWN_STREAM_DETAILED_DP_PLUS_PLUS.
      Otherwise, it is not cleared, and stale information remains.
      
      During mode validation:
      function: dp_active_dongle_validate_timing reads
      link->dpcd_caps.dongle_caps->dongle_type to determine the maximum
      pixel clock to support. This information is now stale and no longer
      valid.
      
      [HOW]
      dp_active_dongle_validate_timing should be using
      link->dpcd_caps->dongle_type instead.
      Signed-off-by: default avatarDavid Galiffi <david.galiffi@amd.com>
      Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
      Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      59fc1675
    • Sami Tolvanen's avatar
      syscalls/x86: Use the correct function type in SYSCALL_DEFINE0 · 0aeb6588
      Sami Tolvanen authored
      [ Upstream commit 8661d769 ]
      
      Although a syscall defined using SYSCALL_DEFINE0 doesn't accept
      parameters, use the correct function type to avoid type mismatches
      with Control-Flow Integrity (CFI) checking.
      Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H . Peter Anvin <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.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/20191008224049.115427-2-samitolvanen@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0aeb6588
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance failure about invalid sizeimage · fa03f6cc
      Benoit Parrot authored
      [ Upstream commit 0bac73ad ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-formats.cpp(463): !pfmt.sizeimage
         fail: v4l2-test-formats.cpp(736): \
      	Video Capture Multiplanar is valid, \
      	but TRY_FMT failed to return a format
         test VIDIOC_TRY_FMT: FAIL
      
      This failure is causd by the driver failing to handle out range
      'bytesperline' values from user space applications.
      
      VPDMA hardware is limited to 64k line stride (16 bytes aligned, so 65520
      bytes). So make sure the provided or calculated 'bytesperline' is
      smaller than the maximum value.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      fa03f6cc
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: ensure buffers are cleaned up properly in abort cases · 653e40fd
      Benoit Parrot authored
      [ Upstream commit cf6acb73 ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-buffers.cpp(691): ret == 0
         fail: v4l2-test-buffers.cpp(974): captureBufs(node, q, m2m_q,
      frame_count, true)
         test MMAP: FAIL
      
      This caused the following Kernel Warning:
      
      WARNING: CPU: 0 PID: 961 at
      drivers/media/v4l2-core/videobuf2-core.c:1658
      __vb2_queue_cancel+0x174/0x1d8
      ...
      CPU: 0 PID: 961 Comm: v4l2-compliance Not tainted
      4.14.62-01720-g20ecd717e87a #6
      Hardware name: Generic DRA72X (Flattened Device Tree)
      Backtrace:
      [<c020b5bc>] (dump_backtrace) from [<c020b8a0>] (show_stack+0x18/0x1c)
       r7:00000009 r6:60070013 r5:00000000 r4:c1053824
      [<c020b888>] (show_stack) from [<c09232e8>] (dump_stack+0x90/0xa4)
      [<c0923258>] (dump_stack) from [<c022b740>] (__warn+0xec/0x104)
        r7:00000009 r6:c0c0ad50 r5:00000000 r4:00000000
      [<c022b654>] (__warn) from [<c022b810>] (warn_slowpath_null+0x28/0x30)
        r9:00000008 r8:00000000 r7:eced4808 r6:edbc9bac r5:eced4844
      r4:eced4808
      [<c022b7e8>] (warn_slowpath_null) from [<c0726f48>]
      (__vb2_queue_cancel+0x174/0x1d8)
      [<c0726dd4>] (__vb2_queue_cancel) from [<c0727648>]
      (vb2_core_queue_release+0x20/0x40)
        r10:ecc7bd70 r9:00000008 r8:00000000 r7:edb73010 r6:edbc9bac
      r5:eced4844
        r4:eced4808 r3:00000004
      [<c0727628>] (vb2_core_queue_release) from [<c0729528>]
      (vb2_queue_release+0x10/0x14)
        r5:edbc9810 r4:eced4800
      [<c0729518>] (vb2_queue_release) from [<c0724d08>]
      (v4l2_m2m_ctx_release+0x1c/0x30)
      [<c0724cec>] (v4l2_m2m_ctx_release) from [<bf0e8f28>]
      (vpe_release+0x74/0xb0 [ti_vpe])
        r5:edbc9810 r4:ed67a400
      [<bf0e8eb4>] (vpe_release [ti_vpe]) from [<c070fccc>]
      (v4l2_release+0x3c/0x80)
        r7:edb73010 r6:ed176aa0 r5:edbc9868 r4:ed5119c0
      [<c070fc90>] (v4l2_release) from [<c033cf1c>] (__fput+0x8c/0x1dc)
        r5:ecc7bd70 r4:ed5119c0
      [<c033ce90>] (__fput) from [<c033d0cc>] (____fput+0x10/0x14)
        r10:00000000 r9:ed5119c0 r8:ece392d0 r7:c1059544 r6:ece38d80
      r5:ece392b4
        r4:00000000
      [<c033d0bc>] (____fput) from [<c0246e00>] (task_work_run+0x98/0xb8)
      [<c0246d68>] (task_work_run) from [<c022f1d8>] (do_exit+0x170/0xa80)
        r9:ece351fc r8:00000000 r7:ecde3f58 r6:ffffe000 r5:ece351c0
      r4:ece38d80
      [<c022f068>] (do_exit) from [<c022fb6c>] (do_group_exit+0x48/0xc4)
        r7:000000f8
      [<c022fb24>] (do_group_exit) from [<c022fc00>]
      (__wake_up_parent+0x0/0x28)
        r7:000000f8 r6:b6c6a798 r5:00000001 r4:00000001
      [<c022fbe8>] (SyS_exit_group) from [<c0207c80>]
      (ret_fast_syscall+0x0/0x4c)
      
      These warnings are caused by buffers which not properly cleaned
      up/release during an abort use case.
      
      In the abort cases the VPDMA desc buffers would still be mapped and the
      in-flight VB2 buffers would not be released properly causing a kernel
      warning from being generated by the videobuf2-core level.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      653e40fd
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance failure causing a kernel panic · 030a5be2
      Benoit Parrot authored
      [ Upstream commit a37980ac ]
      
      v4l2-compliance fails with this message:
      
         warn: v4l2-test-formats.cpp(717): \
         	TRY_FMT cannot handle an invalid pixelformat.
         test VIDIOC_TRY_FMT: FAIL
      
      This causes the following kernel panic:
      
      Unable to handle kernel paging request at virtual address 56595561
      pgd = ecd80e00
      *pgd=00000000
      Internal error: Oops: 205 [#1] PREEMPT SMP ARM
      ...
      CPU: 0 PID: 930 Comm: v4l2-compliance Not tainted \
      	4.14.62-01715-gc8cd67f49a19 #1
      Hardware name: Generic DRA72X (Flattened Device Tree)
      task: ece44d80 task.stack: ecc6e000
      PC is at __vpe_try_fmt+0x18c/0x2a8 [ti_vpe]
      LR is at 0x8
      
      Because the driver fails to properly check the 'num_planes' values for
      proper ranges it ends up accessing out of bound data causing the kernel
      panic.
      
      Since this driver only handle single or dual plane pixel format, make
      sure the provided value does not exceed 2 planes.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      030a5be2
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: Make sure YUYV is set as default format · dc5c8d1b
      Benoit Parrot authored
      [ Upstream commit e20b2480 ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-formats.cpp(672): \
      	Video Capture Multiplanar: TRY_FMT(G_FMT) != G_FMT
         fail: v4l2-test-formats.cpp(672): \
      	Video Output Multiplanar: TRY_FMT(G_FMT) != G_FMT
      	...
         test VIDIOC_TRY_FMT: FAIL
      
      The default pixel format was setup as pointing to a specific offset in
      the vpe_formats table assuming it was pointing to the V4L2_PIX_FMT_YUYV
      entry. This became false after the addition on the NV21 format (see
      above commid-id)
      
      So instead of hard-coding an offset which might change over time we need
      to use a lookup helper instead so we know the default will always be what
      we intended.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Fixes: 40cc823f7005 ("media: ti-vpe: Add support for NV21 format")
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      dc5c8d1b
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance failure about frame sequence number · 8155d363
      Benoit Parrot authored
      [ Upstream commit 2444846c ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-buffers.cpp(294): \
      	(int)g_sequence() < seq.last_seq + 1
         fail: v4l2-test-buffers.cpp(740): \
      	buf.check(m2m_q, last_m2m_seq)
         fail: v4l2-test-buffers.cpp(974): \
      	captureBufs(node, q, m2m_q, frame_count, true)
         test MMAP: FAIL
      
      The driver is failing to update the source frame sequence number in the
      vb2 buffer object. Only the destination frame sequence was being
      updated.
      
      This is only a reporting issue if the user space app actually cares
      about the frame sequence number. But it is fixed nonetheless.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      8155d363
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance warning about invalid pixel format · 5f54465d
      Benoit Parrot authored
      [ Upstream commit 06bec72b ]
      
      v4l2-compliance warns with this message:
      
         warn: v4l2-test-formats.cpp(717): \
       	TRY_FMT cannot handle an invalid pixelformat.
         warn: v4l2-test-formats.cpp(718): \
       	This may or may not be a problem. For more information see:
         warn: v4l2-test-formats.cpp(719): \
       	http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
      	...
         test VIDIOC_TRY_FMT: FAIL
      
      We need to make sure that the returns a valid pixel format in all
      instance. Based on the v4l2 framework convention drivers must return a
      valid pixel format when the requested pixel format is either invalid or
      not supported.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.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>
      5f54465d
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: Fix Motion Vector vpdma stride · 4b358bbb
      Benoit Parrot authored
      [ Upstream commit 102af9b9 ]
      
      commit 3dc2046c ("[media] media: ti-vpe: vpe: allow use of user
      specified stride") and commit da4414ea ("[media] media: ti-vpe: vpdma:
      add support for user specified stride") resulted in the Motion Vector
      stride to be the same as the image stride.
      
      This caused memory corruption in the output image as mentioned in
      commit 00db9699 ("[media] media: ti-vpe: vpe: Fix line stride
      for output motion vector").
      
      Fixes: 3dc2046c ("[media] media: ti-vpe: vpe: allow use of user specified stride")
      Fixes: da4414ea ("[media] media: ti-vpe: vpdma: add support for user specified stride")
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Acked-by: default avatarNikhil Devshatwar <nikhil.nd@ti.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>
      4b358bbb
    • Christophe JAILLET's avatar
      media: cx88: Fix some error handling path in 'cx8800_initdev()' · 3835f929
      Christophe JAILLET authored
      [ Upstream commit e1444e9b ]
      
      A call to 'pci_disable_device()' is missing in the error handling path.
      In some cases, a call to 'free_irq()' may also be missing.
      
      Reorder the error handling path, add some new labels and fix the 2 issues
      mentionned above.
      
      This way, the error handling path in more in line with 'cx8800_finidev()'
      (i.e. the remove function)
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      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>
      3835f929
    • Rodrigo Siqueira's avatar
      drm/drm_vblank: Change EINVAL by the correct errno · 5d60d398
      Rodrigo Siqueira authored
      [ Upstream commit aed6105b ]
      
      For historical reasons, the function drm_wait_vblank_ioctl always return
      -EINVAL if something gets wrong. This scenario limits the flexibility
      for the userspace to make detailed verification of any problem and take
      some action. In particular, the validation of “if (!dev->irq_enabled)”
      in the drm_wait_vblank_ioctl is responsible for checking if the driver
      support vblank or not. If the driver does not support VBlank, the
      function drm_wait_vblank_ioctl returns EINVAL, which does not represent
      the real issue; this patch changes this behavior by return EOPNOTSUPP.
      Additionally, drm_crtc_get_sequence_ioctl and
      drm_crtc_queue_sequence_ioctl, also returns EINVAL if vblank is not
      supported; this patch also changes the return value to EOPNOTSUPP in
      these functions. Lastly, these functions are invoked by libdrm, which is
      used by many compositors; because of this, it is important to check if
      this change breaks any compositor. In this sense, the following projects
      were examined:
      
      * Drm-hwcomposer
      * Kwin
      * Sway
      * Wlroots
      * Wayland
      * Weston
      * Mutter
      * Xorg (67 different drivers)
      
      For each repository the verification happened in three steps:
      
      * Update the main branch
      * Look for any occurrence of "drmCrtcQueueSequence",
        "drmCrtcGetSequence", and "drmWaitVBlank" with the command git grep -n
        "STRING".
      * Look in the git history of the project with the command
      git log -S<STRING>
      
      None of the above projects validate the use of EINVAL when using
      drmWaitVBlank(), which make safe, at least for these projects, to change
      the return values. On the other hand, mesa and xserver project uses
      drmCrtcQueueSequence() and drmCrtcGetSequence(); this change is harmless
      for both projects.
      
      Change since V5 (Pekka Paalanen):
       - Check if the change also affects Mutter
      
      Change since V4 (Daniel):
       - Also return EOPNOTSUPP in drm_crtc_[get|queue]_sequence_ioctl
      
      Change since V3:
       - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel)
      
      Change since V2:
       Daniel Vetter and Chris Wilson
       - Replace ENOTTY by EOPNOTSUPP
       - Return EINVAL if the parameters are wrong
      
      Cc: Keith Packard <keithp@keithp.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
      Signed-off-by: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Acked-by: default avatarPekka Paalanen <pekka.paalanen@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191002140516.adeyj3htylimmlmg@smtp.gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      5d60d398
    • Navid Emamdoost's avatar
      mwifiex: pcie: Fix memory leak in mwifiex_pcie_init_evt_ring · 1b3e52db
      Navid Emamdoost authored
      [ Upstream commit d10dcb61 ]
      
      In mwifiex_pcie_init_evt_ring, a new skb is allocated which should be
      released if mwifiex_map_pci_memory() fails. The release for skb and
      card->evtbd_ring_vbase is added.
      
      Fixes: 0732484b ("mwifiex: separate ring initialization and ring creation routines")
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Acked-by: default avatarGanapathi Bhat <gbhat@marvell.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b3e52db
    • Bart Van Assche's avatar
      block: Fix writeback throttling W=1 compiler warnings · bf495b67
      Bart Van Assche authored
      [ Upstream commit 1d200e9d ]
      
      Fix the following compiler warnings:
      
      In file included from ./include/linux/bitmap.h:9,
                       from ./include/linux/cpumask.h:12,
                       from ./arch/x86/include/asm/cpumask.h:5,
                       from ./arch/x86/include/asm/msr.h:11,
                       from ./arch/x86/include/asm/processor.h:21,
                       from ./arch/x86/include/asm/cpufeature.h:5,
                       from ./arch/x86/include/asm/thread_info.h:53,
                       from ./include/linux/thread_info.h:38,
                       from ./arch/x86/include/asm/preempt.h:7,
                       from ./include/linux/preempt.h:78,
                       from ./include/linux/spinlock.h:51,
                       from ./include/linux/mmzone.h:8,
                       from ./include/linux/gfp.h:6,
                       from ./include/linux/mm.h:10,
                       from ./include/linux/bvec.h:13,
                       from ./include/linux/blk_types.h:10,
                       from block/blk-wbt.c:23:
      In function 'strncpy',
          inlined from 'perf_trace_wbt_stat' at ./include/trace/events/wbt.h:15:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'perf_trace_wbt_lat' at ./include/trace/events/wbt.h:58:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'perf_trace_wbt_step' at ./include/trace/events/wbt.h:87:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'perf_trace_wbt_timer' at ./include/trace/events/wbt.h:126:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'trace_event_raw_event_wbt_stat' at ./include/trace/events/wbt.h:15:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'trace_event_raw_event_wbt_lat' at ./include/trace/events/wbt.h:58:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'trace_event_raw_event_wbt_timer' at ./include/trace/events/wbt.h:126:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function 'strncpy',
          inlined from 'trace_event_raw_event_wbt_step' at ./include/trace/events/wbt.h:87:1:
      ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
        return __builtin_strncpy(p, q, size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Fixes: e34cbd30 ("blk-wbt: add general throttling mechanism"; v4.10).
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bf495b67
    • Daniel T. Lee's avatar
      samples: pktgen: fix proc_cmd command result check logic · 340eae0a
      Daniel T. Lee authored
      [ Upstream commit 3cad8f91 ]
      
      Currently, proc_cmd is used to dispatch command to 'pg_ctrl', 'pg_thread',
      'pg_set'. proc_cmd is designed to check command result with grep the
      "Result:", but this might fail since this string is only shown in
      'pg_thread' and 'pg_set'.
      
      This commit fixes this logic by grep-ing the "Result:" string only when
      the command is not for 'pg_ctrl'.
      
      For clarity of an execution flow, 'errexit' flag has been set.
      
      To cleanup pktgen on exit, trap has been added for EXIT signal.
      Signed-off-by: default avatarDaniel T. Lee <danieltimlee@gmail.com>
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      340eae0a
    • Matthias Kaehlcke's avatar
      drm/bridge: dw-hdmi: Refuse DDC/CI transfers on the internal I2C controller · da6c7498
      Matthias Kaehlcke authored
      [ Upstream commit bee447e2 ]
      
      The DDC/CI protocol involves sending a multi-byte request to the
      display via I2C, which is typically followed by a multi-byte
      response. The internal I2C controller only allows single byte
      reads/writes or reads of 8 sequential bytes, hence DDC/CI is not
      supported when the internal I2C controller is used. The I2C
      transfers complete without errors, however the data in the response
      is garbage. Abort transfers to/from slave address 0x37 (DDC) with
      -EOPNOTSUPP, to make it evident that the communication is failing.
      Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarSean Paul <sean@poorly.run>
      Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191002124354.v2.1.I709dfec496f5f0b44a7b61dcd4937924da8d8382@changeidSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      da6c7498