1. 23 2月, 2018 1 次提交
    • D
      Merge tag 'imx-drm-next-2018-02-22' of git://git.pengutronix.de/git/pza/linux into drm-fixes · b17800e9
      Dave Airlie 提交于
      drm/imx: ipu-v3 fixups and grayscale support
      
      - Make const interrupt register arrays static, reduces object size.
      - Fix device_node leaks in PRE/PRG phandle lookup functions.
      - Add 8-bit and 16-bit grayscale buffer support to ipu_cpmem_set_image,
      - add 10-bit and 12-bit grayscale media bus support to ipu-csi,
        to be used by the imx-media driver.
      
      * tag 'imx-drm-next-2018-02-22' of git://git.pengutronix.de/git/pza/linux:
        gpu: ipu-csi: add 10/12-bit grayscale support to mbus_code_to_bus_cfg
        gpu: ipu-cpmem: add 16-bit grayscale support to ipu_cpmem_set_image
        gpu: ipu-v3: prg: fix device node leak in ipu_prg_lookup_by_phandle
        gpu: ipu-v3: pre: fix device node leak in ipu_pre_lookup_by_phandle
        gpu: ipu-cpmem: add 8-bit grayscale support to ipu_cpmem_set_image
        gpu: ipu-v3: make const arrays int_reg static, shrinks object size
      b17800e9
  2. 22 2月, 2018 1 次提交
    • D
      Merge tag 'drm-misc-fixes-2018-02-21' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · dfe8db22
      Dave Airlie 提交于
      Fixes for 4.16. I contains fixes for deadlock on runtime suspend on few
      drivers, a memory leak on non-blocking commits, a crash on color-eviction.
      The is also meson and edid fixes, plus a fix for a doc warning.
      
      * tag 'drm-misc-fixes-2018-02-21' of git://anongit.freedesktop.org/drm/drm-misc:
        drm/tve200: fix kernel-doc documentation comment include
        drm/meson: fix vsync buffer update
        drm: Handle unexpected holes in color-eviction
        drm/edid: Add 6 bpc quirk for CPT panel in Asus UX303LA
        drm/amdgpu: Fix deadlock on runtime suspend
        drm/radeon: Fix deadlock on runtime suspend
        drm/nouveau: Fix deadlock on runtime suspend
        drm: Allow determining if current task is output poll worker
        workqueue: Allow retrieval of current task's work struct
        drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits
      dfe8db22
  3. 21 2月, 2018 6 次提交
  4. 20 2月, 2018 7 次提交
    • N
      drm/meson: fix vsync buffer update · e88230a3
      Neil Armstrong 提交于
      The plane buffer address/stride/height was incorrectly updated in the
      plane_atomic_update operation instead of the vsync irq.
      This patch delays this operation in the vsync irq along with the
      other plane delayed setup.
      
      This issue was masked using legacy framebuffer and X11 modesetting, but
      is clearly visible using gbm rendering when buffer is submitted late after
      vblank, like using software decoding and OpenGL rendering in Kodi.
      With this patch, tearing and other artifacts disappears completely.
      
      Cc: Michal Lazo <michal.lazo@gmail.com>
      Fixes: bbbe775e ("drm: Add support for Amlogic Meson Graphic Controller")
      Signed-off-by: NNeil Armstrong <narmstrong@baylibre.com>
      Acked-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/1518689976-23292-1-git-send-email-narmstrong@baylibre.com
      e88230a3
    • C
      drm: Handle unexpected holes in color-eviction · b8ff1802
      Chris Wilson 提交于
      During eviction, the driver may free more than one hole in the drm_mm
      due to the side-effects in evicting the scanned nodes. However,
      drm_mm_scan_color_evict() expects that the scan result is the first
      available hole (in the mru freed hole_stack list):
      
        kernel BUG at drivers/gpu/drm/drm_mm.c:844!
        invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
        Dumping ftrace buffer:
           (ftrace buffer empty)
        Modules linked in: i915 snd_hda_codec_analog snd_hda_codec_generic coretemp snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core lpc_ich snd_pcm e1000e mei_me prime_numbers mei
        CPU: 1 PID: 1490 Comm: gem_userptr_bli Tainted: G     U           4.16.0-rc1-g740f57c54ecf-kasan_6+ #1
        Hardware name: Dell Inc. OptiPlex 755                 /0PU052, BIOS A08 02/19/2008
        RIP: 0010:drm_mm_scan_color_evict+0x2b8/0x3d0
        RSP: 0018:ffff880057a573f8 EFLAGS: 00010287
        RAX: ffff8800611f5980 RBX: ffff880057a575d0 RCX: dffffc0000000000
        RDX: 00000000029d5000 RSI: 1ffff1000af4aec1 RDI: ffff8800611f5a10
        RBP: ffff88005ab884d0 R08: ffff880057a57600 R09: 000000000afff000
        R10: 1ffff1000b5710b5 R11: 0000000000001000 R12: 1ffff1000af4ae82
        R13: ffff8800611f59b0 R14: ffff8800611f5980 R15: ffff880057a57608
        FS:  00007f2de0c2e8c0(0000) GS:ffff88006ac40000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f2ddde1e000 CR3: 00000000609b2000 CR4: 00000000000006e0
        Call Trace:
         ? drm_mm_scan_remove_block+0x330/0x330
         ? drm_mm_scan_remove_block+0x151/0x330
         i915_gem_evict_something+0x711/0xbd0 [i915]
         ? igt_evict_contexts+0x50/0x50 [i915]
         ? nop_clear_range+0x10/0x10 [i915]
         ? igt_evict_something+0x90/0x90 [i915]
         ? i915_gem_gtt_reserve+0x1a1/0x320 [i915]
         i915_gem_gtt_insert+0x237/0x400 [i915]
         __i915_vma_do_pin+0xc25/0x1a20 [i915]
         eb_lookup_vmas+0x1c63/0x3790 [i915]
         ? i915_gem_check_execbuffer+0x250/0x250 [i915]
         ? trace_hardirqs_on_caller+0x33f/0x590
         ? _raw_spin_unlock_irqrestore+0x39/0x60
         ? __pm_runtime_resume+0x7d/0xf0
         i915_gem_do_execbuffer+0x86a/0x2ff0 [i915]
         ? __kmalloc+0x132/0x340
         ? i915_gem_execbuffer2_ioctl+0x10f/0x760 [i915]
         ? drm_ioctl_kernel+0x12e/0x1c0
         ? drm_ioctl+0x662/0x980
         ? eb_relocate_slow+0xa90/0xa90 [i915]
         ? i915_gem_execbuffer2_ioctl+0x10f/0x760 [i915]
         ? __might_fault+0xea/0x1a0
         i915_gem_execbuffer2_ioctl+0x3cc/0x760 [i915]
         ? i915_gem_execbuffer_ioctl+0xba0/0xba0 [i915]
         ? lock_acquire+0x3c0/0x3c0
         ? i915_gem_execbuffer_ioctl+0xba0/0xba0 [i915]
         drm_ioctl_kernel+0x12e/0x1c0
         drm_ioctl+0x662/0x980
         ? i915_gem_execbuffer_ioctl+0xba0/0xba0 [i915]
         ? drm_getstats+0x20/0x20
         ? debug_check_no_obj_freed+0x2a6/0x8c0
         do_vfs_ioctl+0x170/0xe70
         ? ioctl_preallocate+0x170/0x170
         ? task_work_run+0xbe/0x160
         ? lock_acquire+0x3c0/0x3c0
         ? trace_hardirqs_on_caller+0x33f/0x590
         ? _raw_spin_unlock_irq+0x2f/0x50
         SyS_ioctl+0x36/0x70
         ? do_vfs_ioctl+0xe70/0xe70
         do_syscall_64+0x18c/0x5d0
         entry_SYSCALL_64_after_hwframe+0x26/0x9b
        RIP: 0033:0x7f2ddf13b587
        RSP: 002b:00007fff15c4f9d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f2ddf13b587
        RDX: 00007fff15c4fa20 RSI: 0000000040406469 RDI: 0000000000000003
        RBP: 00007fff15c4fa20 R08: 0000000000000000 R09: 00007f2ddf3fe120
        R10: 0000000000000073 R11: 0000000000000246 R12: 0000000040406469
        R13: 0000000000000003 R14: 00007fff15c4fa20 R15: 00000000000000c7
        Code: 00 00 00 4a c7 44 22 08 00 00 00 00 42 c7 44 22 10 00 00 00 00 48 81 c4 b8 00 00 00 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 0b 0f 0b <0f> 0b 31 c0 eb c0 4c 89 ef e8 9a 09 41 ff e9 1e fe ff ff 4c 89
        RIP: drm_mm_scan_color_evict+0x2b8/0x3d0 RSP: ffff880057a573f8
      
      We can trivially relax this assumption by searching the hole_stack for
      the scan result and warn instead if the driver called us without any
      result.
      
      Fixes: 3fa489da ("drm: Apply tight eviction scanning to color_adjust")
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: <stable@vger.kernel.org> # v4.11+
      Reviewed-by: NJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180219113543.8010-1-chris@chris-wilson.co.uk
      b8ff1802
    • S
      drm: exynos: Use proper macro definition for HDMI_I2S_PIN_SEL_1 · c84b66f8
      Sylwester Nawrocki 提交于
      Bit field [2:0] of HDMI_I2S_PIN_SEL_1 corresponds to SDATA_0,
      not SDATA_2. This patch removes redefinition of HDMI_I2S_SEL_DATA2
      constant and adds missing HDMI_I2S_SEL_DATA0.
      The value of bit field selecting SDATA_1 (pin_sel_3) is also changed,
      so it is 3 as suggested in the Exynos TRMs.
      Signed-off-by: NSylwester Nawrocki <s.nawrocki@samsung.com>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      c84b66f8
    • C
      drm/exynos: remove exynos_drm_rotator.h · b701a143
      Corentin Labbe 提交于
      Since its inclusion in 2012 via commit bea8a429 ("drm/exynos: add rotator ipp driver")
      this header is not used by any source files and is empty.
      Lets just remove it.
      Signed-off-by: NCorentin Labbe <clabbe@baylibre.com>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      b701a143
    • M
      drm/exynos: g2d: Delete an error message for a failed memory allocation in two functions · 6f0a6029
      Markus Elfring 提交于
      Omit an extra message for a memory allocation failure in these functions.
      
      This issue was detected by using the Coccinelle software.
      Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      6f0a6029
    • W
      drm/exynos: fix comparison to bitshift when dealing with a mask · 1293b619
      Wolfram Sang 提交于
      Due to a typo, the mask was destroyed by a comparison instead of a bit
      shift.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      1293b619
    • A
      drm/exynos: g2d: use monotonic timestamps · a588a8bb
      Arnd Bergmann 提交于
      The exynos DRM driver uses real-time 'struct timeval' values
      for exporting its timestamps to user space. This has multiple
      problems:
      
      1. signed seconds overflow in y2038
      2. the 'struct timeval' definition is deprecated in the kernel
      3. time may jump or go backwards after a 'settimeofday()' syscall
      4. other DRM timestamps are in CLOCK_MONOTONIC domain, so they
         can't be compared
      5. exporting microseconds requires a division by 1000, which may
         be slow on some architectures.
      
      The code existed in two places before, but the IPP portion was
      removed in 8ded5941 ("drm/exynos: ipp: Remove Exynos DRM
      IPP subsystem"), so we no longer need to worry about it.
      
      Ideally timestamps should just use 64-bit nanoseconds instead, but
      of course we can't change that now. Instead, this tries to address
      the first four points above by using monotonic 'timespec' values.
      
      According to Tobias Jakobi, user space doesn't care about the
      timestamp at the moment, so we can change the format. Even if
      there is something looking at them, it will work just fine with
      monotonic times as long as the application only looks at the
      relative values between two events.
      
      Link: https://patchwork.kernel.org/patch/10038593/
      Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NTobias Jakobi <tjakobi@math.uni-bielefeld.de>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      a588a8bb
  5. 19 2月, 2018 10 次提交
  6. 18 2月, 2018 6 次提交
    • L
      Merge tag 'for-linus-20180217' of git://git.kernel.dk/linux-block · c786427f
      Linus Torvalds 提交于
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request from Keith, with fixes all over the map for nvme.
         From various folks.
      
       - Classic polling fix, that avoids a latency issue where we still end
         up waiting for an interrupt in some cases. From Nitesh Shetty.
      
       - Comment typo fix from Minwoo Im.
      
      * tag 'for-linus-20180217' of git://git.kernel.dk/linux-block:
        block: fix a typo in comment of BLK_MQ_POLL_STATS_BKTS
        nvme-rdma: fix sysfs invoked reset_ctrl error flow
        nvmet: Change return code of discard command if not supported
        nvme-pci: Fix timeouts in connecting state
        nvme-pci: Remap CMB SQ entries on every controller reset
        nvme: fix the deadlock in nvme_update_formats
        blk: optimization for classic polling
        nvme: Don't use a stack buffer for keep-alive command
        nvme_fc: cleanup io completion
        nvme_fc: correct abort race condition on resets
        nvme: Fix discard buffer overrun
        nvme: delete NVME_CTRL_LIVE --> NVME_CTRL_CONNECTING transition
        nvme-rdma: use NVME_CTRL_CONNECTING state to mark init process
        nvme: rename NVME_CTRL_RECONNECTING state to NVME_CTRL_CONNECTING
      c786427f
    • L
      Merge tag 'mmc-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc · fa2139ef
      Linus Torvalds 提交于
      Pull MMC fixes from Ulf Hansson:
      
       - meson-gx: Revert to earlier tuning process
      
       - bcm2835: Don't overwrite max frequency unconditionally
      
      * tag 'mmc-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
        mmc: bcm2835: Don't overwrite max frequency unconditionally
        Revert "mmc: meson-gx: include tx phase in the tuning process"
      fa2139ef
    • L
      Merge tag 'mtd/fixes-for-4.16-rc2' of git://git.infradead.org/linux-mtd · 4b6415f9
      Linus Torvalds 提交于
      Pull mtd fixes from Boris Brezillon:
      
       - add missing dependency to NAND_MARVELL Kconfig entry
      
       - use the appropriate OOB layout in the VF610 driver
      
      * tag 'mtd/fixes-for-4.16-rc2' of git://git.infradead.org/linux-mtd:
        mtd: nand: MTD_NAND_MARVELL should depend on HAS_DMA
        mtd: nand: vf610: set correct ooblayout
      4b6415f9
    • L
      Merge tag 'powerpc-4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · ee78ad78
      Linus Torvalds 提交于
      Pull powerpc fixes from Michael Ellerman:
       "The main attraction is a fix for a bug in the new drmem code, which
        was causing an oops on boot on some versions of Qemu.
      
        There's also a fix for XIVE (Power9 interrupt controller) on KVM, as
        well as a few other minor fixes.
      
        Thanks to: Corentin Labbe, Cyril Bur, Cédric Le Goater, Daniel Black,
        Nathan Fontenot, Nicholas Piggin"
      
      * tag 'powerpc-4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/pseries: Check for zero filled ibm,dynamic-memory property
        powerpc/pseries: Add empty update_numa_cpu_lookup_table() for NUMA=n
        powerpc/powernv: IMC fix out of bounds memory access at shutdown
        powerpc/xive: Use hw CPU ids when configuring the CPU queues
        powerpc: Expose TSCR via sysfs only on powernv
      ee78ad78
    • L
      Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · 74688a02
      Linus Torvalds 提交于
      Pull arm64 fixes from Catalin Marinas:
       "The bulk of this is the pte accessors annotation to READ/WRITE_ONCE
        (we tried to avoid pushing this during the merge window to avoid
        conflicts)
      
         - Updated the page table accessors to use READ/WRITE_ONCE and prevent
           compiler transformation that could lead to an apparent loss of
           coherency
      
         - Enabled branch predictor hardening for the Falkor CPU
      
         - Fix interaction between kpti enabling and KASan causing the
           recursive page table walking to take a significant time
      
         - Fix some sparse warnings"
      
      * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        arm64: cputype: Silence Sparse warnings
        arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables
        arm64: proc: Set PTE_NG for table entries to avoid traversing them twice
        arm64: Add missing Falkor part number for branch predictor hardening
      74688a02
    • L
      Merge tag 'for-linus-4.16a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · f73f047d
      Linus Torvalds 提交于
      Pull xen fixes from Juergen Gross:
      
       - fixes for the Xen pvcalls frontend driver
      
       - fix for booting Xen pv domains
      
       - fix for the xenbus driver user interface
      
      * tag 'for-linus-4.16a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        pvcalls-front: wait for other operations to return when release passive sockets
        pvcalls-front: introduce a per sock_mapping refcount
        x86/xen: Calculate __max_logical_packages on PV domains
        xenbus: track caller request id
      f73f047d
  7. 17 2月, 2018 9 次提交
    • S
      pvcalls-front: wait for other operations to return when release passive sockets · d1a75e08
      Stefano Stabellini 提交于
      Passive sockets can have ongoing operations on them, specifically, we
      have two wait_event_interruptable calls in pvcalls_front_accept.
      
      Add two wake_up calls in pvcalls_front_release, then wait for the
      potential waiters to return and release the sock_mapping refcount.
      Signed-off-by: NStefano Stabellini <stefano@aporeto.com>
      Acked-by: NJuergen Gross <jgross@suse.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      d1a75e08
    • S
      pvcalls-front: introduce a per sock_mapping refcount · 64d68718
      Stefano Stabellini 提交于
      Introduce a per sock_mapping refcount, in addition to the existing
      global refcount. Thanks to the sock_mapping refcount, we can safely wait
      for it to be 1 in pvcalls_front_release before freeing an active socket,
      instead of waiting for the global refcount to be 1.
      Signed-off-by: NStefano Stabellini <stefano@aporeto.com>
      Acked-by: NJuergen Gross <jgross@suse.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      64d68718
    • P
      x86/xen: Calculate __max_logical_packages on PV domains · 63e708f8
      Prarit Bhargava 提交于
      The kernel panics on PV domains because native_smp_cpus_done() is
      only called for HVM domains.
      
      Calculate __max_logical_packages for PV domains.
      
      Fixes: b4c0a732 ("x86/smpboot: Fix __max_logical_packages estimate")
      Signed-off-by: NPrarit Bhargava <prarit@redhat.com>
      Tested-and-reported-by: NSimon Gaiser <simon@invisiblethingslab.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: x86@kernel.org
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Dou Liyang <douly.fnst@cn.fujitsu.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: xen-devel@lists.xenproject.org
      Reviewed-by: NBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      63e708f8
    • J
      xenbus: track caller request id · 29fee6ee
      Joao Martins 提交于
      Commit fd8aa909 ("xen: optimize xenbus driver for multiple concurrent
      xenstore accesses") optimized xenbus concurrent accesses but in doing so
      broke UABI of /dev/xen/xenbus. Through /dev/xen/xenbus applications are in
      charge of xenbus message exchange with the correct header and body. Now,
      after the mentioned commit the replies received by application will no
      longer have the header req_id echoed back as it was on request (see
      specification below for reference), because that particular field is being
      overwritten by kernel.
      
      struct xsd_sockmsg
      {
        uint32_t type;  /* XS_??? */
        uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
        uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
        uint32_t len;   /* Length of data following this. */
      
        /* Generally followed by nul-terminated string(s). */
      };
      
      Before there was only one request at a time so req_id could simply be
      forwarded back and forth. To allow simultaneous requests we need a
      different req_id for each message thus kernel keeps a monotonic increasing
      counter for this field and is written on every request irrespective of
      userspace value.
      
      Forwarding again the req_id on userspace requests is not a solution because
      we would open the possibility of userspace-generated req_id colliding with
      kernel ones. So this patch instead takes another route which is to
      artificially keep user req_id while keeping the xenbus logic as is. We do
      that by saving the original req_id before xs_send(), use the private kernel
      counter as req_id and then once reply comes and was validated, we restore
      back the original req_id.
      
      Cc: <stable@vger.kernel.org> # 4.11
      Fixes: fd8aa909 ("xen: optimize xenbus driver for multiple concurrent xenstore accesses")
      Reported-by: NBhavesh Davda <bhavesh.davda@oracle.com>
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      Reviewed-by: NJuergen Gross <jgross@suse.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      29fee6ee
    • R
      arm64: cputype: Silence Sparse warnings · e1a50de3
      Robin Murphy 提交于
      Sparse makes a fair bit of noise about our MPIDR mask being implicitly
      long - let's explicitly describe it as such rather than just relying on
      the value forcing automatic promotion.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      e1a50de3
    • L
      drm/amdgpu: Fix deadlock on runtime suspend · aa0aad57
      Lukas Wunner 提交于
      amdgpu's ->runtime_suspend hook calls drm_kms_helper_poll_disable(),
      which waits for the output poll worker to finish if it's running.
      
      The output poll worker meanwhile calls pm_runtime_get_sync() in
      amdgpu's ->detect hooks, which waits for the ongoing suspend to finish,
      causing a deadlock.
      
      Fix by not acquiring a runtime PM ref if the ->detect hooks are called
      in the output poll worker's context.  This is safe because the poll
      worker is only enabled while runtime active and we know that
      ->runtime_suspend waits for it to finish.
      
      Fixes: d38ceaf9 ("drm/amdgpu: add core driver (v4)")
      Cc: stable@vger.kernel.org # v4.2+: 27d4ee03: workqueue: Allow retrieval of current task's work struct
      Cc: stable@vger.kernel.org # v4.2+: 25c058cc: drm: Allow determining if current task is output poll worker
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Tested-by: NMike Lothian <mike@fireburn.co.uk>
      Reviewed-by: NLyude Paul <lyude@redhat.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/4c9bf72aacae1eef062bd134cd112e0770a7f121.1518338789.git.lukas@wunner.de
      aa0aad57
    • L
      drm/radeon: Fix deadlock on runtime suspend · 15734fef
      Lukas Wunner 提交于
      radeon's ->runtime_suspend hook calls drm_kms_helper_poll_disable(),
      which waits for the output poll worker to finish if it's running.
      
      The output poll worker meanwhile calls pm_runtime_get_sync() in
      radeon's ->detect hooks, which waits for the ongoing suspend to finish,
      causing a deadlock.
      
      Fix by not acquiring a runtime PM ref if the ->detect hooks are called
      in the output poll worker's context.  This is safe because the poll
      worker is only enabled while runtime active and we know that
      ->runtime_suspend waits for it to finish.
      
      Stack trace for posterity:
      
        INFO: task kworker/0:3:31847 blocked for more than 120 seconds
        Workqueue: events output_poll_execute [drm_kms_helper]
        Call Trace:
         schedule+0x3c/0x90
         rpm_resume+0x1e2/0x690
         __pm_runtime_resume+0x3f/0x60
         radeon_lvds_detect+0x39/0xf0 [radeon]
         output_poll_execute+0xda/0x1e0 [drm_kms_helper]
         process_one_work+0x14b/0x440
         worker_thread+0x48/0x4a0
      
        INFO: task kworker/2:0:10493 blocked for more than 120 seconds.
        Workqueue: pm pm_runtime_work
        Call Trace:
         schedule+0x3c/0x90
         schedule_timeout+0x1b3/0x240
         wait_for_common+0xc2/0x180
         wait_for_completion+0x1d/0x20
         flush_work+0xfc/0x1a0
         __cancel_work_timer+0xa5/0x1d0
         cancel_delayed_work_sync+0x13/0x20
         drm_kms_helper_poll_disable+0x1f/0x30 [drm_kms_helper]
         radeon_pmops_runtime_suspend+0x3d/0xa0 [radeon]
         pci_pm_runtime_suspend+0x61/0x1a0
         vga_switcheroo_runtime_suspend+0x21/0x70
         __rpm_callback+0x32/0x70
         rpm_callback+0x24/0x80
         rpm_suspend+0x12b/0x640
         pm_runtime_work+0x6f/0xb0
         process_one_work+0x14b/0x440
         worker_thread+0x48/0x4a0
      
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94147
      Fixes: 10ebc0bc ("drm/radeon: add runtime PM support (v2)")
      Cc: stable@vger.kernel.org # v3.13+: 27d4ee03: workqueue: Allow retrieval of current task's work struct
      Cc: stable@vger.kernel.org # v3.13+: 25c058cc: drm: Allow determining if current task is output poll worker
      Cc: Ismo Toijala <ismo.toijala@gmail.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Reviewed-by: NLyude Paul <lyude@redhat.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/64ea02c44f91dda19bc563902b97bbc699040392.1518338789.git.lukas@wunner.de
      15734fef
    • L
      drm/nouveau: Fix deadlock on runtime suspend · d61a5c10
      Lukas Wunner 提交于
      nouveau's ->runtime_suspend hook calls drm_kms_helper_poll_disable(),
      which waits for the output poll worker to finish if it's running.
      
      The output poll worker meanwhile calls pm_runtime_get_sync() in
      nouveau_connector_detect() which waits for the ongoing suspend to finish,
      causing a deadlock.
      
      Fix by not acquiring a runtime PM ref if nouveau_connector_detect() is
      called in the output poll worker's context.  This is safe because
      the poll worker is only enabled while runtime active and we know that
      ->runtime_suspend waits for it to finish.
      
      Other contexts calling nouveau_connector_detect() do require a runtime
      PM ref, these comprise:
      
        status_store() drm sysfs interface
        ->fill_modes drm callback
        drm_fb_helper_probe_connector_modes()
        drm_mode_getconnector()
        nouveau_connector_hotplug()
        nouveau_display_hpd_work()
        nv17_tv_set_property()
      
      Stack trace for posterity:
      
        INFO: task kworker/0:1:58 blocked for more than 120 seconds.
        Workqueue: events output_poll_execute [drm_kms_helper]
        Call Trace:
         schedule+0x28/0x80
         rpm_resume+0x107/0x6e0
         __pm_runtime_resume+0x47/0x70
         nouveau_connector_detect+0x7e/0x4a0 [nouveau]
         nouveau_connector_detect_lvds+0x132/0x180 [nouveau]
         drm_helper_probe_detect_ctx+0x85/0xd0 [drm_kms_helper]
         output_poll_execute+0x11e/0x1c0 [drm_kms_helper]
         process_one_work+0x184/0x380
         worker_thread+0x2e/0x390
      
        INFO: task kworker/0:2:252 blocked for more than 120 seconds.
        Workqueue: pm pm_runtime_work
        Call Trace:
         schedule+0x28/0x80
         schedule_timeout+0x1e3/0x370
         wait_for_completion+0x123/0x190
         flush_work+0x142/0x1c0
         nouveau_pmops_runtime_suspend+0x7e/0xd0 [nouveau]
         pci_pm_runtime_suspend+0x5c/0x180
         vga_switcheroo_runtime_suspend+0x1e/0xa0
         __rpm_callback+0xc1/0x200
         rpm_callback+0x1f/0x70
         rpm_suspend+0x13c/0x640
         pm_runtime_work+0x6e/0x90
         process_one_work+0x184/0x380
         worker_thread+0x2e/0x390
      
      Bugzilla: https://bugs.archlinux.org/task/53497
      Bugzilla: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870523
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70388#c33
      Fixes: 5addcf0a ("nouveau: add runtime PM support (v0.9)")
      Cc: stable@vger.kernel.org # v3.12+: 27d4ee03: workqueue: Allow retrieval of current task's work struct
      Cc: stable@vger.kernel.org # v3.12+: 25c058cc: drm: Allow determining if current task is output poll worker
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Reviewed-by: NLyude Paul <lyude@redhat.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/b7d2cbb609a80f59ccabfdf479b9d5907c603ea1.1518338789.git.lukas@wunner.de
      d61a5c10
    • L
      drm: Allow determining if current task is output poll worker · 25c058cc
      Lukas Wunner 提交于
      Introduce a helper to determine if the current task is an output poll
      worker.
      
      This allows us to fix a long-standing deadlock in several DRM drivers
      wherein the ->runtime_suspend callback waits for the output poll worker
      to finish and the worker in turn calls a ->detect callback which waits
      for runtime suspend to finish.  The ->detect callback is invoked from
      multiple call sites and waiting for runtime suspend to finish is the
      correct thing to do except if it's executing in the context of the
      worker.
      
      v2: Expand kerneldoc to specifically mention deadlock between
          output poll worker and autosuspend worker as use case. (Lyude)
      
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Reviewed-by: NLyude Paul <lyude@redhat.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/3549ce32e7f1467102e70d3e9cbf70c46bfe108e.1518593424.git.lukas@wunner.de
      25c058cc