1. 19 Apr, 2024 1 commit
  2. 18 Apr, 2024 4 commits
  3. 17 Apr, 2024 11 commits
  4. 16 Apr, 2024 11 commits
  5. 15 Apr, 2024 13 commits
    • Zack Rusin's avatar
      drm/vmwgfx: Implement virtual crc generation · 7b006203
      Zack Rusin authored
      crc checksums are used to validate the output. Normally they're part
      of the actual display hardware but on virtual stack there's nothing
      to automatically generate them.
      
      Implement crc generation for the vmwgfx stack. This works only on
      screen targets, where it's possibly to easily make sure that the
      guest side contents of the surface matches the host sides output.
      
      Just like the vblank support, crc generation can only be enabled via:
      guestinfo.vmwgfx.vkms_enable = "TRUE"
      option in the vmx file.
      
      Makes IGT's kms_pipe_crc_basic pass and allows a huge number of other
      IGT tests which require CRC generation of the output to actually run
      on vmwgfx. Makes it possible to actually validate a lof of the kms and
      drm functionality with vmwgfx.
      Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
      Acked-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240412025511.78553-3-zack.rusin@broadcom.com
      7b006203
    • Zack Rusin's avatar
      drm/vmwgfx: Implement virtual kms · cd2eb57d
      Zack Rusin authored
      By default vmwgfx doesn't support vblanking or crc generation which
      makes it impossible to use various IGT tests to validate vmwgfx.
      Implement virtual kernel mode setting, which is mainly related to
      simulated vblank support.
      
      Code is very similar to amd's vkms and the vkms module itself, except
      that it's integrated with vmwgfx three different output technologies -
      legacy, screen object and screen targets.
      
      Make IGT's kms_vblank pass on vmwgfx and allows a lot of other IGT
      tests to run with vmwgfx.
      
      Support for vkms needs to be manually enabled by adding:
      guestinfo.vmwgfx.vkms_enable = "TRUE"
      somewhere in the vmx file, otherwise it's off by default.
      Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
      Acked-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240412025511.78553-2-zack.rusin@broadcom.com
      cd2eb57d
    • Tvrtko Ursulin's avatar
      dma-buf: Do not build debugfs related code when !CONFIG_DEBUG_FS · bfc7bc53
      Tvrtko Ursulin authored
      There is no point in compiling in the list and mutex operations which are
      only used from the dma-buf debugfs code, if debugfs is not compiled in.
      
      Put the code in questions behind some kconfig guards and so save some text
      and maybe even a pointer per object at runtime when not enabled.
      Signed-off-by: default avatarTvrtko Ursulin <tursulin@ursulin.net>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Cc: linaro-mm-sig@lists.linaro.org
      Cc: linux-kernel@vger.kernel.org
      Cc: kernel-dev@igalia.com
      Reviewed-by: default avatarT.J. Mercier <tjmercier@google.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240328145323.68872-1-tursulin@igalia.com
      bfc7bc53
    • Maíra Canal's avatar
      drm/fb_dma: s/drm_panic_gem_get_scanout_buffer/drm_fb_dma_get_scanout_buffer · d894ea56
      Maíra Canal authored
      On version 11 of the "drm/panic: Add a drm panic handler" series [1], Thomas
      suggested to change the name of the function `drm_panic_gem_get_scanout_buffer`
      to `drm_fb_dma_get_scanout_buffer` and this request was applied on version 12,
      which is the version that landed [2]. Although the name of the function
      changed on the C file, it didn't changed on the header file, leading to a
      compilation error as such:
      
      drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c:780:24: error: use of undeclared
      identifier 'drm_fb_dma_get_scanout_buffer'; did you mean 'drm_panic_gem_get_scanout_buffer'?
        780 |         .get_scanout_buffer = drm_fb_dma_get_scanout_buffer,
            |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |                               drm_panic_gem_get_scanout_buffer
      ./include/drm/drm_fb_dma_helper.h:23:5: note: 'drm_panic_gem_get_scanout_buffer'
      declared here
         23 | int drm_panic_gem_get_scanout_buffer(struct drm_plane *plane,
            |     ^
      1 error generated.
      
      Fix the compilation error by changing `drm_panic_gem_get_scanout_buffer` to
      `drm_fb_dma_get_scanout_buffer` on the header file.
      
      Link: https://lore.kernel.org/dri-devel/20240328120638.468738-1-jfalempe@redhat.com/ [1]
      Link: https://lore.kernel.org/dri-devel/aea2aa01-7f03-453b-8b30-8f4d90b1b47f@redhat.com/ [2]
      Fixes: 879b3b65 ("drm/fb_dma: Add generic get_scanout_buffer() for drm_panic")
      Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
      Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240415151013.3210278-1-mcanal@igalia.com
      d894ea56
    • Jocelyn Falempe's avatar
      drm/ast: Add drm_panic support · baaf150f
      Jocelyn Falempe authored
      Add support for the drm_panic module, which displays a message to
      the screen when a kernel panic occurs.
      
      v7
       * Use drm_for_each_primary_visible_plane()
      
      v8:
       * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
         (Thomas Zimmermann)
      v9:
       * Revert to using get_scanout_buffer() (Sima)
       * move get_scanout_buffer() to plane helper functions
      
      v12:
       * Use array for map and pitch in struct drm_scanout_buffer
         to support multi-planar format later. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Acked-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
      Tested-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
      Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-10-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      baaf150f
    • Jocelyn Falempe's avatar
      drm/imx: Add drm_panic support · 99b62519
      Jocelyn Falempe authored
      Add support for the drm_panic module, which displays a user-friendly
      message to the screen when a kernel panic occurs.
      
      v7:
       * use drm_panic_gem_get_scanout_buffer() helper
      
      v8:
       * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
      
      v9:
       * Revert to using get_scanout_buffer() (Sima)
       * move get_scanout_buffer() to plane helper functions
      
      v12:
       * Rename drm_panic_gem_get_scanout_buffer to drm_fb_dma_get_scanout_buffer
       (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-9-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      99b62519
    • Jocelyn Falempe's avatar
      drm/mgag200: Add drm_panic support · 7e64f7c8
      Jocelyn Falempe authored
      Add support for the drm_panic module, which displays a message to
      the screen when a kernel panic occurs.
      
      v5:
       * Also check that the plane is visible and primary. (Thomas Zimmermann)
      
      v7:
       * use drm_for_each_primary_visible_plane()
      
      v8:
       * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
         (Thomas Zimmermann)
      
      v9:
       * Revert to using get_scanout_buffer() (Sima)
       * move get_scanout_buffer() to plane helper functions (Thomas Zimmermann)
      
      v12:
       * Use array for map and pitch in struct drm_scanout_buffer
         to support multi-planar format later. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-8-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      7e64f7c8
    • Jocelyn Falempe's avatar
      drm/simpledrm: Add drm_panic support · 41e54853
      Jocelyn Falempe authored
      Add support for the drm_panic module, which displays a user-friendly
      message to the screen when a kernel panic occurs.
      
      v8:
       * Replace get_scanout_buffer() with drm_panic_set_buffer()
         (Thomas Zimmermann)
      
      v9:
       * Revert to using get_scanout_buffer() (Sima)
       * move get_scanout_buffer() to plane helper functions (Thomas Zimmermann)
      
      v12:
       * Use array for map and pitch in struct drm_scanout_buffer
         to support multi-planar format later. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-7-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      41e54853
    • Jocelyn Falempe's avatar
      drm/fb_dma: Add generic get_scanout_buffer() for drm_panic · 879b3b65
      Jocelyn Falempe authored
      This was initialy done for imx6, but should work on most drivers
      using drm_fb_dma_helper.
      
      v8:
       * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
         (Thomas Zimmermann)
      
      v9:
       * go back to get_scanout_buffer()
       * move get_scanout_buffer() to plane helper functions
      
      v12:
       * Rename drm_panic_gem_get_scanout_buffer to drm_fb_dma_get_scanout_buffer
         (Thomas Zimmermann)
       * Remove the #ifdef CONFIG_DRM_PANIC, and build it unconditionnaly, as
         it's a small function. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-6-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      879b3b65
    • Jocelyn Falempe's avatar
      drm/panic: Add debugfs entry to test without triggering panic. · 813ca3aa
      Jocelyn Falempe authored
      Add a debugfs file, so you can test drm_panic without freezing
      your machine. This is unsafe, and should be enabled only for
      developer or tester.
      
      To display the drm_panic screen on the device 0:
      echo 1 > /sys/kernel/debug/dri/0/drm_panic_plane_0
      
      v9:
       * Create a debugfs file for each plane in the device's debugfs
         directory. This allows to test for each plane of each GPU
         independently.
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-5-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      813ca3aa
    • Jocelyn Falempe's avatar
      drm/panic: Add support for color format conversion · 95443097
      Jocelyn Falempe authored
      Add support for the following formats:
      DRM_FORMAT_RGB565
      DRM_FORMAT_RGBA5551
      DRM_FORMAT_XRGB1555
      DRM_FORMAT_ARGB1555
      DRM_FORMAT_RGB888
      DRM_FORMAT_XRGB8888
      DRM_FORMAT_ARGB8888
      DRM_FORMAT_XBGR8888
      DRM_FORMAT_XRGB2101010
      DRM_FORMAT_ARGB2101010
      
      v10:
       * move and simplify the functions from the drm format helper to drm_panic
      
      v12:
       * Use array for map and pitch in struct drm_scanout_buffer
         to support multi-planar format later. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-4-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      95443097
    • Jocelyn Falempe's avatar
      drm/panic: Add a drm panic handler · bf9fb17c
      Jocelyn Falempe authored
      This module displays a user friendly message when a kernel panic
      occurs. It currently doesn't contain any debug information,
      but that can be added later.
      
      v2
       * Use get_scanout_buffer() instead of the drm client API.
        (Thomas Zimmermann)
       * Add the panic reason to the panic message (Nerdopolis)
       * Add an exclamation mark (Nerdopolis)
      
      v3
       * Rework the drawing functions, to write the pixels line by line and
       to use the drm conversion helper to support other formats.
       (Thomas Zimmermann)
      
      v4
       * Use drm_fb_r1_to_32bit for fonts (Thomas Zimmermann)
       * Remove the default y to DRM_PANIC config option (Thomas Zimmermann)
       * Add foreground/background color config option
       * Fix the bottom lines not painted if the framebuffer height
         is not a multiple of the font height.
       * Automatically register the device to drm_panic, if the function
         get_scanout_buffer exists. (Thomas Zimmermann)
      
      v5
       * Change the drawing API, use drm_fb_blit_from_r1() to draw the font.
       * Also add drm_fb_fill() to fill area with background color.
       * Add draw_pixel_xy() API for drivers that can't provide a linear buffer.
       * Add a flush() callback for drivers that needs to synchronize the buffer.
       * Add a void *private field, so drivers can pass private data to
         draw_pixel_xy() and flush().
      
      v6
       * Fix sparse warning for panic_msg and logo.
      
      v7
       * Add select DRM_KMS_HELPER for the color conversion functions.
      
      v8
       * Register directly each plane to the panic notifier (Sima)
       * Add raw_spinlock to properly handle concurrency (Sima)
       * Register plane instead of device, to avoid looping through plane
         list, and simplify code.
       * Replace get_scanout_buffer() logic with drm_panic_set_buffer()
        (Thomas Zimmermann)
       * Removed the draw_pixel_xy() API, will see later if it can be added back.
      
      v9
       * Revert to using get_scanout_buffer() (Sima)
       * Move get_scanout_buffer() and panic_flush() to the plane helper
         functions (Thomas Zimmermann)
       * Register all planes with get_scanout_buffer() to the panic notifier
       * Use drm_panic_lock() to protect against race (Sima)
      
      v10
       * Move blit and fill functions back in drm_panic (Thomas Zimmermann).
       * Simplify the text drawing functions.
       * Use kmsg_dumper instead of panic_notifier (Sima).
      
      v12
       * Use array for map and pitch in struct drm_scanout_buffer
         to support multi-planar format later. (Thomas Zimmermann)
       * Better indent struct drm_scanout_buffer declaration. (Thomas Zimmermann)
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-3-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      bf9fb17c
    • Daniel Vetter's avatar
      drm/panic: Add drm panic locking · e2a1cda3
      Daniel Vetter authored
      Rough sketch for the locking of drm panic printing code. The upshot of
      this approach is that we can pretty much entirely rely on the atomic
      commit flow, with the pair of raw_spin_lock/unlock providing any
      barriers we need, without having to create really big critical
      sections in code.
      
      This also avoids the need that drivers must explicitly update the
      panic handler state, which they might forget to do, or not do
      consistently, and then we blow up in the worst possible times.
      
      It is somewhat racy against a concurrent atomic update, and we might
      write into a buffer which the hardware will never display. But there's
      fundamentally no way to avoid that - if we do the panic state update
      explicitly after writing to the hardware, we might instead write to an
      old buffer that the user will barely ever see.
      
      Note that an rcu protected deference of plane->state would give us the
      the same guarantees, but it has the downside that we then need to
      protect the plane state freeing functions with call_rcu too. Which
      would very widely impact a lot of code and therefore doesn't seem
      worth the complexity compared to a raw spinlock with very tiny
      critical sections. Plus rcu cannot be used to protect access to
      peek/poke registers anyway, so we'd still need it for those cases.
      
      Peek/poke registers for vram access (or a gart pte reserved just for
      panic code) are also the reason I've gone with a per-device and not
      per-plane spinlock, since usually these things are global for the
      entire display. Going with per-plane locks would mean drivers for such
      hardware would need additional locks, which we don't want, since it
      deviates from the per-console takeoverlocks design.
      
      Longer term it might be useful if the panic notifiers grow a bit more
      structure than just the absolute bare
      EXPORT_SYMBOL(panic_notifier_list) - somewhat aside, why is that not
      EXPORT_SYMBOL_GPL ... If panic notifiers would be more like console
      drivers with proper register/unregister interfaces we could perhaps
      reuse the very fancy console lock with all it's check and takeover
      semantics that John Ogness is developing to fix the console_lock mess.
      But for the initial cut of a drm panic printing support I don't think
      we need that, because the critical sections are extremely small and
      only happen once per display refresh. So generally just 60 tiny locked
      sections per second, which is nothing compared to a serial console
      running a 115kbaud doing really slow mmio writes for each byte. So for
      now the raw spintrylock in drm panic notifier callback should be good
      enough.
      
      Another benefit of making panic notifiers more like full blown
      consoles (that are used in panics only) would be that we get the two
      stage design, where first all the safe outputs are used. And then the
      dangerous takeover tricks are deployed (where for display drivers we
      also might try to intercept any in-flight display buffer flips, which
      if we race and misprogram fifos and watermarks can hang the memory
      controller on some hw).
      
      For context the actual implementation on the drm side is by Jocelyn
      and this patch is meant to be combined with the overall approach in
      v7 (v8 is a bit less flexible, which I think is the wrong direction):
      
      https://lore.kernel.org/dri-devel/20240104160301.185915-1-jfalempe@redhat.com/
      
      Note that the locking is very much not correct there, hence this
      separate rfc.
      
      Starting from v10, I (Jocelyn) have included this patch in the drm_panic
      series, and done the corresponding changes.
      
      v2:
      - fix authorship, this was all my typing
      - some typo oopsies
      - link to the drm panic work by Jocelyn for context
      
      v10:
      - Use spinlock_irqsave/restore (John Ogness)
      
      v11:
      - Use macro instead of inline functions for drm_panic_lock/unlock (John Ogness)
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Jocelyn Falempe <jfalempe@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: David Airlie <airlied@gmail.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Signed-off-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-2-jfalempe@redhat.comAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      e2a1cda3