[PULL] drm-misc-next-fixes

2024-05-16 Thread Maarten Lankhorst

drm-misc-next-fixes-2024-05-16:
drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.
The following changes since commit be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-16


for you to fetch changes up to 959314c438caf1b62d787f02d54a193efda38880:

  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 
(2024-05-13 22:27:33 +0200)



drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.


Anatoliy Klymenko (2):
  drm: xlnx: zynqmp_dpsub: Fix few function comments
  drm: xlnx: zynqmp_dpsub: Fix compilation error

Antonino Maniscalco (1):
  drm/panthor: Fix tiler OOM handling to allow incremental rendering

Boris Brezillon (8):
  drm/panthor: Make sure the tiler initial/max chunks are consistent
  drm/panthor: Relax the constraints on the tiler chunk size
  drm/panthor: Fix an off-by-one in the heap context retrieval logic
  drm/panthor: Document drm_panthor_tiler_heap_destroy::handle 
validity constraints

  drm/panthor: Force an immediate reset on unrecoverable faults
  drm/panthor: Keep a ref to the VM at the panthor_kernel_bo level
  drm/panthor: Reset the FW VM to NULL on unplug
  drm/panthor: Call panthor_sched_post_reset() even if the reset failed

Mohamed Ahmed (1):
  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations

 drivers/gpu/drm/nouveau/nouveau_abi16.c  |  3 ++
 drivers/gpu/drm/nouveau/nouveau_bo.c | 44 
+

 drivers/gpu/drm/panthor/panthor_device.c |  8 ++
 drivers/gpu/drm/panthor/panthor_device.h |  1 +
 drivers/gpu/drm/panthor/panthor_fw.c |  5 ++--
 drivers/gpu/drm/panthor/panthor_gem.c|  8 --
 drivers/gpu/drm/panthor/panthor_gem.h|  8 --
 drivers/gpu/drm/panthor/panthor_heap.c   | 36 ++--
 drivers/gpu/drm/panthor/panthor_sched.c  | 48 
+++-

 drivers/gpu/drm/panthor/panthor_sched.h  |  2 +-
 drivers/gpu/drm/xlnx/zynqmp_disp.c   |  6 ++--
 include/uapi/drm/nouveau_drm.h   |  7 +
 include/uapi/drm/panthor_drm.h   | 20 ++---
 13 files changed, 123 insertions(+), 73 deletions(-)


[PULL] drm-misc-next-fixes

2024-05-16 Thread Maarten Lankhorst

drm-misc-next-fixes-2024-05-16:
drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.
The following changes since commit be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-16


for you to fetch changes up to 959314c438caf1b62d787f02d54a193efda38880:

  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 
(2024-05-13 22:27:33 +0200)



drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.


Anatoliy Klymenko (2):
  drm: xlnx: zynqmp_dpsub: Fix few function comments
  drm: xlnx: zynqmp_dpsub: Fix compilation error

Antonino Maniscalco (1):
  drm/panthor: Fix tiler OOM handling to allow incremental rendering

Boris Brezillon (8):
  drm/panthor: Make sure the tiler initial/max chunks are consistent
  drm/panthor: Relax the constraints on the tiler chunk size
  drm/panthor: Fix an off-by-one in the heap context retrieval logic
  drm/panthor: Document drm_panthor_tiler_heap_destroy::handle 
validity constraints

  drm/panthor: Force an immediate reset on unrecoverable faults
  drm/panthor: Keep a ref to the VM at the panthor_kernel_bo level
  drm/panthor: Reset the FW VM to NULL on unplug
  drm/panthor: Call panthor_sched_post_reset() even if the reset failed

Mohamed Ahmed (1):
  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations

 drivers/gpu/drm/nouveau/nouveau_abi16.c  |  3 ++
 drivers/gpu/drm/nouveau/nouveau_bo.c | 44 
+

 drivers/gpu/drm/panthor/panthor_device.c |  8 ++
 drivers/gpu/drm/panthor/panthor_device.h |  1 +
 drivers/gpu/drm/panthor/panthor_fw.c |  5 ++--
 drivers/gpu/drm/panthor/panthor_gem.c|  8 --
 drivers/gpu/drm/panthor/panthor_gem.h|  8 --
 drivers/gpu/drm/panthor/panthor_heap.c   | 36 ++--
 drivers/gpu/drm/panthor/panthor_sched.c  | 48 
+++-

 drivers/gpu/drm/panthor/panthor_sched.h  |  2 +-
 drivers/gpu/drm/xlnx/zynqmp_disp.c   |  6 ++--
 include/uapi/drm/nouveau_drm.h   |  7 +
 include/uapi/drm/panthor_drm.h   | 20 ++---
 13 files changed, 123 insertions(+), 73 deletions(-)


[PULL] drm-misc-next-fixes

2024-05-16 Thread Maarten Lankhorst

drm-misc-next-fixes-2024-05-16:
drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.
The following changes since commit be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-16


for you to fetch changes up to 959314c438caf1b62d787f02d54a193efda38880:

  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 
(2024-05-13 22:27:33 +0200)



drm-misc-next-fixes for v6.10-rc1:
- VM_BIND fix for nouveau.
- Lots of panthor fixes:
  * Fixes for panthor's heap logical block.
  * Reset on unrecoverable fault
  * Fix VM references.
  * Reset fix.
- xlnx compile and doc fixes.


Anatoliy Klymenko (2):
  drm: xlnx: zynqmp_dpsub: Fix few function comments
  drm: xlnx: zynqmp_dpsub: Fix compilation error

Antonino Maniscalco (1):
  drm/panthor: Fix tiler OOM handling to allow incremental rendering

Boris Brezillon (8):
  drm/panthor: Make sure the tiler initial/max chunks are consistent
  drm/panthor: Relax the constraints on the tiler chunk size
  drm/panthor: Fix an off-by-one in the heap context retrieval logic
  drm/panthor: Document drm_panthor_tiler_heap_destroy::handle 
validity constraints

  drm/panthor: Force an immediate reset on unrecoverable faults
  drm/panthor: Keep a ref to the VM at the panthor_kernel_bo level
  drm/panthor: Reset the FW VM to NULL on unplug
  drm/panthor: Call panthor_sched_post_reset() even if the reset failed

Mohamed Ahmed (1):
  drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations

 drivers/gpu/drm/nouveau/nouveau_abi16.c  |  3 ++
 drivers/gpu/drm/nouveau/nouveau_bo.c | 44 
+

 drivers/gpu/drm/panthor/panthor_device.c |  8 ++
 drivers/gpu/drm/panthor/panthor_device.h |  1 +
 drivers/gpu/drm/panthor/panthor_fw.c |  5 ++--
 drivers/gpu/drm/panthor/panthor_gem.c|  8 --
 drivers/gpu/drm/panthor/panthor_gem.h|  8 --
 drivers/gpu/drm/panthor/panthor_heap.c   | 36 ++--
 drivers/gpu/drm/panthor/panthor_sched.c  | 48 
+++-

 drivers/gpu/drm/panthor/panthor_sched.h  |  2 +-
 drivers/gpu/drm/xlnx/zynqmp_disp.c   |  6 ++--
 include/uapi/drm/nouveau_drm.h   |  7 +
 include/uapi/drm/panthor_drm.h   | 20 ++---
 13 files changed, 123 insertions(+), 73 deletions(-)


Re: [PATCH v10 05/12] drm/panelreplay: dpcd register definition for panelreplay SU

2024-05-15 Thread Maarten Lankhorst

Hey,

Den 2024-05-13 kl. 10:55, skrev Hogander, Jouni:

Hello Maintainers,

Could you please ack this patch? I'm planning to merge it via drm-intel
tree.

BR,

Jouni Högander

Acked-by: Maarten Lankhorst 


[PULL] drm-misc-next-fixes

2024-05-08 Thread Maarten Lankhorst

Hi Dave, Sima,

drm-misc-next-fixes for v6.10-rc1.

There was some discussion on certain cherry picks I did,
specifically the one for hiding fbdev address. There is some potential
to cause regressions on ARM by hiding the physical address, but I think 
it should be fine to move ahead. This is why a pull request didn't make 
it in time last week.


Hope the extra time at least gave more chance of detection of potential 
regressions.


Cheers,
Maarten

drm-misc-next-fixes-2024-05-08:
drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.
The following changes since commit 4a56c0ed5aa0bcbe1f5f7d755fb1fe1ebf48ae9c:

  Merge tag 'amd-drm-next-6.10-2024-04-26' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-next (2024-04-30 
14:43:00 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-08


for you to fetch changes up to be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)


drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.


Boris Brezillon (3):
  drm/panthor: Kill the faulty_slots variable in 
panthor_sched_suspend()

  drm/panthor: Make sure we handle 'unknown group state' case properly
  drm/panthor: Fix the FW reset logic

Geert Uytterhoeven (11):
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2"
  Revert "drm/display: Select DRM_KMS_HELPER for DP helpers"
  Revert "drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable"
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies"
  Revert "drm: Switch DRM_DISPLAY_HDMI_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_HDCP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_AUX_BUS to depends on"
  Revert "drm: Switch DRM_DISPLAY_HELPER to depends on"
  Revert "drm: Make drivers depends on DRM_DW_HDMI"
  Revert "drm/display: Make all helpers visible and switch to 
depends on"


Jocelyn Falempe (1):
  drm/fb_dma: Add checks in drm_fb_dma_get_scanout_buffer()

Luca Ceresoli (1):
  Revert "drm/bridge: ti-sn65dsi83: Fix enable error path"

Masahiro Yamada (1):
  drm: move DRM-related CONFIG options into DRM submenu

Sean Anderson (1):
  drm: zynqmp_dpsub: Always register bridge

Thomas Zimmermann (1):
  drm/fbdev-generic: Do not set physical framebuffer address

 drivers/gpu/drm/Kconfig | 20 +++---
 drivers/gpu/drm/amd/amdgpu/Kconfig  | 12 -
 drivers/gpu/drm/bridge/Kconfig  | 28 ++--
 drivers/gpu/drm/bridge/analogix/Kconfig | 18 ++---
 drivers/gpu/drm/bridge/cadence/Kconfig  |  8 +++---
 drivers/gpu/drm/bridge/imx/Kconfig  |  4 +--
 drivers/gpu/drm/bridge/synopsys/Kconfig |  6 ++---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c   |  1 -
 drivers/gpu/drm/display/Kconfig | 32 +-
 drivers/gpu/drm/drm_fb_dma_helper.c |  3 +++
 drivers/gpu/drm/drm_fbdev_generic.c |  1 -
 drivers/gpu/drm/exynos/Kconfig  |  4 +--
 drivers/gpu/drm/i915/Kconfig|  8 +++---
 drivers/gpu/drm/imx/ipuv3/Kconfig   |  5 ++--
 drivers/gpu/drm/ingenic/Kconfig |  2 +-
 drivers/gpu/drm/mediatek/Kconfig|  6 ++---
 drivers/gpu/drm/meson/Kconfig   |  2 +-
 drivers/gpu/drm/msm/Kconfig |  8 +++---
 drivers/gpu/drm/nouveau/Kconfig | 10 +++
 drivers/gpu/drm/panel/Kconfig   | 32 +++---
 drivers/gpu/drm/panthor/panthor_fw.c|  7 ++---
 drivers/gpu/drm/panthor/panthor_sched.c | 47 
++---

 drivers/gpu/drm/radeon/Kconfig  |  8 +++---
 drivers/gpu/drm/renesas/rcar-du/Kconfig |  2 +-
 drivers/gpu/drm/rockchip/Kconfig| 10 +++
 drivers/gpu/drm/sun4i/Kconfig   |  2 +-
 drivers/gpu/drm/tegra/Kconfig   |  8 +++---
 drivers/gpu/drm/vc4/Kconfig | 10 +++
 drivers/gpu/drm/xe/Kconfig  | 13 -
 drivers/gpu/drm/xlnx/Kconfig|  8 +++---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c |  7 +++--
 31 files changed, 172 insertions(+), 160 deletions(-)


[PULL] drm-misc-next-fixes

2024-05-08 Thread Maarten Lankhorst

Hi Dave, Sima,

drm-misc-next-fixes for v6.10-rc1.

There was some discussion on certain cherry picks I did,
specifically the one for hiding fbdev address. There is some potential
to cause regressions on ARM by hiding the physical address, but I think 
it should be fine to move ahead. This is why a pull request didn't make 
it in time last week.


Hope the extra time at least gave more chance of detection of potential 
regressions.


Cheers,
Maarten

drm-misc-next-fixes-2024-05-08:
drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.
The following changes since commit 4a56c0ed5aa0bcbe1f5f7d755fb1fe1ebf48ae9c:

  Merge tag 'amd-drm-next-6.10-2024-04-26' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-next (2024-04-30 
14:43:00 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-08


for you to fetch changes up to be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)


drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.


Boris Brezillon (3):
  drm/panthor: Kill the faulty_slots variable in 
panthor_sched_suspend()

  drm/panthor: Make sure we handle 'unknown group state' case properly
  drm/panthor: Fix the FW reset logic

Geert Uytterhoeven (11):
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2"
  Revert "drm/display: Select DRM_KMS_HELPER for DP helpers"
  Revert "drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable"
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies"
  Revert "drm: Switch DRM_DISPLAY_HDMI_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_HDCP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_AUX_BUS to depends on"
  Revert "drm: Switch DRM_DISPLAY_HELPER to depends on"
  Revert "drm: Make drivers depends on DRM_DW_HDMI"
  Revert "drm/display: Make all helpers visible and switch to 
depends on"


Jocelyn Falempe (1):
  drm/fb_dma: Add checks in drm_fb_dma_get_scanout_buffer()

Luca Ceresoli (1):
  Revert "drm/bridge: ti-sn65dsi83: Fix enable error path"

Masahiro Yamada (1):
  drm: move DRM-related CONFIG options into DRM submenu

Sean Anderson (1):
  drm: zynqmp_dpsub: Always register bridge

Thomas Zimmermann (1):
  drm/fbdev-generic: Do not set physical framebuffer address

 drivers/gpu/drm/Kconfig | 20 +++---
 drivers/gpu/drm/amd/amdgpu/Kconfig  | 12 -
 drivers/gpu/drm/bridge/Kconfig  | 28 ++--
 drivers/gpu/drm/bridge/analogix/Kconfig | 18 ++---
 drivers/gpu/drm/bridge/cadence/Kconfig  |  8 +++---
 drivers/gpu/drm/bridge/imx/Kconfig  |  4 +--
 drivers/gpu/drm/bridge/synopsys/Kconfig |  6 ++---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c   |  1 -
 drivers/gpu/drm/display/Kconfig | 32 +-
 drivers/gpu/drm/drm_fb_dma_helper.c |  3 +++
 drivers/gpu/drm/drm_fbdev_generic.c |  1 -
 drivers/gpu/drm/exynos/Kconfig  |  4 +--
 drivers/gpu/drm/i915/Kconfig|  8 +++---
 drivers/gpu/drm/imx/ipuv3/Kconfig   |  5 ++--
 drivers/gpu/drm/ingenic/Kconfig |  2 +-
 drivers/gpu/drm/mediatek/Kconfig|  6 ++---
 drivers/gpu/drm/meson/Kconfig   |  2 +-
 drivers/gpu/drm/msm/Kconfig |  8 +++---
 drivers/gpu/drm/nouveau/Kconfig | 10 +++
 drivers/gpu/drm/panel/Kconfig   | 32 +++---
 drivers/gpu/drm/panthor/panthor_fw.c|  7 ++---
 drivers/gpu/drm/panthor/panthor_sched.c | 47 
++---

 drivers/gpu/drm/radeon/Kconfig  |  8 +++---
 drivers/gpu/drm/renesas/rcar-du/Kconfig |  2 +-
 drivers/gpu/drm/rockchip/Kconfig| 10 +++
 drivers/gpu/drm/sun4i/Kconfig   |  2 +-
 drivers/gpu/drm/tegra/Kconfig   |  8 +++---
 drivers/gpu/drm/vc4/Kconfig | 10 +++
 drivers/gpu/drm/xe/Kconfig  | 13 -
 drivers/gpu/drm/xlnx/Kconfig|  8 +++---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c |  7 +++--
 31 files changed, 172 insertions(+), 160 deletions(-)


[PULL] drm-misc-next-fixes

2024-05-08 Thread Maarten Lankhorst

Hi Dave, Sima,

drm-misc-next-fixes for v6.10-rc1.

There was some discussion on certain cherry picks I did,
specifically the one for hiding fbdev address. There is some potential
to cause regressions on ARM by hiding the physical address, but I think 
it should be fine to move ahead. This is why a pull request didn't make 
it in time last week.


Hope the extra time at least gave more chance of detection of potential 
regressions.


Cheers,
Maarten

drm-misc-next-fixes-2024-05-08:
drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.
The following changes since commit 4a56c0ed5aa0bcbe1f5f7d755fb1fe1ebf48ae9c:

  Merge tag 'amd-drm-next-6.10-2024-04-26' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-next (2024-04-30 
14:43:00 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-05-08


for you to fetch changes up to be3f3042391d061cfca2bd22630e0d101acea5fc:

  drm: zynqmp_dpsub: Always register bridge (2024-05-02 23:40:56 +0200)


drm-misc-next-fixes for v6.10-rc1:
- panthor fixes.
- Reverting Kconfig changes, and moving drm options to submenu.
- Hide physical fb address in fb helper.
- zynqmp bridge fix.
- Revert broken ti-sn65dsi83 fix.


Boris Brezillon (3):
  drm/panthor: Kill the faulty_slots variable in 
panthor_sched_suspend()

  drm/panthor: Make sure we handle 'unknown group state' case properly
  drm/panthor: Fix the FW reset logic

Geert Uytterhoeven (11):
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2"
  Revert "drm/display: Select DRM_KMS_HELPER for DP helpers"
  Revert "drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable"
  Revert "drm: fix DRM_DISPLAY_DP_HELPER dependencies"
  Revert "drm: Switch DRM_DISPLAY_HDMI_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_HDCP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_HELPER to depends on"
  Revert "drm: Switch DRM_DISPLAY_DP_AUX_BUS to depends on"
  Revert "drm: Switch DRM_DISPLAY_HELPER to depends on"
  Revert "drm: Make drivers depends on DRM_DW_HDMI"
  Revert "drm/display: Make all helpers visible and switch to 
depends on"


Jocelyn Falempe (1):
  drm/fb_dma: Add checks in drm_fb_dma_get_scanout_buffer()

Luca Ceresoli (1):
  Revert "drm/bridge: ti-sn65dsi83: Fix enable error path"

Masahiro Yamada (1):
  drm: move DRM-related CONFIG options into DRM submenu

Sean Anderson (1):
  drm: zynqmp_dpsub: Always register bridge

Thomas Zimmermann (1):
  drm/fbdev-generic: Do not set physical framebuffer address

 drivers/gpu/drm/Kconfig | 20 +++---
 drivers/gpu/drm/amd/amdgpu/Kconfig  | 12 -
 drivers/gpu/drm/bridge/Kconfig  | 28 ++--
 drivers/gpu/drm/bridge/analogix/Kconfig | 18 ++---
 drivers/gpu/drm/bridge/cadence/Kconfig  |  8 +++---
 drivers/gpu/drm/bridge/imx/Kconfig  |  4 +--
 drivers/gpu/drm/bridge/synopsys/Kconfig |  6 ++---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c   |  1 -
 drivers/gpu/drm/display/Kconfig | 32 +-
 drivers/gpu/drm/drm_fb_dma_helper.c |  3 +++
 drivers/gpu/drm/drm_fbdev_generic.c |  1 -
 drivers/gpu/drm/exynos/Kconfig  |  4 +--
 drivers/gpu/drm/i915/Kconfig|  8 +++---
 drivers/gpu/drm/imx/ipuv3/Kconfig   |  5 ++--
 drivers/gpu/drm/ingenic/Kconfig |  2 +-
 drivers/gpu/drm/mediatek/Kconfig|  6 ++---
 drivers/gpu/drm/meson/Kconfig   |  2 +-
 drivers/gpu/drm/msm/Kconfig |  8 +++---
 drivers/gpu/drm/nouveau/Kconfig | 10 +++
 drivers/gpu/drm/panel/Kconfig   | 32 +++---
 drivers/gpu/drm/panthor/panthor_fw.c|  7 ++---
 drivers/gpu/drm/panthor/panthor_sched.c | 47 
++---

 drivers/gpu/drm/radeon/Kconfig  |  8 +++---
 drivers/gpu/drm/renesas/rcar-du/Kconfig |  2 +-
 drivers/gpu/drm/rockchip/Kconfig| 10 +++
 drivers/gpu/drm/sun4i/Kconfig   |  2 +-
 drivers/gpu/drm/tegra/Kconfig   |  8 +++---
 drivers/gpu/drm/vc4/Kconfig | 10 +++
 drivers/gpu/drm/xe/Kconfig  | 13 -
 drivers/gpu/drm/xlnx/Kconfig|  8 +++---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c |  7 +++--
 31 files changed, 172 insertions(+), 160 deletions(-)


[PATCH v4 4/4] drm/xe/display: Re-use display vmas when possible

2024-05-06 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  8 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index b083b985d170..ee82f4b6abbc 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1123,7 +1123,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 2118b87ccb10..dab938566c94 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -761,7 +761,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index be095cc696ba..24bcaea53f0b 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -234,7 +234,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index bda702c2cab8..2d5bf26b2aad 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -695,3 +695,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 08de2d5b3433..24a3434558cb 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -17,6 +17,8 @@ struct intel_framebuffer;
 void intel_fbdev_setup(struct drm_i915_private *dev_priv);
 void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool 
synchronous);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline void intel_fbdev_setup(struct drm_i915_private *dev_priv)
 {
@@ -30,6 +32,12 @@ static inline struct intel_framebuffer 
*intel_fbdev_framebuffer(struct intel_fbd
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h 
b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
index a20d2638ea7a..193382f97823 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
+++ b/drivers/gpu/drm/xe/compat-

[PATCH v4 3/4] drm/xe: Use simple xchg to cache DPT

2024-05-06 Thread Maarten Lankhorst
Preallocate a DPT when creating the FB, and store it in
i915_address_space. This can be used to prevent an expensive
allocation in the pinning path.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 5a8d6857fb89..6ebda3ded8b4 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -112,9 +112,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -152,10 +154,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -171,17 +174,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -237,7 +240,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -399,14 +402,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -433,7 +436,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -455,7 +458,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -465,10 +468,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[PATCH v4 2/4] drm/xe/display: Preparations for preallocating dpt bo

2024-05-06 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3e1ae37c4c8b..5a8d6857fb89 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -77,47 +77,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_pm_runtime_get_noresume(xe);
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_pm_runtime_put(xe);
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
+{
+   struct xe

[PATCH v4 1/4] drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen

2024-05-06 Thread Maarten Lankhorst
This is invalid with display code when reworking DPT pinning.
The only reason we added it, was because originally all display
allocations also had the bit set.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c 
b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index f77367329760..1613290b9eda 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -298,10 +298,6 @@ static int __xe_ttm_stolen_io_mem_reserve_stolen(struct 
xe_device *xe,
 
XE_WARN_ON(IS_DGFX(xe));
 
-   /* XXX: Require BO to be mapped to GGTT? */
-   if (drm_WARN_ON(>drm, !(bo->flags & XE_BO_FLAG_GGTT)))
-   return -EIO;
-
/* GGTT is always contiguously mapped */
mem->bus.offset = xe_bo_ggtt_addr(bo) + mgr->io_base;
 
-- 
2.43.0



[PATCH v4 0/4] drm/xe: More fb pinning optimizations.

2024-05-06 Thread Maarten Lankhorst
This reduces the latency of pinning framebuffers by
re-using the previous mapping, if available.

Additionally, DPT is preallocated when creating the FB, instead
of performing a bo allocation on every pin.

No changes since v3, just a rebase from conflicts.

Maarten Lankhorst (4):
  drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen
  drm/xe/display: Preparations for preallocating dpt bo
  drm/xe: Use simple xchg to cache DPT
  drm/xe/display: Re-use display vmas when possible

 .../gpu/drm/i915/display/intel_atomic_plane.c |   2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |   2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |   3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|   5 +
 drivers/gpu/drm/i915/display/intel_fbdev.h|   8 +
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |   3 +
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 220 ++
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c|   4 -
 9 files changed, 197 insertions(+), 53 deletions(-)

-- 
2.43.0



Re: [RFC PATCH 00/18] TTM interface for managing VRAM oversubscription

2024-05-02 Thread Maarten Lankhorst

Hey,

Den 2024-04-24 kl. 18:56, skrev Friedrich Vock:

Hi everyone,

recently I've been looking into remedies for apps (in particular, newer
games) that experience significant performance loss when they start to
hit VRAM limits, especially on older or lower-end cards that struggle
to fit both desktop apps and all the game data into VRAM at once.

The root of the problem lies in the fact that from userspace's POV,
buffer eviction is very opaque: Userspace applications/drivers cannot
tell how oversubscribed VRAM is, nor do they have fine-grained control
over which buffers get evicted.  At the same time, with GPU APIs becoming
increasingly lower-level and GPU-driven, only the application itself
can know which buffers are used within a particular submission, and
how important each buffer is. For this, GPU APIs include interfaces
to query oversubscription and specify memory priorities: In Vulkan,
oversubscription can be queried through the VK_EXT_memory_budget
extension. Different buffers can also be assigned priorities via the
VK_EXT_pageable_device_local_memory extension. Modern games, especially
D3D12 games via vkd3d-proton, rely on oversubscription being reported and
priorities being respected in order to perform their memory management.

However, relaying this information to the kernel via the current KMD uAPIs
is not possible. On AMDGPU for example, all work submissions include a
"bo list" that contains any buffer object that is accessed during the
course of the submission. If VRAM is oversubscribed and a buffer in the
list was evicted to system memory, that buffer is moved back to VRAM
(potentially evicting other unused buffers).

Since the usermode driver doesn't know what buffers are used by the
application, its only choice is to submit a bo list that contains every
buffer the application has allocated. In case of VRAM oversubscription,
it is highly likely that some of the application's buffers were evicted,
which almost guarantees that some buffers will get moved around. Since
the bo list is only known at submit time, this also means the buffers
will get moved right before submitting application work, which is the
worst possible time to move buffers from a latency perspective. Another
consequence of the large bo list is that nearly all memory from other
applications will be evicted, too. When different applications (e.g. game
and compositor) submit work one after the other, this causes a ping-pong
effect where each app's submission evicts the other app's memory,
resulting in a large amount of unnecessary moves.

This overly aggressive eviction behavior led to RADV adopting a change
that effectively allows all VRAM applications to reside in system memory
[1].  This worked around the ping-ponging/excessive buffer moving problem,
but also meant that any memory evicted to system memory would forever
stay there, regardless of how VRAM is used.

My proposal aims at providing a middle ground between these extremes.
The goals I want to meet are:
- Userspace is accurately informed about VRAM oversubscription/how much
   VRAM has been evicted
- Buffer eviction respects priorities set by userspace - Wasteful
   ping-ponging is avoided to the extent possible

I have been testing out some prototypes, and came up with this rough
sketch of an API:

- For each ttm_resource_manager, the amount of evicted memory is tracked
   (similarly to how "usage" tracks the memory usage). When memory is
   evicted via ttm_bo_evict, the size of the evicted memory is added, when
   memory is un-evicted (see below), its size is subtracted. The amount of
   evicted memory for e.g. VRAM can be queried by userspace via an ioctl.

- Each ttm_resource_manager maintains a list of evicted buffer objects.

- ttm_mem_unevict walks the list of evicted bos for a given
   ttm_resource_manager and tries moving evicted resources back. When a
   buffer is freed, this function is called to immediately restore some
   evicted memory.

- Each ttm_buffer_object independently tracks the mem_type it wants
   to reside in.

- ttm_bo_try_unevict is added as a helper function which attempts to
   move the buffer to its preferred mem_type. If no space is available
   there, it fails with -ENOSPC/-ENOMEM.

- Similar to how ttm_bo_evict works, each driver can implement
   uneviction_valuable/unevict_flags callbacks to control buffer
   un-eviction.

This is what patches 1-10 accomplish (together with an amdgpu
implementation utilizing the new API).

Userspace priorities could then be implemented as follows:

- TTM already manages priorities for each buffer object. These priorities
   can be updated by userspace via a GEM_OP ioctl to inform the kernel
   which buffers should be evicted before others. If an ioctl increases
   the priority of a buffer, ttm_bo_try_unevict is called on that buffer to
   try and move it back (potentially evicting buffers with a lower
   priority)

- Buffers should never be evicted by other buffers with equal/lower
   priority, but 

Re: [RFC PATCH 00/18] TTM interface for managing VRAM oversubscription

2024-05-02 Thread Maarten Lankhorst

Hey,

Den 2024-04-24 kl. 18:56, skrev Friedrich Vock:

Hi everyone,

recently I've been looking into remedies for apps (in particular, newer
games) that experience significant performance loss when they start to
hit VRAM limits, especially on older or lower-end cards that struggle
to fit both desktop apps and all the game data into VRAM at once.

The root of the problem lies in the fact that from userspace's POV,
buffer eviction is very opaque: Userspace applications/drivers cannot
tell how oversubscribed VRAM is, nor do they have fine-grained control
over which buffers get evicted.  At the same time, with GPU APIs becoming
increasingly lower-level and GPU-driven, only the application itself
can know which buffers are used within a particular submission, and
how important each buffer is. For this, GPU APIs include interfaces
to query oversubscription and specify memory priorities: In Vulkan,
oversubscription can be queried through the VK_EXT_memory_budget
extension. Different buffers can also be assigned priorities via the
VK_EXT_pageable_device_local_memory extension. Modern games, especially
D3D12 games via vkd3d-proton, rely on oversubscription being reported and
priorities being respected in order to perform their memory management.

However, relaying this information to the kernel via the current KMD uAPIs
is not possible. On AMDGPU for example, all work submissions include a
"bo list" that contains any buffer object that is accessed during the
course of the submission. If VRAM is oversubscribed and a buffer in the
list was evicted to system memory, that buffer is moved back to VRAM
(potentially evicting other unused buffers).

Since the usermode driver doesn't know what buffers are used by the
application, its only choice is to submit a bo list that contains every
buffer the application has allocated. In case of VRAM oversubscription,
it is highly likely that some of the application's buffers were evicted,
which almost guarantees that some buffers will get moved around. Since
the bo list is only known at submit time, this also means the buffers
will get moved right before submitting application work, which is the
worst possible time to move buffers from a latency perspective. Another
consequence of the large bo list is that nearly all memory from other
applications will be evicted, too. When different applications (e.g. game
and compositor) submit work one after the other, this causes a ping-pong
effect where each app's submission evicts the other app's memory,
resulting in a large amount of unnecessary moves.

This overly aggressive eviction behavior led to RADV adopting a change
that effectively allows all VRAM applications to reside in system memory
[1].  This worked around the ping-ponging/excessive buffer moving problem,
but also meant that any memory evicted to system memory would forever
stay there, regardless of how VRAM is used.

My proposal aims at providing a middle ground between these extremes.
The goals I want to meet are:
- Userspace is accurately informed about VRAM oversubscription/how much
   VRAM has been evicted
- Buffer eviction respects priorities set by userspace - Wasteful
   ping-ponging is avoided to the extent possible

I have been testing out some prototypes, and came up with this rough
sketch of an API:

- For each ttm_resource_manager, the amount of evicted memory is tracked
   (similarly to how "usage" tracks the memory usage). When memory is
   evicted via ttm_bo_evict, the size of the evicted memory is added, when
   memory is un-evicted (see below), its size is subtracted. The amount of
   evicted memory for e.g. VRAM can be queried by userspace via an ioctl.

- Each ttm_resource_manager maintains a list of evicted buffer objects.

- ttm_mem_unevict walks the list of evicted bos for a given
   ttm_resource_manager and tries moving evicted resources back. When a
   buffer is freed, this function is called to immediately restore some
   evicted memory.

- Each ttm_buffer_object independently tracks the mem_type it wants
   to reside in.

- ttm_bo_try_unevict is added as a helper function which attempts to
   move the buffer to its preferred mem_type. If no space is available
   there, it fails with -ENOSPC/-ENOMEM.

- Similar to how ttm_bo_evict works, each driver can implement
   uneviction_valuable/unevict_flags callbacks to control buffer
   un-eviction.

This is what patches 1-10 accomplish (together with an amdgpu
implementation utilizing the new API).

Userspace priorities could then be implemented as follows:

- TTM already manages priorities for each buffer object. These priorities
   can be updated by userspace via a GEM_OP ioctl to inform the kernel
   which buffers should be evicted before others. If an ioctl increases
   the priority of a buffer, ttm_bo_try_unevict is called on that buffer to
   try and move it back (potentially evicting buffers with a lower
   priority)

- Buffers should never be evicted by other buffers with equal/lower
   priority, but 

[PULL] drm-misc-next

2024-04-25 Thread Maarten Lankhorst

Hi Dave, Sima,

One more pull request for v6.10!

Cheers,
~Maarten

drm-misc-next-2024-04-25:
drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.
The following changes since commit 0208ca55aa9c9b997da1f5bc45c4e98916323f08:

  Backmerge tag 'v6.9-rc5' into drm-next (2024-04-22 14:35:52 +1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-25


for you to fetch changes up to 9e2b84fb6cd7ee913aa61d461db65c1d6a08dcf2:

  drm/print: drop include seq_file.h (2024-04-25 17:05:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.


Adam Ford (1):
  drm/bridge: imx: Fix unmet depenency for PHY_FSL_SAMSUNG_HDMI_PHY

Anatoliy Klymenko (6):
  drm: xlnx: zynqmp_dpsub: Set layer mode during creation
  drm: xlnx: zynqmp_dpsub: Update live format defines
  drm: xlnx: zynqmp_dpsub: Add connected live layer helper
  drm: xlnx: zynqmp_dpsub: Anounce supported input formats
  drm: xlnx: zynqmp_dpsub: Minimize usage of global flag
  drm: xlnx: zynqmp_dpsub: Set input live format

Andy Yan (1):
  drm/rockchip: lvds: Remove include of drm_dp_helper.h

Arunpravin Paneer Selvam (3):
  drm/buddy: Implement tracking clear page feature
  drm/amdgpu: Enable clear page functionality
  drm/tests: Add a test case for drm buddy clear allocation

Barnabás Czémán (1):
  drm/panel: jdi-fhd-r63452: make use of prepare_prev_first

Dan Carpenter (1):
  drm/panthor: clean up some types in panthor_sched_suspend()

David Wronek (2):
  dt-bindings: display: panel: Add Raydium RM69380
  drm/panel: Add driver for EDO RM69380 OLED panel

Detlev Casanova (1):
  drm/rockchip: vop2: Do not divide height twice for YUV

Dharma Balasubiramani (3):
  dt-bindings: display: bridge: add sam9x75-lvds binding
  drm/bridge: add lvds controller support for sam9x7
  MAINTAINERS: add SAM9X7 SoC's LVDS controller

Dmitry Baryshkov (5):
  drm/panel: novatek-nt36672e: stop setting register load before 
disable

  drm/panel: novatek-nt36672e: stop calling regulator_set_load manually
  drm/panel: novatek-nt36672a: stop calling regulator_set_load manually
  drm/panel: visionox-rm69299: stop calling regulator_set_load manually
  drm/bridge: adv7511: make it honour next bridge in DT

Jacobe Zang (2):
  dt-bindings: panel-simple-dsi: add Khadas TS050 V2 panel
  drm/panel: add Khadas TS050 V2 panel support

Jani Nikula (11):
  drm/panel: simple: switch to struct drm_edid
  drm/panel-samsung-atna33xc20: switch to struct drm_edid
  drm/panel-edp: switch to struct drm_edid
  drm/sun4i: hdmi: switch to struct drm_edid
  drm/vc4: hdmi: switch to struct drm_edid
  drm/gud: switch to struct drm_edid
  drm/rockchip: cdn-dp: switch to struct drm_edid
  drm/rockchip: inno_hdmi: switch to struct drm_edid
  drm/rockchip: rk3066_hdmi: switch to struct drm_edid
  drm/print: drop include debugfs.h and include where needed
  drm/print: drop include seq_file.h

Johan Jonker (3):
  dt-bindings: display: add #sound-dai-cells property to rockchip 
dw hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
rk3066 hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
inno hdmi


Krzysztof Kozlowski (3):
  drm/rockchip: cdn-dp: drop driver owner assignment
  drm/bridge: chipone-icn6211: drop driver owner assignment
  drm/bridge: tc358764: drop driver owner 

[PULL] drm-misc-next

2024-04-25 Thread Maarten Lankhorst

Hi Dave, Sima,

One more pull request for v6.10!

Cheers,
~Maarten

drm-misc-next-2024-04-25:
drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.
The following changes since commit 0208ca55aa9c9b997da1f5bc45c4e98916323f08:

  Backmerge tag 'v6.9-rc5' into drm-next (2024-04-22 14:35:52 +1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-25


for you to fetch changes up to 9e2b84fb6cd7ee913aa61d461db65c1d6a08dcf2:

  drm/print: drop include seq_file.h (2024-04-25 17:05:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.


Adam Ford (1):
  drm/bridge: imx: Fix unmet depenency for PHY_FSL_SAMSUNG_HDMI_PHY

Anatoliy Klymenko (6):
  drm: xlnx: zynqmp_dpsub: Set layer mode during creation
  drm: xlnx: zynqmp_dpsub: Update live format defines
  drm: xlnx: zynqmp_dpsub: Add connected live layer helper
  drm: xlnx: zynqmp_dpsub: Anounce supported input formats
  drm: xlnx: zynqmp_dpsub: Minimize usage of global flag
  drm: xlnx: zynqmp_dpsub: Set input live format

Andy Yan (1):
  drm/rockchip: lvds: Remove include of drm_dp_helper.h

Arunpravin Paneer Selvam (3):
  drm/buddy: Implement tracking clear page feature
  drm/amdgpu: Enable clear page functionality
  drm/tests: Add a test case for drm buddy clear allocation

Barnabás Czémán (1):
  drm/panel: jdi-fhd-r63452: make use of prepare_prev_first

Dan Carpenter (1):
  drm/panthor: clean up some types in panthor_sched_suspend()

David Wronek (2):
  dt-bindings: display: panel: Add Raydium RM69380
  drm/panel: Add driver for EDO RM69380 OLED panel

Detlev Casanova (1):
  drm/rockchip: vop2: Do not divide height twice for YUV

Dharma Balasubiramani (3):
  dt-bindings: display: bridge: add sam9x75-lvds binding
  drm/bridge: add lvds controller support for sam9x7
  MAINTAINERS: add SAM9X7 SoC's LVDS controller

Dmitry Baryshkov (5):
  drm/panel: novatek-nt36672e: stop setting register load before 
disable

  drm/panel: novatek-nt36672e: stop calling regulator_set_load manually
  drm/panel: novatek-nt36672a: stop calling regulator_set_load manually
  drm/panel: visionox-rm69299: stop calling regulator_set_load manually
  drm/bridge: adv7511: make it honour next bridge in DT

Jacobe Zang (2):
  dt-bindings: panel-simple-dsi: add Khadas TS050 V2 panel
  drm/panel: add Khadas TS050 V2 panel support

Jani Nikula (11):
  drm/panel: simple: switch to struct drm_edid
  drm/panel-samsung-atna33xc20: switch to struct drm_edid
  drm/panel-edp: switch to struct drm_edid
  drm/sun4i: hdmi: switch to struct drm_edid
  drm/vc4: hdmi: switch to struct drm_edid
  drm/gud: switch to struct drm_edid
  drm/rockchip: cdn-dp: switch to struct drm_edid
  drm/rockchip: inno_hdmi: switch to struct drm_edid
  drm/rockchip: rk3066_hdmi: switch to struct drm_edid
  drm/print: drop include debugfs.h and include where needed
  drm/print: drop include seq_file.h

Johan Jonker (3):
  dt-bindings: display: add #sound-dai-cells property to rockchip 
dw hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
rk3066 hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
inno hdmi


Krzysztof Kozlowski (3):
  drm/rockchip: cdn-dp: drop driver owner assignment
  drm/bridge: chipone-icn6211: drop driver owner assignment
  drm/bridge: tc358764: drop driver owner 

[PULL] drm-misc-next

2024-04-25 Thread Maarten Lankhorst

Hi Dave, Sima,

One more pull request for v6.10!

Cheers,
~Maarten

drm-misc-next-2024-04-25:
drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.
The following changes since commit 0208ca55aa9c9b997da1f5bc45c4e98916323f08:

  Backmerge tag 'v6.9-rc5' into drm-next (2024-04-22 14:35:52 +1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-25


for you to fetch changes up to 9e2b84fb6cd7ee913aa61d461db65c1d6a08dcf2:

  drm/print: drop include seq_file.h (2024-04-25 17:05:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:

Cross-subsystem Changes:
- Devicetree updates for rockchip (#sound-dai-cells)
- Add dt bindings for new panels.
- Change bridge/tc358775 dt bindings.

Core Changes:
- Fix SIZE_HINTS cursor property doc.
- Parse topology blocks for all DispID < 2.0.
- Implement support for tracking cleared free memory, use it in amdgpu.
- Drop seq_file.h from drm_print.h, and include debugfs.h explicitly
  where needed (drivers).

Driver Changes:
- Small fixes to rockchip, panthor, v3d, bridge chaining, xlx.
- Add Khadas TS050 V2, EDO RM69380 OLED, CSOT MNB601LS1-1 panels,
- Add SAM9X7 SoC's LVDS controller.
- More driver conversions to struct drm_edid.
- Support tc358765 in tc358775 bridge.


Adam Ford (1):
  drm/bridge: imx: Fix unmet depenency for PHY_FSL_SAMSUNG_HDMI_PHY

Anatoliy Klymenko (6):
  drm: xlnx: zynqmp_dpsub: Set layer mode during creation
  drm: xlnx: zynqmp_dpsub: Update live format defines
  drm: xlnx: zynqmp_dpsub: Add connected live layer helper
  drm: xlnx: zynqmp_dpsub: Anounce supported input formats
  drm: xlnx: zynqmp_dpsub: Minimize usage of global flag
  drm: xlnx: zynqmp_dpsub: Set input live format

Andy Yan (1):
  drm/rockchip: lvds: Remove include of drm_dp_helper.h

Arunpravin Paneer Selvam (3):
  drm/buddy: Implement tracking clear page feature
  drm/amdgpu: Enable clear page functionality
  drm/tests: Add a test case for drm buddy clear allocation

Barnabás Czémán (1):
  drm/panel: jdi-fhd-r63452: make use of prepare_prev_first

Dan Carpenter (1):
  drm/panthor: clean up some types in panthor_sched_suspend()

David Wronek (2):
  dt-bindings: display: panel: Add Raydium RM69380
  drm/panel: Add driver for EDO RM69380 OLED panel

Detlev Casanova (1):
  drm/rockchip: vop2: Do not divide height twice for YUV

Dharma Balasubiramani (3):
  dt-bindings: display: bridge: add sam9x75-lvds binding
  drm/bridge: add lvds controller support for sam9x7
  MAINTAINERS: add SAM9X7 SoC's LVDS controller

Dmitry Baryshkov (5):
  drm/panel: novatek-nt36672e: stop setting register load before 
disable

  drm/panel: novatek-nt36672e: stop calling regulator_set_load manually
  drm/panel: novatek-nt36672a: stop calling regulator_set_load manually
  drm/panel: visionox-rm69299: stop calling regulator_set_load manually
  drm/bridge: adv7511: make it honour next bridge in DT

Jacobe Zang (2):
  dt-bindings: panel-simple-dsi: add Khadas TS050 V2 panel
  drm/panel: add Khadas TS050 V2 panel support

Jani Nikula (11):
  drm/panel: simple: switch to struct drm_edid
  drm/panel-samsung-atna33xc20: switch to struct drm_edid
  drm/panel-edp: switch to struct drm_edid
  drm/sun4i: hdmi: switch to struct drm_edid
  drm/vc4: hdmi: switch to struct drm_edid
  drm/gud: switch to struct drm_edid
  drm/rockchip: cdn-dp: switch to struct drm_edid
  drm/rockchip: inno_hdmi: switch to struct drm_edid
  drm/rockchip: rk3066_hdmi: switch to struct drm_edid
  drm/print: drop include debugfs.h and include where needed
  drm/print: drop include seq_file.h

Johan Jonker (3):
  dt-bindings: display: add #sound-dai-cells property to rockchip 
dw hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
rk3066 hdmi
  dt-bindings: display: add #sound-dai-cells property to rockchip 
inno hdmi


Krzysztof Kozlowski (3):
  drm/rockchip: cdn-dp: drop driver owner assignment
  drm/bridge: chipone-icn6211: drop driver owner assignment
  drm/bridge: tc358764: drop driver owner 

[PATCH 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-04-25 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 25593f6aae7d..7f935c88726e 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -616,6 +629,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[PATCH 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-04-25 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3cebeaa6e8b4 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -674,6 +674,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -817,14 +828,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index b9434465d3a7..bb8983715ad6 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6916,6 +6917,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 62f7a30c37dc..42fa627e7e14 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -730,6 +730,9 @@ struct intel_plane_state {
struct intel_fb_view view;
u32 phys_dma_addr; /* for cursor_needs_physical */
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[PATCH 0/3] drm/i915/display: Unpin cursor worker in vblank worker series.

2024-04-25 Thread Maarten Lankhorst
Use the vblank worker to unpin fb, for the legacy cursor fastpath and atomic 
cursor slowpath.
This prevents pipe fault errors from the cursor plane in Xe.

A small race appears to exist in kms_universal_plane@cursor-fb-leak on dg2, not 
sure why. I tried reproducing it and failed.

Maarten Lankhorst (2):
  drm: Add drm_vblank_work_flush_all().
  drm/i915: Use the same vblank worker for atomic unpin

Ville Syrjälä (1):
  drm/i915: Use vblank worker to unpin old legacy cursor fb safely

 drivers/gpu/drm/drm_vblank_work.c | 22 +
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 ++--
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 drivers/gpu/drm/i915/display/intel_display.c  |  3 ++
 .../drm/i915/display/intel_display_types.h|  3 ++
 include/drm/drm_vblank_work.h |  2 ++
 9 files changed, 102 insertions(+), 3 deletions(-)

-- 
2.43.0



[PATCH 1/3] drm: Add drm_vblank_work_flush_all().

2024-04-25 Thread Maarten Lankhorst
In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 4fe9b1d3b00f..83a81a5e8280 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   !waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[PATCH v3 4/4] drm/xe/display: Re-use display vmas when possible

2024-04-24 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  9 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..24ba55531e8d 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1106,7 +1106,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3d3b8e37c0f2 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -761,7 +761,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index b6df9baf481b..7b8a1825ccfc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -236,7 +236,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 43855c6c3509..a010b7a8a468 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -668,3 +668,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 04fd523a5023..fa6c0c1ae936 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -22,6 +22,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
 void intel_fbdev_output_poll_changed(struct drm_device *dev);
 void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -51,10 +53,17 @@ static inline void intel_fbdev_output_poll_changed(struct 
drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
 {
 }
+
 static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-

[PATCH v3 3/4] drm/xe: Use simple xchg to cache DPT

2024-04-24 Thread Maarten Lankhorst
Preallocate a DPT when creating the FB, and store it in
i915_address_space. This can be used to prevent an expensive
allocation in the pinning path.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 5a8d6857fb89..6ebda3ded8b4 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -112,9 +112,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -152,10 +154,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -171,17 +174,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -237,7 +240,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -399,14 +402,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -433,7 +436,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -455,7 +458,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -465,10 +468,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[PATCH v3 2/4] drm/xe/display: Preparations for preallocating dpt bo

2024-04-24 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3e1ae37c4c8b..5a8d6857fb89 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -77,47 +77,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_pm_runtime_get_noresume(xe);
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_pm_runtime_put(xe);
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
+{
+   struct xe

[PATCH v3 1/4] drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen

2024-04-24 Thread Maarten Lankhorst
This is invalid with display code when reworking DPT pinning.
The only reason we added it, was because originally all display
allocations also had the bit set.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c 
b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index f77367329760..1613290b9eda 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -298,10 +298,6 @@ static int __xe_ttm_stolen_io_mem_reserve_stolen(struct 
xe_device *xe,
 
XE_WARN_ON(IS_DGFX(xe));
 
-   /* XXX: Require BO to be mapped to GGTT? */
-   if (drm_WARN_ON(>drm, !(bo->flags & XE_BO_FLAG_GGTT)))
-   return -EIO;
-
/* GGTT is always contiguously mapped */
mem->bus.offset = xe_bo_ggtt_addr(bo) + mgr->io_base;
 
-- 
2.43.0



[PATCH v3 0/4] drm/xe: More fb pinning optimizations.

2024-04-24 Thread Maarten Lankhorst
This reduces the latency of pinning framebuffers by
re-using the previous mapping, if available.

Additionally, DPT is preallocated when creating the FB, instead
of performing a bo allocation on every pin.

Remove the safety check in the first patch again, I didn't realize it was
needed even without the initial FB GGTT pinning removal.

Maarten Lankhorst (4):
  drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen
  drm/xe/display: Preparations for preallocating dpt bo
  drm/xe: Use simple xchg to cache DPT
  drm/xe/display: Re-use display vmas when possible

 .../gpu/drm/i915/display/intel_atomic_plane.c |   2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |   2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |   3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|   5 +
 drivers/gpu/drm/i915/display/intel_fbdev.h|   9 +
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |   3 +
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 220 ++
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c|   4 -
 9 files changed, 198 insertions(+), 53 deletions(-)

-- 
2.43.0



[PATCH v2 1/3] drm/xe/display: Preparations for preallocating dpt bo

2024-04-23 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3e1ae37c4c8b..5a8d6857fb89 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -77,47 +77,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_pm_runtime_get_noresume(xe);
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_pm_runtime_put(xe);
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
+{
+   struct xe

[PATCH v2 2/3] drm/xe: Use simple xchg to cache DPT

2024-04-23 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 5a8d6857fb89..6ebda3ded8b4 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -112,9 +112,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -152,10 +154,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -171,17 +174,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -237,7 +240,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -399,14 +402,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -433,7 +436,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -455,7 +458,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -465,10 +468,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[PATCH v2 2/3] drm/xe: Use simple xchg to cache DPT

2024-04-23 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 5a8d6857fb89..6ebda3ded8b4 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -112,9 +112,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -152,10 +154,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -171,17 +174,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -237,7 +240,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -399,14 +402,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -433,7 +436,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -455,7 +458,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -465,10 +468,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[PATCH v2 1/3] drm/xe/display: Preparations for preallocating dpt bo

2024-04-23 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3e1ae37c4c8b..5a8d6857fb89 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -77,47 +77,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_pm_runtime_get_noresume(xe);
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_pm_runtime_put(xe);
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
+{
+   struct xe

[PATCH v2 3/3] drm/xe/display: Re-use display vmas when possible

2024-04-23 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  9 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..24ba55531e8d 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1106,7 +1106,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3d3b8e37c0f2 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -761,7 +761,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index b6df9baf481b..7b8a1825ccfc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -236,7 +236,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 43855c6c3509..a010b7a8a468 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -668,3 +668,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 04fd523a5023..fa6c0c1ae936 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -22,6 +22,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
 void intel_fbdev_output_poll_changed(struct drm_device *dev);
 void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -51,10 +53,17 @@ static inline void intel_fbdev_output_poll_changed(struct 
drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
 {
 }
+
 static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-

[PATCH v2 0/3] drm/xe: More fb pinning optimizations.

2024-04-23 Thread Maarten Lankhorst
This reduces the latency of pinning framebuffers by
re-using the previous mapping, if available.

Additionally, DPT is preallocated when creating the FB, instead
of performing a bo allocation on every pin.

Changes since v1:
- Drop the patch to prevent overwriting GGTT, to see if this fixes the test 
results.
  It's not needed for optimizing FB pinning.

Maarten Lankhorst (3):
  drm/xe/display: Preparations for preallocating dpt bo
  drm/xe: Use simple xchg to cache DPT
  drm/xe/display: Re-use display vmas when possible

 .../gpu/drm/i915/display/intel_atomic_plane.c |   2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |   2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |   3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|   5 +
 drivers/gpu/drm/i915/display/intel_fbdev.h|   9 +
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |   3 +
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 220 ++
 8 files changed, 198 insertions(+), 49 deletions(-)

-- 
2.43.0



[PATCH v2 3/3] drm/xe/display: Re-use display vmas when possible

2024-04-23 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  9 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..24ba55531e8d 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1106,7 +1106,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3d3b8e37c0f2 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -761,7 +761,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index b6df9baf481b..7b8a1825ccfc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -236,7 +236,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 43855c6c3509..a010b7a8a468 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -668,3 +668,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 04fd523a5023..fa6c0c1ae936 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -22,6 +22,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
 void intel_fbdev_output_poll_changed(struct drm_device *dev);
 void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -51,10 +53,17 @@ static inline void intel_fbdev_output_poll_changed(struct 
drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
 {
 }
+
 static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-

[PATCH v2 0/3] drm/xe: More fb pinning optimizations.

2024-04-23 Thread Maarten Lankhorst
This reduces the latency of pinning framebuffers by
re-using the previous mapping, if available.

Additionally, DPT is preallocated when creating the FB, instead
of performing a bo allocation on every pin.

Changes since v1:
- Drop the patch to prevent overwriting GGTT, to see if this fixes the test 
results.
  It's not needed for optimizing FB pinning.

Maarten Lankhorst (3):
  drm/xe/display: Preparations for preallocating dpt bo
  drm/xe: Use simple xchg to cache DPT
  drm/xe/display: Re-use display vmas when possible

 .../gpu/drm/i915/display/intel_atomic_plane.c |   2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |   2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |   3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|   5 +
 drivers/gpu/drm/i915/display/intel_fbdev.h|   9 +
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |   3 +
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 220 ++
 8 files changed, 198 insertions(+), 49 deletions(-)

-- 
2.43.0



[PULL] drm-misc-next

2024-04-19 Thread Maarten Lankhorst

Hi Dave, Sima,

Bit late, but with slightly more content.

Cheers,
~Maarten

drm-misc-next-2024-04-19:
drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.
The following changes since commit 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-19


for you to fetch changes up to 069a6c0e94f99437652dbb7229a56233c7d39968:

  drm: panel: Add LG sw43408 panel driver (2024-04-19 04:27:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.


Aleksandr Mishin (1):
  drm: vc4: Fix possible null pointer dereference

Arnd Bergmann (2):
  accel/qaic: mark debugfs stub functions as static inline
  drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2

Baruch Siach (1):
  doc: dma-buf: fix grammar typo

Daniel Vetter (1):
  drm/panic: Add drm panic locking

Dmitry Baryshkov (2):
  drm/mipi-dsi: use correct return type for the DSC functions
  drm/mipi-dsi: add mipi_dsi_compression_mode_ext()

Erico Nunes (5):
  drm/lima: add mask irq callback to gp and pp
  drm/lima: include pp bcast irq in timeout handler check
  drm/lima: mask irqs in timeout path before hard reset
  drm/lima: fix shared irq handling on driver remove
  drm/lima: fix void pointer to enum lima_gpu_id cast warning

Hsin-Te Yuan (1):
  drm/bridge: anx7625: Update audio status while detecting

Huai-Yuan Liu (1):
  drm/arm/malidp: fix a possible null pointer dereference

Jani Nikula (18):
  drm/edid: add drm_edid_get_product_id()
  drm/edid: add drm_edid_print_product_id()
  drm/i915/bios: switch to struct drm_edid and struct 
drm_edid_product_id

  drm/i915/bios: return drm_edid_product_id from get_lvds_pnp_id()
  drm/probe-helper: switch to drm device based logging
  drm/modes: switch to drm device based error logging
  drm/sysfs: switch to drm device based logging
  drm/client: switch to drm device based logging, and more
  drm/crtc: switch to drm device based logging
  drm/crtc-helper: switch to drm device based logging and warns
  drm: prefer DRM_MODE_FMT/ARG over drm_mode_debug_printmodeline()
  drm/displayid: move drm_displayid.h to drm_displayd_internal.h
  drm/edid: move all internal declarations to drm_crtc_internal.h
  drm/edid: group struct drm_edid based declarations together
  drm/edid: rename drm_find_edid_extension() to 
drm_edid_find_extension()

  drm/edid: avoid drm_edid_find_extension() internally
  drm/edid: make drm_edid_are_equal() static
  drm/edid: make drm_edid_are_equal() more convenient for its 
single user


Jeffrey Hugo (1):
  accel/qaic: Add Sahara implementation for firmware loading

Jesse Zhang (1):
  drm/ttm: remove unused paramter

Jocelyn Falempe (9):
  drm/panic: Add a drm panic handler
  drm/panic: Add support for color format conversion
  drm/panic: Add debugfs entry to test without triggering panic.
  drm/fb_dma: Add generic get_scanout_buffer() for drm_panic
  drm/simpledrm: Add drm_panic support
  drm/mgag200: Add drm_panic support
  drm/imx: Add 

[PULL] drm-misc-next

2024-04-19 Thread Maarten Lankhorst

Hi Dave, Sima,

Bit late, but with slightly more content.

Cheers,
~Maarten

drm-misc-next-2024-04-19:
drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.
The following changes since commit 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-19


for you to fetch changes up to 069a6c0e94f99437652dbb7229a56233c7d39968:

  drm: panel: Add LG sw43408 panel driver (2024-04-19 04:27:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.


Aleksandr Mishin (1):
  drm: vc4: Fix possible null pointer dereference

Arnd Bergmann (2):
  accel/qaic: mark debugfs stub functions as static inline
  drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2

Baruch Siach (1):
  doc: dma-buf: fix grammar typo

Daniel Vetter (1):
  drm/panic: Add drm panic locking

Dmitry Baryshkov (2):
  drm/mipi-dsi: use correct return type for the DSC functions
  drm/mipi-dsi: add mipi_dsi_compression_mode_ext()

Erico Nunes (5):
  drm/lima: add mask irq callback to gp and pp
  drm/lima: include pp bcast irq in timeout handler check
  drm/lima: mask irqs in timeout path before hard reset
  drm/lima: fix shared irq handling on driver remove
  drm/lima: fix void pointer to enum lima_gpu_id cast warning

Hsin-Te Yuan (1):
  drm/bridge: anx7625: Update audio status while detecting

Huai-Yuan Liu (1):
  drm/arm/malidp: fix a possible null pointer dereference

Jani Nikula (18):
  drm/edid: add drm_edid_get_product_id()
  drm/edid: add drm_edid_print_product_id()
  drm/i915/bios: switch to struct drm_edid and struct 
drm_edid_product_id

  drm/i915/bios: return drm_edid_product_id from get_lvds_pnp_id()
  drm/probe-helper: switch to drm device based logging
  drm/modes: switch to drm device based error logging
  drm/sysfs: switch to drm device based logging
  drm/client: switch to drm device based logging, and more
  drm/crtc: switch to drm device based logging
  drm/crtc-helper: switch to drm device based logging and warns
  drm: prefer DRM_MODE_FMT/ARG over drm_mode_debug_printmodeline()
  drm/displayid: move drm_displayid.h to drm_displayd_internal.h
  drm/edid: move all internal declarations to drm_crtc_internal.h
  drm/edid: group struct drm_edid based declarations together
  drm/edid: rename drm_find_edid_extension() to 
drm_edid_find_extension()

  drm/edid: avoid drm_edid_find_extension() internally
  drm/edid: make drm_edid_are_equal() static
  drm/edid: make drm_edid_are_equal() more convenient for its 
single user


Jeffrey Hugo (1):
  accel/qaic: Add Sahara implementation for firmware loading

Jesse Zhang (1):
  drm/ttm: remove unused paramter

Jocelyn Falempe (9):
  drm/panic: Add a drm panic handler
  drm/panic: Add support for color format conversion
  drm/panic: Add debugfs entry to test without triggering panic.
  drm/fb_dma: Add generic get_scanout_buffer() for drm_panic
  drm/simpledrm: Add drm_panic support
  drm/mgag200: Add drm_panic support
  drm/imx: Add 

[PULL] drm-misc-next

2024-04-19 Thread Maarten Lankhorst

Hi Dave, Sima,

Bit late, but with slightly more content.

Cheers,
~Maarten

drm-misc-next-2024-04-19:
drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.
The following changes since commit 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-19


for you to fetch changes up to 069a6c0e94f99437652dbb7229a56233c7d39968:

  drm: panel: Add LG sw43408 panel driver (2024-04-19 04:27:48 +0300)


drm-misc-next for v6.10-rc1:

UAPI Changes:
- Add SIZE_HINTS property for cursor planes.

Cross-subsystem Changes:

Core Changes:
- Document the requirements and expectations of adding new
  driver-specific properties.
- Assorted small fixes to ttm.
- More Kconfig fixes.
- Add struct drm_edid_product_id and helpers.
- Use drm device based logging in more drm functions.
- Fixes for drm-panic, and option to test it.
- Assorted small fixes and updates to edid.
- Add drm_crtc_vblank_crtc and use it in vkms, nouveau.

Driver Changes:
- Assorted small fixes and improvements to bridge/imx8mp-hdmi-tx, 
nouveau, ast, qaic, lima, vc4, bridge/anx7625, mipi-dsi.

- Add drm panic to simpledrm, mgag200, imx, ast.
- Use dev_err_probe in bridge/panel drivers.
- Add Innolux G121X1-L03, LG sw43408 panels.
- Use struct drm_edid in i915 bios parsing.


Aleksandr Mishin (1):
  drm: vc4: Fix possible null pointer dereference

Arnd Bergmann (2):
  accel/qaic: mark debugfs stub functions as static inline
  drm: fix DRM_DISPLAY_DP_HELPER dependencies, part 2

Baruch Siach (1):
  doc: dma-buf: fix grammar typo

Daniel Vetter (1):
  drm/panic: Add drm panic locking

Dmitry Baryshkov (2):
  drm/mipi-dsi: use correct return type for the DSC functions
  drm/mipi-dsi: add mipi_dsi_compression_mode_ext()

Erico Nunes (5):
  drm/lima: add mask irq callback to gp and pp
  drm/lima: include pp bcast irq in timeout handler check
  drm/lima: mask irqs in timeout path before hard reset
  drm/lima: fix shared irq handling on driver remove
  drm/lima: fix void pointer to enum lima_gpu_id cast warning

Hsin-Te Yuan (1):
  drm/bridge: anx7625: Update audio status while detecting

Huai-Yuan Liu (1):
  drm/arm/malidp: fix a possible null pointer dereference

Jani Nikula (18):
  drm/edid: add drm_edid_get_product_id()
  drm/edid: add drm_edid_print_product_id()
  drm/i915/bios: switch to struct drm_edid and struct 
drm_edid_product_id

  drm/i915/bios: return drm_edid_product_id from get_lvds_pnp_id()
  drm/probe-helper: switch to drm device based logging
  drm/modes: switch to drm device based error logging
  drm/sysfs: switch to drm device based logging
  drm/client: switch to drm device based logging, and more
  drm/crtc: switch to drm device based logging
  drm/crtc-helper: switch to drm device based logging and warns
  drm: prefer DRM_MODE_FMT/ARG over drm_mode_debug_printmodeline()
  drm/displayid: move drm_displayid.h to drm_displayd_internal.h
  drm/edid: move all internal declarations to drm_crtc_internal.h
  drm/edid: group struct drm_edid based declarations together
  drm/edid: rename drm_find_edid_extension() to 
drm_edid_find_extension()

  drm/edid: avoid drm_edid_find_extension() internally
  drm/edid: make drm_edid_are_equal() static
  drm/edid: make drm_edid_are_equal() more convenient for its 
single user


Jeffrey Hugo (1):
  accel/qaic: Add Sahara implementation for firmware loading

Jesse Zhang (1):
  drm/ttm: remove unused paramter

Jocelyn Falempe (9):
  drm/panic: Add a drm panic handler
  drm/panic: Add support for color format conversion
  drm/panic: Add debugfs entry to test without triggering panic.
  drm/fb_dma: Add generic get_scanout_buffer() for drm_panic
  drm/simpledrm: Add drm_panic support
  drm/mgag200: Add drm_panic support
  drm/imx: Add 

[PATCH 4/5] drm/xe/display: Prevent overwriting original GGTT when taking over initial FB.

2024-04-18 Thread Maarten Lankhorst
Instead of overwriting the original GGTT mapping accidentally, allocate
a new GGTT mapping above the original GGTT mapping.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 40 ---
 drivers/gpu/drm/xe/display/xe_fb_pin.h| 20 ++
 drivers/gpu/drm/xe/display/xe_plane_initial.c | 15 ---
 drivers/gpu/drm/xe/xe_ggtt.c  |  9 +++--
 drivers/gpu/drm/xe/xe_ggtt.h  |  3 +-
 5 files changed, 63 insertions(+), 24 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/display/xe_fb_pin.h

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 16a287cbebc5..dd7a1c4a9430 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -8,6 +8,7 @@
 #include "intel_dpt.h"
 #include "intel_fb.h"
 #include "intel_fb_pin.h"
+#include "xe_fb_pin.h"
 #include "xe_ggtt.h"
 #include "xe_gt.h"
 
@@ -119,12 +120,11 @@ static void xe_fb_dpt_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
vma->dpt = NULL;
 }
 
-static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt, u64 ggtt_start)
 {
struct xe_device *xe = xe_bo_device(dpt);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
struct xe_ggtt *ggtt = tile0->mem.ggtt;
-   u64 start = 0, end = U64_MAX;
u64 alignment = XE_PAGE_SIZE;
int err;
 
@@ -139,8 +139,9 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
if (err)
goto out_put;
 
-   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
- alignment, 0, start, end, 0);
+   err = xe_ggtt_insert_special_node_locked(ggtt, >ggtt_node, 
dpt->size,
+alignment, ggtt_start, U64_MAX,
+ggtt_start ? 
DRM_MM_INSERT_HIGH : 0);
if (!err)
xe_ggtt_map_bo(ggtt, dpt);
mutex_unlock(>lock);
@@ -188,7 +189,7 @@ static void xe_fb_dpt_unpin_free(struct i915_vma *vma, 
struct intel_framebuffer
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
   const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+  struct i915_vma *vma, u64 ggtt_start)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
@@ -237,7 +238,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
  rot_info->plane[i].dst_stride);
}
 
-   ret = xe_fb_dpt_map_ggtt(dpt);
+   ret = xe_fb_dpt_map_ggtt(dpt, ggtt_start);
if (ret)
xe_fb_dpt_unpin_free(vma, fb);
return ret;
@@ -269,7 +270,7 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, 
u32 *ggtt_ofs, u32 bo
 
 static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
const struct i915_gtt_view *view,
-   struct i915_vma *vma)
+   struct i915_vma *vma, u64 ggtt_start)
 {
struct xe_bo *bo = intel_fb_obj(>base);
struct xe_device *xe = to_xe_device(fb->base.dev);
@@ -295,7 +296,8 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
u32 x, size = bo->ttm.base.size;
 
ret = xe_ggtt_insert_special_node_locked(ggtt, >node, size,
-align, 0);
+align, ggtt_start, 
U64_MAX,
+ggtt_start ? 
DRM_MM_INSERT_HIGH : 0);
if (ret)
goto out_unlock;
 
@@ -313,7 +315,7 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
 
ret = xe_ggtt_insert_special_node_locked(ggtt, >node, size,
-align, 0);
+align, ggtt_start, 
U64_MAX, 0);
if (ret)
goto out_unlock;
 
@@ -336,7 +338,8 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
 }
 
 static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
-   const struct i915_gtt_view *view)
+   const struct i915_gtt_view *view,
+   u64 ggtt_start)
 {
struct drm_device *dev = fb->base.dev;
struct xe_device *xe = to_xe_device(dev);
@@ -384,9 +387,9 @@ static struct i915_vma *__xe_pin_fb_vma(stru

[PATCH 5/5] drm/xe/display: Re-use display vmas when possible

2024-04-18 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  9 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..24ba55531e8d 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1106,7 +1106,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3d3b8e37c0f2 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -761,7 +761,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index b6df9baf481b..7b8a1825ccfc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -236,7 +236,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 43855c6c3509..a010b7a8a468 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -668,3 +668,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 04fd523a5023..fa6c0c1ae936 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -22,6 +22,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
 void intel_fbdev_output_poll_changed(struct drm_device *dev);
 void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -51,10 +53,17 @@ static inline void intel_fbdev_output_poll_changed(struct 
drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
 {
 }
+
 static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-

[PATCH 0/5] drm/xe: More fb pinning optimizations.

2024-04-18 Thread Maarten Lankhorst
This reduces the latency of pinning framebuffers by
re-using the previous mapping, if available.

Additionally, DPT is preallocated when creating the FB, instead
of performing a bo allocation on every pin.

Maarten Lankhorst (5):
  drm/xe/display: Preparations for preallocating dpt bo
  drm/xe: Use simple xchg to cache DPT
  drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen
  drm/xe/display: Prevent overwriting original GGTT when taking over
initial FB.
  drm/xe/display: Re-use display vmas when possible

 .../gpu/drm/i915/display/intel_atomic_plane.c |   2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |   2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |   3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|   5 +
 drivers/gpu/drm/i915/display/intel_fbdev.h|   9 +
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |   3 +
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 246 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.h|  20 ++
 drivers/gpu/drm/xe/display/xe_plane_initial.c |  15 +-
 drivers/gpu/drm/xe/xe_ggtt.c  |   9 +-
 drivers/gpu/drm/xe/xe_ggtt.h  |   3 +-
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c|   4 -
 13 files changed, 254 insertions(+), 70 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/display/xe_fb_pin.h

-- 
2.43.0



[PATCH 1/5] drm/xe/display: Preparations for preallocating dpt bo

2024-04-18 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3a584bc3a0a3..d967d00bbf9d 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -76,47 +76,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_device_mem_access_get(tile_to_xe(ggtt->tile));
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_device_mem_access_put(tile_to_xe(ggtt->tile));
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct i

[PATCH 3/5] drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen

2024-04-18 Thread Maarten Lankhorst
This is invalid with display code when reworking DPT.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c 
b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index f77367329760..1613290b9eda 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -298,10 +298,6 @@ static int __xe_ttm_stolen_io_mem_reserve_stolen(struct 
xe_device *xe,
 
XE_WARN_ON(IS_DGFX(xe));
 
-   /* XXX: Require BO to be mapped to GGTT? */
-   if (drm_WARN_ON(>drm, !(bo->flags & XE_BO_FLAG_GGTT)))
-   return -EIO;
-
/* GGTT is always contiguously mapped */
mem->bus.offset = xe_bo_ggtt_addr(bo) + mgr->io_base;
 
-- 
2.43.0



[PATCH 2/5] drm/xe: Use simple xchg to cache DPT

2024-04-18 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index d967d00bbf9d..16a287cbebc5 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -111,9 +111,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -151,10 +153,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -170,17 +173,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -236,7 +239,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -398,14 +401,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -432,7 +435,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -454,7 +457,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -464,10 +467,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[CI-only 8/8] drm/xe/display: Re-use display vmas when possible

2024-04-12 Thread Maarten Lankhorst
i915 has this really nice, infrastructure where everything becomes
complicated, GGTT needs eviction, etc..

Lets not do that, and make the dumbest possible interface instead.
Try to retrieve the VMA from old_plane_state, or intel_fbdev if kernel
fb.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.c   |  3 +-
 drivers/gpu/drm/i915/display/intel_fb_pin.h   |  3 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  5 ++
 drivers/gpu/drm/i915/display/intel_fbdev.h|  9 
 .../gpu/drm/xe/compat-i915-headers/i915_vma.h |  3 ++
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 46 +--
 8 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index ab01c2d15afd..dcb9b7751261 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1107,7 +1107,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index f08fce0de713..9153a1cdb1f2 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -772,7 +772,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
 
-   ret = intel_plane_pin_fb(new_plane_state);
+   ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
if (ret)
goto out_free;
 
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c 
b/drivers/gpu/drm/i915/display/intel_fb_pin.c
index b6df9baf481b..7b8a1825ccfc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
@@ -236,7 +236,8 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long 
flags)
i915_vma_put(vma);
 }
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state)
+int intel_plane_pin_fb(struct intel_plane_state *plane_state,
+  const struct intel_plane_state *old_plane_state)
 {
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h 
b/drivers/gpu/drm/i915/display/intel_fb_pin.h
index de0efaa25905..48675e6233f0 100644
--- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
+++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
@@ -22,7 +22,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 
-int intel_plane_pin_fb(struct intel_plane_state *plane_state);
+int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
+  const struct intel_plane_state *old_plane_state);
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
 
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 43855c6c3509..a010b7a8a468 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -668,3 +668,8 @@ struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 
return to_intel_framebuffer(fbdev->helper.fb);
 }
+
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)
+{
+   return fbdev ? fbdev->vma : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.h 
b/drivers/gpu/drm/i915/display/intel_fbdev.h
index 04fd523a5023..fa6c0c1ae936 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.h
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.h
@@ -22,6 +22,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int 
state, bool synchronous
 void intel_fbdev_output_poll_changed(struct drm_device *dev);
 void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
 struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
+struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev);
+
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -51,10 +53,17 @@ static inline void intel_fbdev_output_poll_changed(struct 
drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
 {
 }
+
 static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct 
intel_fbdev *fbdev)
 {
return NULL;
 }
+
+static inline struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev 
*fbdev)
+{
+   return NULL;
+}
+
 #endif
 
 #endif /* __INTEL_FBDEV_H__ */
diff --git a/drivers/gpu/drm/xe/compat-

[CI-only 3/8] drm/i915: Use the same vblank worker for atomic unpin

2024-04-12 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 22b80004574f..558e9b7404b5 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -618,6 +631,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[CI-only 6/8] drm/xe: Use simple xchg to cache DPT

2024-04-12 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 33 +++---
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index d967d00bbf9d..16a287cbebc5 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -111,9 +111,11 @@ static struct xe_bo *xe_fb_dpt_alloc(struct 
intel_framebuffer *fb)
return dpt;
 }
 
-static void xe_fb_dpt_free(struct i915_vma *vma)
+static void xe_fb_dpt_free(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   xe_bo_put(vma->dpt);
+   if (!fb || cmpxchg((struct xe_bo **)>dpt_vm, NULL, vma->dpt))
+   xe_bo_put(vma->dpt);
+
vma->dpt = NULL;
 }
 
@@ -151,10 +153,11 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
 static int
 xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct intel_framebuffer *fb)
 {
-   struct xe_bo *dpt;
+   struct xe_bo *dpt = (struct xe_bo *)xchg(>dpt_vm, NULL);
int err;
 
-   dpt = xe_fb_dpt_alloc(fb);
+   if (!dpt)
+   dpt = xe_fb_dpt_alloc(fb);
if (IS_ERR(dpt))
return PTR_ERR(dpt);
 
@@ -170,17 +173,17 @@ xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct 
intel_framebuffer *fb)
ttm_bo_unreserve(>ttm);
}
if (err)
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
return err;
 }
 
-static void xe_fb_dpt_unpin_free(struct i915_vma *vma)
+static void xe_fb_dpt_unpin_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
 {
ttm_bo_reserve(>dpt->ttm, false, false, NULL);
ttm_bo_unpin(>dpt->ttm);
ttm_bo_unreserve(>dpt->ttm);
 
-   xe_fb_dpt_free(vma);
+   xe_fb_dpt_free(vma, fb);
 }
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
@@ -236,7 +239,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
ret = xe_fb_dpt_map_ggtt(dpt);
if (ret)
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
return ret;
 }
 
@@ -398,14 +401,14 @@ static struct i915_vma *__xe_pin_fb_vma(struct 
intel_framebuffer *fb,
return ERR_PTR(ret);
 }
 
-static void __xe_unpin_fb_vma(struct i915_vma *vma)
+static void __xe_unpin_fb_vma(struct i915_vma *vma, struct intel_framebuffer 
*fb)
 {
struct xe_device *xe = to_xe_device(vma->bo->ttm.base.dev);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
 
if (vma->dpt) {
xe_ggtt_remove_bo(ggtt, vma->dpt);
-   xe_fb_dpt_unpin_free(vma);
+   xe_fb_dpt_unpin_free(vma, fb);
} else {
if (!drm_mm_node_allocated(>bo->ggtt_node) ||
vma->bo->ggtt_node.start != vma->node.start)
@@ -432,7 +435,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-   __xe_unpin_fb_vma(vma);
+   __xe_unpin_fb_vma(vma, NULL);
 }
 
 int intel_plane_pin_fb(struct intel_plane_state *plane_state)
@@ -454,7 +457,7 @@ int intel_plane_pin_fb(struct intel_plane_state 
*plane_state)
 
 void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
 {
-   __xe_unpin_fb_vma(old_plane_state->ggtt_vma);
+   __xe_unpin_fb_vma(old_plane_state->ggtt_vma, 
to_intel_framebuffer(old_plane_state->hw.fb));
old_plane_state->ggtt_vma = NULL;
 }
 
@@ -464,10 +467,12 @@ void intel_plane_unpin_fb(struct intel_plane_state 
*old_plane_state)
  */
 struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
 {
-   return NULL;
+   return (struct i915_address_space *)xe_fb_dpt_alloc(fb);
 }
 
 void intel_dpt_destroy(struct i915_address_space *vm)
 {
-   return;
+   struct xe_bo *bo = (struct xe_bo *)vm;
+
+   xe_bo_put(bo);
 }
-- 
2.43.0



[CI-only 4/8] drm/xe/display: Preparations for preallocating dpt bo

2024-04-12 Thread Maarten Lankhorst
The DPT bo should not be allocated when pinning, but in advance when
creating the framebuffer. Split allocation from bo pinning and GGTT
insertion.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 159 +++--
 1 file changed, 123 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 3a584bc3a0a3..d967d00bbf9d 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -76,47 +76,130 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map 
*map, u32 *dpt_ofs,
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
 
-static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
-  const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+static struct xe_bo *xe_fb_dpt_alloc(struct intel_framebuffer *fb)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
-   struct xe_ggtt *ggtt = tile0->mem.ggtt;
struct xe_bo *bo = intel_fb_obj(>base), *dpt;
u32 dpt_size, size = bo->ttm.base.size;
 
-   if (view->type == I915_GTT_VIEW_NORMAL)
+   if (!intel_fb_needs_pot_stride_remap(fb))
dpt_size = ALIGN(size / XE_PAGE_SIZE * 8, XE_PAGE_SIZE);
-   else if (view->type == I915_GTT_VIEW_REMAPPED)
-   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
-XE_PAGE_SIZE);
else
-   /* display uses 4K tiles instead of bytes here, convert to 
entries.. */
-   dpt_size = ALIGN(intel_rotation_info_size(>rotated) * 8,
+   dpt_size = 
ALIGN(intel_remapped_info_size(>remapped_view.gtt.remapped) * 8,
 XE_PAGE_SIZE);
 
if (IS_DGFX(xe))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_VRAM0 |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
-   else
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_STOLEN |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   return xe_bo_create(xe, tile0, NULL, dpt_size,
+   ttm_bo_type_kernel,
+   XE_BO_FLAG_NEEDS_CPU_ACCESS |
+   XE_BO_FLAG_VRAM0 |
+   XE_BO_FLAG_PAGETABLE);
+
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_STOLEN |
+  XE_BO_FLAG_PAGETABLE);
if (IS_ERR(dpt))
-   dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
-  ttm_bo_type_kernel,
-  XE_BO_FLAG_SYSTEM |
-  XE_BO_FLAG_GGTT |
-  XE_BO_FLAG_PAGETABLE);
+   dpt = xe_bo_create(xe, tile0, NULL, dpt_size,
+  ttm_bo_type_kernel,
+  XE_BO_FLAG_NEEDS_CPU_ACCESS |
+  XE_BO_FLAG_SYSTEM |
+  XE_BO_FLAG_PAGETABLE);
+
+   return dpt;
+}
+
+static void xe_fb_dpt_free(struct i915_vma *vma)
+{
+   xe_bo_put(vma->dpt);
+   vma->dpt = NULL;
+}
+
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+{
+   struct xe_device *xe = xe_bo_device(dpt);
+   struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+   struct xe_ggtt *ggtt = tile0->mem.ggtt;
+   u64 start = 0, end = U64_MAX;
+   u64 alignment = XE_PAGE_SIZE;
+   int err;
+
+   if (dpt->flags & XE_BO_FLAG_INTERNAL_64K)
+   alignment = SZ_64K;
+
+   if (XE_WARN_ON(dpt->ggtt_node.size))
+   return -EINVAL;
+
+   xe_device_mem_access_get(tile_to_xe(ggtt->tile));
+   err = mutex_lock_interruptible(>lock);
+   if (err)
+   goto out_put;
+
+   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
+ alignment, 0, start, end, 0);
+   if (!err)
+   xe_ggtt_map_bo(ggtt, dpt);
+   mutex_unlock(>lock);
+
+out_put:
+   xe_device_mem_access_put(tile_to_xe(ggtt->tile));
+   return err;
+}
+
+static int
+xe_fb_dpt_alloc_pinned(struct i915_vma *vma, struct i

[CI-only 7/8] drm/xe/display: Prevent overwriting original GGTT when taking over initial FB.

2024-04-12 Thread Maarten Lankhorst
Instead of overwriting the original GGTT mapping accidentally, allocate
a new GGTT mapping above the original GGTT mapping.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c| 40 ---
 drivers/gpu/drm/xe/display/xe_fb_pin.h| 20 ++
 drivers/gpu/drm/xe/display/xe_plane_initial.c | 15 ---
 drivers/gpu/drm/xe/xe_ggtt.c  | 19 ++---
 drivers/gpu/drm/xe/xe_ggtt.h  |  5 +--
 5 files changed, 61 insertions(+), 38 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/display/xe_fb_pin.h

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 16a287cbebc5..dd7a1c4a9430 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -8,6 +8,7 @@
 #include "intel_dpt.h"
 #include "intel_fb.h"
 #include "intel_fb_pin.h"
+#include "xe_fb_pin.h"
 #include "xe_ggtt.h"
 #include "xe_gt.h"
 
@@ -119,12 +120,11 @@ static void xe_fb_dpt_free(struct i915_vma *vma, struct 
intel_framebuffer *fb)
vma->dpt = NULL;
 }
 
-static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
+static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt, u64 ggtt_start)
 {
struct xe_device *xe = xe_bo_device(dpt);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
struct xe_ggtt *ggtt = tile0->mem.ggtt;
-   u64 start = 0, end = U64_MAX;
u64 alignment = XE_PAGE_SIZE;
int err;
 
@@ -139,8 +139,9 @@ static int xe_fb_dpt_map_ggtt(struct xe_bo *dpt)
if (err)
goto out_put;
 
-   err = drm_mm_insert_node_in_range(>mm, >ggtt_node, dpt->size,
- alignment, 0, start, end, 0);
+   err = xe_ggtt_insert_special_node_locked(ggtt, >ggtt_node, 
dpt->size,
+alignment, ggtt_start, U64_MAX,
+ggtt_start ? 
DRM_MM_INSERT_HIGH : 0);
if (!err)
xe_ggtt_map_bo(ggtt, dpt);
mutex_unlock(>lock);
@@ -188,7 +189,7 @@ static void xe_fb_dpt_unpin_free(struct i915_vma *vma, 
struct intel_framebuffer
 
 static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
   const struct i915_gtt_view *view,
-  struct i915_vma *vma)
+  struct i915_vma *vma, u64 ggtt_start)
 {
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
@@ -237,7 +238,7 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
  rot_info->plane[i].dst_stride);
}
 
-   ret = xe_fb_dpt_map_ggtt(dpt);
+   ret = xe_fb_dpt_map_ggtt(dpt, ggtt_start);
if (ret)
xe_fb_dpt_unpin_free(vma, fb);
return ret;
@@ -269,7 +270,7 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, 
u32 *ggtt_ofs, u32 bo
 
 static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
const struct i915_gtt_view *view,
-   struct i915_vma *vma)
+   struct i915_vma *vma, u64 ggtt_start)
 {
struct xe_bo *bo = intel_fb_obj(>base);
struct xe_device *xe = to_xe_device(fb->base.dev);
@@ -295,7 +296,8 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
u32 x, size = bo->ttm.base.size;
 
ret = xe_ggtt_insert_special_node_locked(ggtt, >node, size,
-align, 0);
+align, ggtt_start, 
U64_MAX,
+ggtt_start ? 
DRM_MM_INSERT_HIGH : 0);
if (ret)
goto out_unlock;
 
@@ -313,7 +315,7 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
 
ret = xe_ggtt_insert_special_node_locked(ggtt, >node, size,
-align, 0);
+align, ggtt_start, 
U64_MAX, 0);
if (ret)
goto out_unlock;
 
@@ -336,7 +338,8 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer 
*fb,
 }
 
 static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
-   const struct i915_gtt_view *view)
+   const struct i915_gtt_view *view,
+   u64 ggtt_start)
 {
struct drm_device *dev = fb->base.dev;
struct xe_device *xe = to_xe_device(dev);
@@ -384,9 +387,9 @@ static struct i915_vma *__xe_pin_fb_vma(stru

[CI-only 5/8] drm/xe: Remove safety check from __xe_ttm_stolen_io_mem_reserve_stolen

2024-04-12 Thread Maarten Lankhorst
This is invalid with display code when reworking DPT.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c 
b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index 6ffecf9f23d1..dce742f5bdc0 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -302,10 +302,6 @@ static int __xe_ttm_stolen_io_mem_reserve_stolen(struct 
xe_device *xe,
 
XE_WARN_ON(IS_DGFX(xe));
 
-   /* XXX: Require BO to be mapped to GGTT? */
-   if (drm_WARN_ON(>drm, !(bo->flags & XE_BO_FLAG_GGTT)))
-   return -EIO;
-
/* GGTT is always contiguously mapped */
mem->bus.offset = xe_bo_ggtt_addr(bo) + mgr->io_base;
 
-- 
2.43.0



[CI-only 1/8] drm: Add drm_vblank_work_flush_all().

2024-04-12 Thread Maarten Lankhorst
In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..6a53cede547a 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   !waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[CI-only 2/8] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-04-12 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 23a122ee20c9..3cebeaa6e8b4 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -674,6 +674,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -817,14 +828,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index a92b67adee9c..46982fdc6a30 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6932,6 +6933,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 0f4bd5710796..563637f20abf 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -730,6 +730,9 @@ struct intel_plane_state {
struct intel_fb_view view;
u32 phys_dma_addr; /* for cursor_needs_physical */
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[PULL] drm-misc-next

2024-04-10 Thread Maarten Lankhorst

Hi Dave, Sima,

Still low amount of patches this week!

Cheers,
~Maarten

drm-misc-next-2024-04-10:
drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.
The following changes since commit d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-10


for you to fetch changes up to 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)



drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.


Aleksandr Mishin (1):
  drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference

Chen-Yu Tsai (1):
  dt-bindings: display: bridge: it6505: Add #sound-dai-cells

Dan Carpenter (1):
  drm: xlnx: db: fix a memory leak in probe

Douglas Anderson (3):
  drm/panel-edp: Abstract out function to set conservative timings
  drm/panel-edp: If we fail to powerup/get EDID, use conservative 
timings
  drm-panel: If drm_panel_dp_aux_backlight() fails, don't fail 
panel probe


Jani Nikula (1):
  drm: remove unused header gma_drm.h

Jeffrey Hugo (3):
  accel/qaic: Add bootlog debugfs
  accel/qaic: Add fifo size debugfs
  accel/qaic: Add fifo queued debugfs

Krzysztof Kozlowski (1):
  drm/omap: dmm_tiler: drop driver owner assignment

Maxime Ripard (2):
  drm/display: Select DRM_KMS_HELPER for DP helpers
  drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable

Tomi Valkeinen (1):
  MAINTAINERS: Add myself as maintainer for Xilinx DRM drivers

Uwe Kleine-König (1):
  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void


Wolfram Sang (1):
  drm: tilcdc: don't use devm_pinctrl_get_select_default() in probe

 .../bindings/display/bridge/ite,it6505.yaml|   8 +-
 MAINTAINERS|   1 +
 drivers/accel/qaic/Makefile|   2 +
 drivers/accel/qaic/qaic.h  |   9 +
 drivers/accel/qaic/qaic_data.c |   9 +
 drivers/accel/qaic/qaic_debugfs.c  | 338 
+

 drivers/accel/qaic/qaic_debugfs.h  |  20 ++
 drivers/accel/qaic/qaic_drv.c  |  16 +-
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c|   3 +
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c   |   6 +-
 drivers/gpu/drm/bridge/synopsys/Kconfig|   2 +-
 drivers/gpu/drm/display/Kconfig|   1 +
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c   |   1 -
 drivers/gpu/drm/panel/panel-edp.c  |  60 ++--
 drivers/gpu/drm/panel/panel-samsung-atna33xc20.c   |   9 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |   6 -
 drivers/gpu/drm/xlnx/zynqmp_dp.c   |   2 +-
 include/drm/gma_drm.h  |  13 -
 18 files changed, 450 insertions(+), 56 deletions(-)
 create mode 100644 drivers/accel/qaic/qaic_debugfs.c
 create mode 100644 drivers/accel/qaic/qaic_debugfs.h
 delete mode 100644 include/drm/gma_drm.h


[PULL] drm-misc-next

2024-04-10 Thread Maarten Lankhorst

Hi Dave, Sima,

Still low amount of patches this week!

Cheers,
~Maarten

drm-misc-next-2024-04-10:
drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.
The following changes since commit d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-10


for you to fetch changes up to 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)



drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.


Aleksandr Mishin (1):
  drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference

Chen-Yu Tsai (1):
  dt-bindings: display: bridge: it6505: Add #sound-dai-cells

Dan Carpenter (1):
  drm: xlnx: db: fix a memory leak in probe

Douglas Anderson (3):
  drm/panel-edp: Abstract out function to set conservative timings
  drm/panel-edp: If we fail to powerup/get EDID, use conservative 
timings
  drm-panel: If drm_panel_dp_aux_backlight() fails, don't fail 
panel probe


Jani Nikula (1):
  drm: remove unused header gma_drm.h

Jeffrey Hugo (3):
  accel/qaic: Add bootlog debugfs
  accel/qaic: Add fifo size debugfs
  accel/qaic: Add fifo queued debugfs

Krzysztof Kozlowski (1):
  drm/omap: dmm_tiler: drop driver owner assignment

Maxime Ripard (2):
  drm/display: Select DRM_KMS_HELPER for DP helpers
  drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable

Tomi Valkeinen (1):
  MAINTAINERS: Add myself as maintainer for Xilinx DRM drivers

Uwe Kleine-König (1):
  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void


Wolfram Sang (1):
  drm: tilcdc: don't use devm_pinctrl_get_select_default() in probe

 .../bindings/display/bridge/ite,it6505.yaml|   8 +-
 MAINTAINERS|   1 +
 drivers/accel/qaic/Makefile|   2 +
 drivers/accel/qaic/qaic.h  |   9 +
 drivers/accel/qaic/qaic_data.c |   9 +
 drivers/accel/qaic/qaic_debugfs.c  | 338 
+

 drivers/accel/qaic/qaic_debugfs.h  |  20 ++
 drivers/accel/qaic/qaic_drv.c  |  16 +-
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c|   3 +
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c   |   6 +-
 drivers/gpu/drm/bridge/synopsys/Kconfig|   2 +-
 drivers/gpu/drm/display/Kconfig|   1 +
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c   |   1 -
 drivers/gpu/drm/panel/panel-edp.c  |  60 ++--
 drivers/gpu/drm/panel/panel-samsung-atna33xc20.c   |   9 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |   6 -
 drivers/gpu/drm/xlnx/zynqmp_dp.c   |   2 +-
 include/drm/gma_drm.h  |  13 -
 18 files changed, 450 insertions(+), 56 deletions(-)
 create mode 100644 drivers/accel/qaic/qaic_debugfs.c
 create mode 100644 drivers/accel/qaic/qaic_debugfs.h
 delete mode 100644 include/drm/gma_drm.h


[PULL] drm-misc-next

2024-04-10 Thread Maarten Lankhorst

Hi Dave, Sima,

Still low amount of patches this week!

Cheers,
~Maarten

drm-misc-next-2024-04-10:
drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.
The following changes since commit d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-10


for you to fetch changes up to 29b39672bc1d651010f7b61e106d51998f068aaf:

  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void (2024-04-10 15:06:45 +0200)



drm-misc-next for v6.10:

Cross-subsystem Changes:
- Add Tomi as Xilinx maintainer.
- Add sound bindings to DT.

Core Changes:
- Make DP helper depend on KMS helper.

Driver Changes:
- Assorted small fixes to bridge/dw-hdmi, bridge/cdns-mhdp8456, xlnx,
  omap, tilcdc, bridge/imx8mp-hdmi-pvi.
- Add debugfs entries to qaic.
- Add conservative fallback to panel eDP.


Aleksandr Mishin (1):
  drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference

Chen-Yu Tsai (1):
  dt-bindings: display: bridge: it6505: Add #sound-dai-cells

Dan Carpenter (1):
  drm: xlnx: db: fix a memory leak in probe

Douglas Anderson (3):
  drm/panel-edp: Abstract out function to set conservative timings
  drm/panel-edp: If we fail to powerup/get EDID, use conservative 
timings
  drm-panel: If drm_panel_dp_aux_backlight() fails, don't fail 
panel probe


Jani Nikula (1):
  drm: remove unused header gma_drm.h

Jeffrey Hugo (3):
  accel/qaic: Add bootlog debugfs
  accel/qaic: Add fifo size debugfs
  accel/qaic: Add fifo queued debugfs

Krzysztof Kozlowski (1):
  drm/omap: dmm_tiler: drop driver owner assignment

Maxime Ripard (2):
  drm/display: Select DRM_KMS_HELPER for DP helpers
  drm/bridge: dw-hdmi: Make DRM_DW_HDMI selectable

Tomi Valkeinen (1):
  MAINTAINERS: Add myself as maintainer for Xilinx DRM drivers

Uwe Kleine-König (1):
  drm/bridge: imx8mp-hdmi-pvi: Convert to platform remove callback 
returning void


Wolfram Sang (1):
  drm: tilcdc: don't use devm_pinctrl_get_select_default() in probe

 .../bindings/display/bridge/ite,it6505.yaml|   8 +-
 MAINTAINERS|   1 +
 drivers/accel/qaic/Makefile|   2 +
 drivers/accel/qaic/qaic.h  |   9 +
 drivers/accel/qaic/qaic_data.c |   9 +
 drivers/accel/qaic/qaic_debugfs.c  | 338 
+

 drivers/accel/qaic/qaic_debugfs.h  |  20 ++
 drivers/accel/qaic/qaic_drv.c  |  16 +-
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c|   3 +
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c   |   6 +-
 drivers/gpu/drm/bridge/synopsys/Kconfig|   2 +-
 drivers/gpu/drm/display/Kconfig|   1 +
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c   |   1 -
 drivers/gpu/drm/panel/panel-edp.c  |  60 ++--
 drivers/gpu/drm/panel/panel-samsung-atna33xc20.c   |   9 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |   6 -
 drivers/gpu/drm/xlnx/zynqmp_dp.c   |   2 +-
 include/drm/gma_drm.h  |  13 -
 18 files changed, 450 insertions(+), 56 deletions(-)
 create mode 100644 drivers/accel/qaic/qaic_debugfs.c
 create mode 100644 drivers/accel/qaic/qaic_debugfs.h
 delete mode 100644 include/drm/gma_drm.h


[CI-only 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-04-09 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 22b80004574f..558e9b7404b5 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -618,6 +631,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[CI-only 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-04-09 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 89c26db0730e..f2d18695c21d 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -674,6 +674,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -817,14 +828,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index ad04b94c52ee..be65bf9fbd48 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6854,6 +6855,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 0f4bd5710796..563637f20abf 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -730,6 +730,9 @@ struct intel_plane_state {
struct intel_fb_view view;
u32 phys_dma_addr; /* for cursor_needs_physical */
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[CI-only 1/3] drm: Add drm_vblank_work_flush_all().

2024-04-09 Thread Maarten Lankhorst
In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..6a53cede547a 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   !waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[CI-only 2/4] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-04-09 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 89c26db0730e..f2d18695c21d 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -674,6 +674,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -817,14 +828,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index ad04b94c52ee..be65bf9fbd48 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6854,6 +6855,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 0f4bd5710796..563637f20abf 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -730,6 +730,9 @@ struct intel_plane_state {
struct intel_fb_view view;
u32 phys_dma_addr; /* for cursor_needs_physical */
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[CI-only 4/4] drm/i915: Hack to check use-after-free aggressively, and undo purpose of patches

2024-04-09 Thread Maarten Lankhorst
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_crtc.c   | 2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 558e9b7404b5..0ec6c3a79ec1 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -640,7 +640,7 @@ void intel_pipe_update_end(struct intel_atomic_state *state,
if (old_plane_state->uapi.crtc == >base &&
old_plane_state->unpin_work.vblank) {

drm_vblank_work_schedule(_plane_state->unpin_work,
-
drm_crtc_accurate_vblank_count(>base) + 1,
+
drm_crtc_accurate_vblank_count(>base),
 false);
 
/* Remove plane from atomic state, cleanup/free 
is done from vblank worker. */
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index e999ee8e9d94..f052c25b0675 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -833,7 +833,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 intel_cursor_unpin_work);
 
drm_vblank_work_schedule(_plane_state->unpin_work,
-
drm_crtc_accurate_vblank_count(>base) + 1,
+
drm_crtc_accurate_vblank_count(>base),
 false);
 
old_plane_state = NULL;
-- 
2.43.0



[CI-only 3/4] drm/i915: Use the same vblank worker for atomic unpin

2024-04-09 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 22b80004574f..558e9b7404b5 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -618,6 +631,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[CI-only 1/4] drm: Add drm_vblank_work_flush_all().

2024-04-09 Thread Maarten Lankhorst
In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..6a53cede547a 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   !waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



Re: [rebase 1/3] drm: Add drm_vblank_work_flush_all().

2024-04-06 Thread Maarten Lankhorst

Hey,

On 2024-04-05 15:36, Lucas De Marchi wrote:

what does "rebase" instead of "PATCH" is supposed to mean here?
And then we have a "PATCH v2" as reply to this one.

Shouldn't this go to dri-devel (too)?

Lucas De Marchi

I was rebasing so no changes were originally made.

Afterwards I found out why the patch series failed,
and sent a v2 patch for that specifically.

I think this should go to dri-devel, forgot this patch required it. :)

Can send a full v2 patch series in the beginning of next week. It looks 
like I still missed a uaf even with this fix. :(


Cheers,
~Maarten



On Thu, Apr 04, 2024 at 12:48:11PM +0200, Maarten Lankhorst wrote:

From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
drivers/gpu/drm/drm_vblank_work.c | 22 ++
include/drm/drm_vblank_work.h |  2 ++
2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c

index 43cd5c0f4f6f..ff86f2b2e052 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work 
*work)

}
EXPORT_SYMBOL(drm_vblank_work_flush);

+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank 
work on crtc.

+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+    struct drm_device *dev = crtc->dev;
+    struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+    spin_lock_irq(>event_lock);
+    wait_event_lock_irq(vblank->work_wait_queue,
+    waitqueue_active(>work_wait_queue),
+    dev->event_lock);
+    spin_unlock_irq(>event_lock);
+
+    kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
/**
 * drm_vblank_work_init - initialize a vblank work item
 * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h 
b/include/drm/drm_vblank_work.h

index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
 * drm_vblank_work_init()
 * drm_vblank_work_cancel_sync()
 * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
 */
struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work 
*work, struct drm_crtc *crtc,

  void (*func)(struct kthread_work *work));
bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);

#endif /* !_DRM_VBLANK_WORK_H_ */
--
2.43.0



Re: [rebase 1/3] drm: Add drm_vblank_work_flush_all().

2024-04-06 Thread Maarten Lankhorst

Hey,

On 2024-04-05 15:36, Lucas De Marchi wrote:

what does "rebase" instead of "PATCH" is supposed to mean here?
And then we have a "PATCH v2" as reply to this one.

Shouldn't this go to dri-devel (too)?

Lucas De Marchi

I was rebasing so no changes were originally made.

Afterwards I found out why the patch series failed,
and sent a v2 patch for that specifically.

I think this should go to dri-devel, forgot this patch required it. :)

Can send a full v2 patch series in the beginning of next week. It looks 
like I still missed a uaf even with this fix. :(


Cheers,
~Maarten



On Thu, Apr 04, 2024 at 12:48:11PM +0200, Maarten Lankhorst wrote:

From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
drivers/gpu/drm/drm_vblank_work.c | 22 ++
include/drm/drm_vblank_work.h |  2 ++
2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c

index 43cd5c0f4f6f..ff86f2b2e052 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work 
*work)

}
EXPORT_SYMBOL(drm_vblank_work_flush);

+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank 
work on crtc.

+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+    struct drm_device *dev = crtc->dev;
+    struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+    spin_lock_irq(>event_lock);
+    wait_event_lock_irq(vblank->work_wait_queue,
+    waitqueue_active(>work_wait_queue),
+    dev->event_lock);
+    spin_unlock_irq(>event_lock);
+
+    kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
/**
 * drm_vblank_work_init - initialize a vblank work item
 * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h 
b/include/drm/drm_vblank_work.h

index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
 * drm_vblank_work_init()
 * drm_vblank_work_cancel_sync()
 * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
 */
struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work 
*work, struct drm_crtc *crtc,

  void (*func)(struct kthread_work *work));
bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);

#endif /* !_DRM_VBLANK_WORK_H_ */
--
2.43.0



[PATCH v2] drm: Add drm_vblank_work_flush_all().

2024-04-05 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

 Changes since v1:
   Check in flush_all for waitqueue_active was inverted.

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..6a53cede547a 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   !waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[PULL] drm-misc-next

2024-04-05 Thread Maarten Lankhorst

Hi Dave, Sima,

Everyone seems to be out on vacation, so the pull request is pretty empty.

Cheers,
~Maarten

drm-misc-next-2024-04-05:
drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.
The following changes since commit 39cd87c4eb2b893354f3b850f916353f2658ae6f:

  Linux 6.9-rc2 (2024-03-31 14:32:39 -0700)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-05


for you to fetch changes up to d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)


drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.


Adam Ford (1):
  drm/bridge: adv7511: Allow IRQ to share GPIO pins

Adrián Larumbe (1):
  ABI: sysfs-driver-panfrost-profiling: fix indentation problem

Arnd Bergmann (1):
  drm: fix DRM_DISPLAY_DP_HELPER dependencies

Boris Brezillon (3):
  drm/panthor: Fix IO-page mmap() for 32-bit userspace on 64-bit kernel
  drm/panthor: Fix ordering in _irq_suspend()
  drm/panthor: Drop the dev_enter/exit() sections in 
_irq_suspend/resume()


Chris Morgan (3):
  dt-bindings: vendor-prefix: Add prefix for GameForce
  dt-bindings: display: Add GameForce Chi Panel
  drm/panel: st7703: Add GameForce Chi Panel Support

Christian Hewitt (1):
  drm/meson: vclk: fix calculation of 59.94 fractional rates

Dan Carpenter (3):
  drm/panthor: Fix a couple -ENOMEM error codes
  drm/panthor: Fix error code in panthor_gpu_init()
  drm/panthor: Fix off by one in panthor_fw_get_cs_iface()

Harshit Mogalapalli (2):
  drm/panthor: Fix NULL vs IS_ERR() bug in panthor_probe()
  drm/panthor: Don't return NULL from panthor_vm_get_heap_pool()

Ian Forbes (1):
  drm/vmwgfx: Remove unused code

Liviu Dudau (2):
  drm/panthor: Cleanup unused variable 'cookie'
  drm/panthor: Fix some kerneldoc warnings

Nathan Chancellor (1):
  drm/panthor: Fix clang -Wunused-but-set-variable in tick_ctx_apply()

Thomas Zimmermann (14):
  Merge drm/drm-next into drm-misc-next
  drm/ast: Include  where necessary
  drm/ast: Fail probing if DDC channel could not be initialized
  drm/ast: Remove struct ast_{vga,sil165}_connector
  drm/ast: Allocate instance of struct ast_i2c_chan with managed 
helpers

  drm/ast: Move DDC code to ast_ddc.{c,h}
  drm/ast: Rename struct ast_i2c_chan to struct ast_ddc
  drm/ast: Pass AST device to ast_ddc_create()
  drm/ast: Store AST device in struct ast_ddc
  drm/ast: Rename struct i2c_algo_bit_data callbacks and their 
parameters

  drm/ast: Acquire I/O-register lock in DDC code
  drm/ast: Use drm_connector_helper_get_modes()
  drm/ast: Implement polling for VGA and SIL164 connectors
  drm/ast: Automatically clean up poll helper

 .../ABI/testing/sysfs-driver-panfrost-profiling|   10 +
 .../bindings/display/bridge/lvds-codec.yaml|1 +
 .../bindings/display/panel/ilitek,ili9881c.yaml|1 +
 .../bindings/display/panel/novatek,nt35950.yaml|3 +-
 .../bindings/display/panel/novatek,nt36523.yaml|   25 +-
 .../bindings/display/panel/panel-common-dual.yaml  |   47 +
 .../bindings/display/panel/panel-simple-dsi.yaml   |2 +
 .../bindings/display/panel/panel-simple.yaml   |4 +
 .../display/panel/rocktech,jh057n00900.yaml|2 +
 .../bindings/display/panel/sony,td4353-jdi.yaml|2 +
 .../bindings/gpu/arm,mali-valhall-csf.yaml |  147 +
 .../devicetree/bindings/vendor-prefixes.yaml   |4 +
 Documentation/gpu/driver-uapi.rst  |5 +
 Documentation/gpu/panfrost.rst |9 +
 MAINTAINERS|  183 +-
 arch/m68k/include/asm/pgtable.h|2 +
 arch/parisc/configs/generic-32bit_defconfig|2 +-
 drivers/gpu/drm/Kconfig|   23 +-
 drivers/gpu/drm/Makefile   |   29 +
 drivers/gpu/drm/amd/amdgpu/Kconfig |   12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |6 +
 drivers/gpu/drm/ast/Makefile   |   10 +-
 drivers/gpu/drm/ast/{ast_i2c.c => ast_ddc.c}   |  120 +-
 drivers/gpu/drm/ast/ast_ddc.h  |   20 +
 drivers/gpu/drm/ast/ast_drv.c  |1 +
 drivers/gpu/drm/ast/ast_drv.h  |   39 +-
 drivers/gpu/drm/ast/ast_main.c |1 +
 drivers/gpu/drm/ast/ast_mode.c |  147 +-
 

[PULL] drm-misc-next

2024-04-05 Thread Maarten Lankhorst

Hi Dave, Sima,

Everyone seems to be out on vacation, so the pull request is pretty empty.

Cheers,
~Maarten

drm-misc-next-2024-04-05:
drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.
The following changes since commit 39cd87c4eb2b893354f3b850f916353f2658ae6f:

  Linux 6.9-rc2 (2024-03-31 14:32:39 -0700)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-05


for you to fetch changes up to d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)


drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.


Adam Ford (1):
  drm/bridge: adv7511: Allow IRQ to share GPIO pins

Adrián Larumbe (1):
  ABI: sysfs-driver-panfrost-profiling: fix indentation problem

Arnd Bergmann (1):
  drm: fix DRM_DISPLAY_DP_HELPER dependencies

Boris Brezillon (3):
  drm/panthor: Fix IO-page mmap() for 32-bit userspace on 64-bit kernel
  drm/panthor: Fix ordering in _irq_suspend()
  drm/panthor: Drop the dev_enter/exit() sections in 
_irq_suspend/resume()


Chris Morgan (3):
  dt-bindings: vendor-prefix: Add prefix for GameForce
  dt-bindings: display: Add GameForce Chi Panel
  drm/panel: st7703: Add GameForce Chi Panel Support

Christian Hewitt (1):
  drm/meson: vclk: fix calculation of 59.94 fractional rates

Dan Carpenter (3):
  drm/panthor: Fix a couple -ENOMEM error codes
  drm/panthor: Fix error code in panthor_gpu_init()
  drm/panthor: Fix off by one in panthor_fw_get_cs_iface()

Harshit Mogalapalli (2):
  drm/panthor: Fix NULL vs IS_ERR() bug in panthor_probe()
  drm/panthor: Don't return NULL from panthor_vm_get_heap_pool()

Ian Forbes (1):
  drm/vmwgfx: Remove unused code

Liviu Dudau (2):
  drm/panthor: Cleanup unused variable 'cookie'
  drm/panthor: Fix some kerneldoc warnings

Nathan Chancellor (1):
  drm/panthor: Fix clang -Wunused-but-set-variable in tick_ctx_apply()

Thomas Zimmermann (14):
  Merge drm/drm-next into drm-misc-next
  drm/ast: Include  where necessary
  drm/ast: Fail probing if DDC channel could not be initialized
  drm/ast: Remove struct ast_{vga,sil165}_connector
  drm/ast: Allocate instance of struct ast_i2c_chan with managed 
helpers

  drm/ast: Move DDC code to ast_ddc.{c,h}
  drm/ast: Rename struct ast_i2c_chan to struct ast_ddc
  drm/ast: Pass AST device to ast_ddc_create()
  drm/ast: Store AST device in struct ast_ddc
  drm/ast: Rename struct i2c_algo_bit_data callbacks and their 
parameters

  drm/ast: Acquire I/O-register lock in DDC code
  drm/ast: Use drm_connector_helper_get_modes()
  drm/ast: Implement polling for VGA and SIL164 connectors
  drm/ast: Automatically clean up poll helper

 .../ABI/testing/sysfs-driver-panfrost-profiling|   10 +
 .../bindings/display/bridge/lvds-codec.yaml|1 +
 .../bindings/display/panel/ilitek,ili9881c.yaml|1 +
 .../bindings/display/panel/novatek,nt35950.yaml|3 +-
 .../bindings/display/panel/novatek,nt36523.yaml|   25 +-
 .../bindings/display/panel/panel-common-dual.yaml  |   47 +
 .../bindings/display/panel/panel-simple-dsi.yaml   |2 +
 .../bindings/display/panel/panel-simple.yaml   |4 +
 .../display/panel/rocktech,jh057n00900.yaml|2 +
 .../bindings/display/panel/sony,td4353-jdi.yaml|2 +
 .../bindings/gpu/arm,mali-valhall-csf.yaml |  147 +
 .../devicetree/bindings/vendor-prefixes.yaml   |4 +
 Documentation/gpu/driver-uapi.rst  |5 +
 Documentation/gpu/panfrost.rst |9 +
 MAINTAINERS|  183 +-
 arch/m68k/include/asm/pgtable.h|2 +
 arch/parisc/configs/generic-32bit_defconfig|2 +-
 drivers/gpu/drm/Kconfig|   23 +-
 drivers/gpu/drm/Makefile   |   29 +
 drivers/gpu/drm/amd/amdgpu/Kconfig |   12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |6 +
 drivers/gpu/drm/ast/Makefile   |   10 +-
 drivers/gpu/drm/ast/{ast_i2c.c => ast_ddc.c}   |  120 +-
 drivers/gpu/drm/ast/ast_ddc.h  |   20 +
 drivers/gpu/drm/ast/ast_drv.c  |1 +
 drivers/gpu/drm/ast/ast_drv.h  |   39 +-
 drivers/gpu/drm/ast/ast_main.c |1 +
 drivers/gpu/drm/ast/ast_mode.c |  147 +-
 

[PULL] drm-misc-next

2024-04-05 Thread Maarten Lankhorst

Hi Dave, Sima,

Everyone seems to be out on vacation, so the pull request is pretty empty.

Cheers,
~Maarten

drm-misc-next-2024-04-05:
drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.
The following changes since commit 39cd87c4eb2b893354f3b850f916353f2658ae6f:

  Linux 6.9-rc2 (2024-03-31 14:32:39 -0700)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-04-05


for you to fetch changes up to d1ef8fc18be6adbbffdee06fbb5b33699e2852be:

  drm: fix DRM_DISPLAY_DP_HELPER dependencies (2024-04-04 16:20:57 +0200)


drm-misc-next for v6.10:

Core Changes:
- Fix DRM_DISPLAY_DP_HELPER dependencies.

Driver Changes:
- i2c and polling fixes to ast.
- Small fixes to panthor.
- Allow IRQ to share GPIO pins in bridge/adv7511.


Adam Ford (1):
  drm/bridge: adv7511: Allow IRQ to share GPIO pins

Adrián Larumbe (1):
  ABI: sysfs-driver-panfrost-profiling: fix indentation problem

Arnd Bergmann (1):
  drm: fix DRM_DISPLAY_DP_HELPER dependencies

Boris Brezillon (3):
  drm/panthor: Fix IO-page mmap() for 32-bit userspace on 64-bit kernel
  drm/panthor: Fix ordering in _irq_suspend()
  drm/panthor: Drop the dev_enter/exit() sections in 
_irq_suspend/resume()


Chris Morgan (3):
  dt-bindings: vendor-prefix: Add prefix for GameForce
  dt-bindings: display: Add GameForce Chi Panel
  drm/panel: st7703: Add GameForce Chi Panel Support

Christian Hewitt (1):
  drm/meson: vclk: fix calculation of 59.94 fractional rates

Dan Carpenter (3):
  drm/panthor: Fix a couple -ENOMEM error codes
  drm/panthor: Fix error code in panthor_gpu_init()
  drm/panthor: Fix off by one in panthor_fw_get_cs_iface()

Harshit Mogalapalli (2):
  drm/panthor: Fix NULL vs IS_ERR() bug in panthor_probe()
  drm/panthor: Don't return NULL from panthor_vm_get_heap_pool()

Ian Forbes (1):
  drm/vmwgfx: Remove unused code

Liviu Dudau (2):
  drm/panthor: Cleanup unused variable 'cookie'
  drm/panthor: Fix some kerneldoc warnings

Nathan Chancellor (1):
  drm/panthor: Fix clang -Wunused-but-set-variable in tick_ctx_apply()

Thomas Zimmermann (14):
  Merge drm/drm-next into drm-misc-next
  drm/ast: Include  where necessary
  drm/ast: Fail probing if DDC channel could not be initialized
  drm/ast: Remove struct ast_{vga,sil165}_connector
  drm/ast: Allocate instance of struct ast_i2c_chan with managed 
helpers

  drm/ast: Move DDC code to ast_ddc.{c,h}
  drm/ast: Rename struct ast_i2c_chan to struct ast_ddc
  drm/ast: Pass AST device to ast_ddc_create()
  drm/ast: Store AST device in struct ast_ddc
  drm/ast: Rename struct i2c_algo_bit_data callbacks and their 
parameters

  drm/ast: Acquire I/O-register lock in DDC code
  drm/ast: Use drm_connector_helper_get_modes()
  drm/ast: Implement polling for VGA and SIL164 connectors
  drm/ast: Automatically clean up poll helper

 .../ABI/testing/sysfs-driver-panfrost-profiling|   10 +
 .../bindings/display/bridge/lvds-codec.yaml|1 +
 .../bindings/display/panel/ilitek,ili9881c.yaml|1 +
 .../bindings/display/panel/novatek,nt35950.yaml|3 +-
 .../bindings/display/panel/novatek,nt36523.yaml|   25 +-
 .../bindings/display/panel/panel-common-dual.yaml  |   47 +
 .../bindings/display/panel/panel-simple-dsi.yaml   |2 +
 .../bindings/display/panel/panel-simple.yaml   |4 +
 .../display/panel/rocktech,jh057n00900.yaml|2 +
 .../bindings/display/panel/sony,td4353-jdi.yaml|2 +
 .../bindings/gpu/arm,mali-valhall-csf.yaml |  147 +
 .../devicetree/bindings/vendor-prefixes.yaml   |4 +
 Documentation/gpu/driver-uapi.rst  |5 +
 Documentation/gpu/panfrost.rst |9 +
 MAINTAINERS|  183 +-
 arch/m68k/include/asm/pgtable.h|2 +
 arch/parisc/configs/generic-32bit_defconfig|2 +-
 drivers/gpu/drm/Kconfig|   23 +-
 drivers/gpu/drm/Makefile   |   29 +
 drivers/gpu/drm/amd/amdgpu/Kconfig |   12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |6 +
 drivers/gpu/drm/ast/Makefile   |   10 +-
 drivers/gpu/drm/ast/{ast_i2c.c => ast_ddc.c}   |  120 +-
 drivers/gpu/drm/ast/ast_ddc.h  |   20 +
 drivers/gpu/drm/ast/ast_drv.c  |1 +
 drivers/gpu/drm/ast/ast_drv.h  |   39 +-
 drivers/gpu/drm/ast/ast_main.c |1 +
 drivers/gpu/drm/ast/ast_mode.c |  147 +-
 

[rebase 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-04-04 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 22b80004574f..558e9b7404b5 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -618,6 +631,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[rebase 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-04-04 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 89c26db0730e..f2d18695c21d 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -674,6 +674,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -817,14 +828,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index ad04b94c52ee..be65bf9fbd48 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6854,6 +6855,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 0f4bd5710796..563637f20abf 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -730,6 +730,9 @@ struct intel_plane_state {
struct intel_fb_view view;
u32 phys_dma_addr; /* for cursor_needs_physical */
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[rebase 1/3] drm: Add drm_vblank_work_flush_all().

2024-04-04 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..ff86f2b2e052 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[PULL] drm-misc-next

2024-03-28 Thread Maarten Lankhorst

Hi Dave, Sima,

Happy easter!!

Cheers,
~Maarten

drm-misc-next-2024-03-28:
drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-28


for you to fetch changes up to 4b2d588d8a7520b414290312c9b40bca48b15e39:

  drm: DRM_WERROR should depend on DRM (2024-03-28 12:36:04 +0200)


drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.


Adrián Larumbe (2):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
  drm/panfrost: Only display fdinfo's engine and cycle tags when 
profiling is on


Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Arnd Bergmann (1):
  drm/imagination: avoid -Woverflow warning

Boris Brezillon (18):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue
  drm/panthor: Fix the CONFIG_PM=n case
  drm/panthor: Fix wrong kernel-doc format in the uAPI header

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Colin Ian King (1):
  drm/panthor: Fix spelling mistake "readyness" -> "readiness"

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (2):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert

  drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

Geert Uytterhoeven (2):
  m68k: pgtable: Add missing #include 
  drm: DRM_WERROR should depend on DRM

Heiko Stuebner (2):
  drm/panel: ltk050h3146w: add MIPI_DSI_MODE_VIDEO to LTK050H3148W 
flags
  drm/panel: ltk050h3146w: drop duplicate commands from 
LTK050H3148W init


Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  drm/dp_mst: fix drm_dp_mst_helper.h kernel-doc
  drm/crc: make drm_debugfs_crc.h self-contained and fix kernel-doc
  drm: fix drm_format_helper.h kernel-doc warnings
  drm/lease: make drm_lease.h self-contained
  drm: fix drm_gem_vram_helper.h kernel-doc
  drm/of: make drm_of.h self-contained
  drm/suballoc: fix drm_suballoc.h kernel-doc
  drm: add missing header guards to 

[PULL] drm-misc-next

2024-03-28 Thread Maarten Lankhorst

Hi Dave, Sima,

Happy easter!!

Cheers,
~Maarten

drm-misc-next-2024-03-28:
drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-28


for you to fetch changes up to 4b2d588d8a7520b414290312c9b40bca48b15e39:

  drm: DRM_WERROR should depend on DRM (2024-03-28 12:36:04 +0200)


drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.


Adrián Larumbe (2):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
  drm/panfrost: Only display fdinfo's engine and cycle tags when 
profiling is on


Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Arnd Bergmann (1):
  drm/imagination: avoid -Woverflow warning

Boris Brezillon (18):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue
  drm/panthor: Fix the CONFIG_PM=n case
  drm/panthor: Fix wrong kernel-doc format in the uAPI header

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Colin Ian King (1):
  drm/panthor: Fix spelling mistake "readyness" -> "readiness"

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (2):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert

  drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

Geert Uytterhoeven (2):
  m68k: pgtable: Add missing #include 
  drm: DRM_WERROR should depend on DRM

Heiko Stuebner (2):
  drm/panel: ltk050h3146w: add MIPI_DSI_MODE_VIDEO to LTK050H3148W 
flags
  drm/panel: ltk050h3146w: drop duplicate commands from 
LTK050H3148W init


Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  drm/dp_mst: fix drm_dp_mst_helper.h kernel-doc
  drm/crc: make drm_debugfs_crc.h self-contained and fix kernel-doc
  drm: fix drm_format_helper.h kernel-doc warnings
  drm/lease: make drm_lease.h self-contained
  drm: fix drm_gem_vram_helper.h kernel-doc
  drm/of: make drm_of.h self-contained
  drm/suballoc: fix drm_suballoc.h kernel-doc
  drm: add missing header guards to 

[PULL] drm-misc-next

2024-03-28 Thread Maarten Lankhorst

Hi Dave, Sima,

Happy easter!!

Cheers,
~Maarten

drm-misc-next-2024-03-28:
drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-28


for you to fetch changes up to 4b2d588d8a7520b414290312c9b40bca48b15e39:

  drm: DRM_WERROR should depend on DRM (2024-03-28 12:36:04 +0200)


drm-misc-next for v6.10-rc1:

The deal of a lifetime! You get ALL of the previous
drm-misc-next-2024-03-21-1 tag!!

But WAIT, there's MORE!

Cross-subsystem Changes:
- Assorted DT binding updates.

Core Changes:
- Clarify how optional wait_hpd_asserted is.
- Shuffle Kconfig names around.

Driver Changes:
- Assorted build fixes for panthor, imagination,
- Add AUO B120XAN01.0 panels.
- Assorted small fixes to panthor, panfrost.


Adrián Larumbe (2):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
  drm/panfrost: Only display fdinfo's engine and cycle tags when 
profiling is on


Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Arnd Bergmann (1):
  drm/imagination: avoid -Woverflow warning

Boris Brezillon (18):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue
  drm/panthor: Fix the CONFIG_PM=n case
  drm/panthor: Fix wrong kernel-doc format in the uAPI header

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Colin Ian King (1):
  drm/panthor: Fix spelling mistake "readyness" -> "readiness"

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (2):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert

  drm/dp: Clarify that wait_hpd_asserted() is not optional for panels

Geert Uytterhoeven (2):
  m68k: pgtable: Add missing #include 
  drm: DRM_WERROR should depend on DRM

Heiko Stuebner (2):
  drm/panel: ltk050h3146w: add MIPI_DSI_MODE_VIDEO to LTK050H3148W 
flags
  drm/panel: ltk050h3146w: drop duplicate commands from 
LTK050H3148W init


Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  drm/dp_mst: fix drm_dp_mst_helper.h kernel-doc
  drm/crc: make drm_debugfs_crc.h self-contained and fix kernel-doc
  drm: fix drm_format_helper.h kernel-doc warnings
  drm/lease: make drm_lease.h self-contained
  drm: fix drm_gem_vram_helper.h kernel-doc
  drm/of: make drm_of.h self-contained
  drm/suballoc: fix drm_suballoc.h kernel-doc
  drm: add missing header guards to 

[PULL] drm-misc-next

2024-03-21 Thread Maarten Lankhorst

drm-misc-next-2024-03-21-1:
drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-21-1


for you to fetch changes up to 5e842d55bad7794823a50f24fd645b58f2ef93ab:

  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert (2024-03-20 08:26:18 -0700)



drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.


Adrián Larumbe (1):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs

Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Boris Brezillon (16):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (1):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert


Geert Uytterhoeven (1):
  m68k: pgtable: Add missing #include 

Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  

[PULL] drm-misc-next

2024-03-21 Thread Maarten Lankhorst

drm-misc-next-2024-03-21-1:
drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-21-1


for you to fetch changes up to 5e842d55bad7794823a50f24fd645b58f2ef93ab:

  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert (2024-03-20 08:26:18 -0700)



drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.


Adrián Larumbe (1):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs

Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Boris Brezillon (16):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (1):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert


Geert Uytterhoeven (1):
  m68k: pgtable: Add missing #include 

Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  

[PULL] drm-misc-next

2024-03-21 Thread Maarten Lankhorst

drm-misc-next-2024-03-21-1:
drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.
The following changes since commit b9511c6d277c31b13d4f3128eba46f4e0733d734:

  Merge tag 'drm-msm-next-2024-03-07' of 
https://gitlab.freedesktop.org/drm/msm into drm-next (2024-03-08 
12:45:21 +1000)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-2024-03-21-1


for you to fetch changes up to 5e842d55bad7794823a50f24fd645b58f2ef93ab:

  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert (2024-03-20 08:26:18 -0700)



drm-misc-next for v6.10:

UAPI Changes:
- Move some nouveau magic constants to uapi.

Cross-subsystem Changes:
- Move drm-misc to gitlab and freedesktop hosting.
- Add entries for panfrost.

Core Changes:
- Improve placement for TTM bo's in idle/busy handling.
- Improve drm/bridge init ordering.
- Add CONFIG_DRM_WERROR, and use W=1 for drm.
- Assorted documentation updates.
- Make more (drm and driver) headers self-contained and add header
  guards.
- Grab reservation lock in pin/unpin callbacks.
- Fix reservation lock handling for vmap.
- Add edp and edid panel matching, use it to fix a nearly identical
  panel.

Driver Changes:
- Add drm/panthor driver and assorted fixes.
- Assorted small fixes to xlnx, panel-edp, tidss, ci, nouveau,
  panel and bridge drivers.
- Add Samsung s6e3fa7, BOE NT116WHM-N44, CMN N116BCA-EA1,
  CrystalClear CMT430B19N00, Startek KD050HDFIA020-C020A,
  powertip PH128800T006-ZHC01 panels.
- Fix console for omapdrm.


Adrián Larumbe (1):
  drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs

Andrew Halaney (1):
  drm/tidss: Use dev_err_probe() over dev_dbg() when failing to 
probe the port


Andy Shevchenko (1):
  drm/gma500: Remove unused intel-mid.h

Boris Brezillon (16):
  drm/panthor: Add uAPI
  drm/panthor: Add GPU register definitions
  drm/panthor: Add the device logical block
  drm/panthor: Add the GPU logical block
  drm/panthor: Add GEM logical block
  drm/panthor: Add the devfreq logical block
  drm/panthor: Add the MMU/VM logical block
  drm/panthor: Add the FW logical block
  drm/panthor: Add the heap logical block
  drm/panthor: Add the scheduler logical block
  drm/panthor: Add the driver frontend block
  drm/panthor: Allow driver compilation
  drm/panthor: Add an entry to MAINTAINERS
  drm/panthor: Fix panthor_devfreq kerneldoc
  drm/panthor: Explicitly include mm.h for the {virt, 
__phys)_to_pfn() defs

  drm/panthor: Fix undefined panthor_device_suspend/resume symbol issue

Christian König (3):
  drm/ttm: improve idle/busy handling v5
  drm/amdgpu: use GTT only as fallback for VRAM|GTT
  drm/ttm: warn when resv objs are mixed in a bulk_move

Dmitry Baryshkov (1):
  dt-bindings: display/lvds-codec: add ti,sn65lvds94

Douglas Anderson (1):
  drm/panel: atna33xc20: Fix unbalanced regulator in the case HPD 
doesn't assert


Geert Uytterhoeven (1):
  m68k: pgtable: Add missing #include 

Hsin-Yi Wang (5):
  drm_edid: Add a function to get EDID base block
  drm/edid: Add a function to match EDID with identity
  drm/edid: Match edid quirks with identity
  drm/panel-edp: Match edp_panels with panel identity
  drm/panel-edp: Fix AUO 0x405c panel naming and add a variant

Jagan Teki (2):
  drm/bridge: Fix improper bridge init order with pre_enable_prev_first
  drm/bridge: Document bridge init order with pre_enable_prev_first

Jani Nikula (29):
  drm: enable (most) W=1 warnings by default across the subsystem
  drm: Add CONFIG_DRM_WERROR
  drm/crtc: make drm_crtc_internal.h self-contained
  drm: add missing header guards to drm_internal.h
  drm/kunit: fix drm_kunit_helpers.h kernel-doc
  drm/amdgpu: make amd_asic_type.h self-contained
  drm: bridge: samsung-dsim: make samsung-dsim.h self-contained
  

[PATCH v2 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-03-05 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index f8b33999d43f..9021c0c1683d 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -654,6 +654,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -797,14 +808,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index ab2f52d21bad..1b56197a1183 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -65,6 +65,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6784,6 +6785,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 860e867586f4..9b7113cd86fc 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -721,6 +721,9 @@ struct intel_plane_state {
 
struct intel_fb_view view;
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[PATCH v2 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-03-05 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Changes since previous version:
- Call the memset for plane state immediately when scheduling vblank,
  this prevents a use-after-free in cursor cleanup.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409..ab01c2d15afd 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1176,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e..5a897cf6fa02 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 25593f6aae7d..7f935c88726e 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -616,6 +629,24 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->uapi.event = NULL;
}
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state;
+   int i;
+
+   for_each_old_intel_plane_in_state(state, plane, 
old_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base &&
+

[PATCH v2 0/3] drm/i915: Unpin cursor fb only after vblank.

2024-03-05 Thread Maarten Lankhorst
Fix legacy cursor updates on xe by enforcing wait between updating
registers and unpin.

In comparison with previous version, there was a small bug in the
atomic unpin path. In intel_plane_cleanup_fb we tried to deference
plane_state after calling vblank schedule. Remove plane from atomic
state immediately after scheduling to prevent this issue. It's unsafe
to deference plane_state as soon as schedule occured.

Maarten Lankhorst (2):
  drm: Add drm_vblank_work_flush_all().
  drm/i915: Use the same vblank worker for atomic unpin

Ville Syrjälä (1):
  drm/i915: Use vblank worker to unpin old legacy cursor fb safely

 drivers/gpu/drm/drm_vblank_work.c | 22 +
 .../gpu/drm/i915/display/intel_atomic_plane.c | 13 +++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 31 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 ++--
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 drivers/gpu/drm/i915/display/intel_display.c  |  3 ++
 .../drm/i915/display/intel_display_types.h|  3 ++
 include/drm/drm_vblank_work.h |  2 ++
 9 files changed, 102 insertions(+), 3 deletions(-)

-- 
2.43.0



[PATCH v2 1/3] drm: Add drm_vblank_work_flush_all().

2024-03-05 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..ff86f2b2e052 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



Re: [PATCH 6/6] drm/xe/stolen: ignore first page for FBC

2024-02-16 Thread Maarten Lankhorst




On 2024-02-15 18:44, Matthew Auld wrote:

Seems like we can potentially hit underruns if the CFB offset is within
the first page of stolen. Just like i915 skip the first page.

BSpec: 50214
Reported-by: Matt Roper 
Signed-off-by: Matthew Auld 
---
  drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h 
b/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
index bd233007c1b7..003474cfdf31 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
@@ -19,6 +19,9 @@ static inline int i915_gem_stolen_insert_node_in_range(struct 
xe_device *xe,
int err;
u32 flags = XE_BO_CREATE_PINNED_BIT | XE_BO_CREATE_STOLEN_BIT;
  
+	if (start < SZ_4K)

+   start = SZ_4K;
+
if (align)
size = ALIGN(size, align);
  

Should start also be aligned?

If that's taken care of by other code, for both patches:
Reviewed-by: Maarten Lankhorst 


Re: [PATCH 5/5] drm/xe/hdcp: Add intel_hdcp_gsc_message to Makefile

2024-02-16 Thread Maarten Lankhorst

Hey,

Where is xe_hdcp_gsc_message.c defined in this series?

I would move this part there.

On 2024-02-09 11:14, Suraj Kandpal wrote:

Add intel_hdcp_gsc_message to Makefile and add corresponding
changes to xe_hdcp_gsc.c to make it build.

Signed-off-by: Suraj Kandpal 
---
  drivers/gpu/drm/xe/Makefile  |  1 +
  drivers/gpu/drm/xe/display/xe_hdcp_gsc.c | 18 ++
  2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index c531210695db..2b654c908ff3 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -254,6 +254,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_global_state.o \
i915-display/intel_gmbus.o \
i915-display/intel_hdcp.o \
+   i915-display/intel_hdcp_gsc_message.o \
i915-display/intel_hdmi.o \
i915-display/intel_hotplug.o \
i915-display/intel_hotplug_irq.o \
diff --git a/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c 
b/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
index aa8c13916bb6..f185465d5682 100644
--- a/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
+++ b/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
@@ -5,9 +5,11 @@
  
  #include 

  #include 
+#include 
  
  #include "abi/gsc_command_header_abi.h"

  #include "intel_hdcp_gsc.h"
+#include "intel_hdcp_gsc_message.h"
  #include "xe_device_types.h"
  #include "xe_gt.h"
  #include "xe_gsc_proxy.h"
@@ -113,6 +115,22 @@ static int intel_hdcp_gsc_hdcp2_init(struct xe_device *xe)
return ret;
  }
  
+static const struct i915_hdcp_ops gsc_hdcp_ops = {

+   .initiate_hdcp2_session = intel_hdcp_gsc_initiate_session,
+   .verify_receiver_cert_prepare_km =
+   intel_hdcp_gsc_verify_receiver_cert_prepare_km,
+   .verify_hprime = intel_hdcp_gsc_verify_hprime,
+   .store_pairing_info = intel_hdcp_gsc_store_pairing_info,
+   .initiate_locality_check = intel_hdcp_gsc_initiate_locality_check,
+   .verify_lprime = intel_hdcp_gsc_verify_lprime,
+   .get_session_key = intel_hdcp_gsc_get_session_key,
+   .repeater_check_flow_prepare_ack =
+   intel_hdcp_gsc_repeater_check_flow_prepare_ack,
+   .verify_mprime = intel_hdcp_gsc_verify_mprime,
+   .enable_hdcp_authentication = intel_hdcp_gsc_enable_authentication,
+   .close_hdcp_session = intel_hdcp_gsc_close_session,
+};
The changes to xe_hdcp_gsc seems like it should be part of the previous 
commit?


Presumably also useful to reorder the Makefile change to before 4/5.

Cheers,
Maarten


[CI 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-02-02 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 28 ++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 28 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 76d77d5a0409f..06c5d82624433 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,21 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
+   /*
+* This branch can only ever be called after plane update is succesful,
+* the error path will not cause unpin_work to be set.
+*/
+   if (old_plane_state->unpin_work.vblank) {
+   int i = drm_plane_index(old_plane_state->uapi.plane);
+
+   /*
+* Remove plane from atomic commit,
+* free is done from vblank worker
+*/
+   memset(>base.planes[i], 0, sizeof(*state->base.planes));
+   return;
+   }
+
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1191,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e6..5a897cf6fa021 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 25593f6aae7de..cafe7e86a7feb 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -500,6 +500,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_vblank_evade_init(old_crtc_state, new_crtc_state, );
 
if (drm_WARN_ON(_priv->drm, drm_crtc_vblank_get(>base)))
@@ -616,6 +629,21 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->ua

[CI 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-02-02 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index f8b33999d43fc..9021c0c1683d6 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -654,6 +654,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -797,14 +808,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
intel_psr_unlock(crtc_state);
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index a92e959c8ac7b..36425889b5bc2 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -64,6 +64,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6780,6 +6781,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index ae2e8cff9d691..5fdb9eccab5a6 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -713,6 +713,9 @@ struct intel_plane_state {
 
struct intel_fb_view view;
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[CI 1/3] drm: Add drm_vblank_work_flush_all().

2024-02-02 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6fb..ff86f2b2e052e 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4ff..e04d436b72973 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



Re: [PATCH] drm/xe/display: Fix memleak in display initialization

2024-02-01 Thread Maarten Lankhorst




On 2024-01-31 16:07, Jani Nikula wrote:

On Wed, 31 Jan 2024, Lucas De Marchi  wrote:

+Jani

On Fri, Jan 26, 2024 at 11:34:53PM +0800, wangxiaoming321 wrote:

intel_power_domains_init has been called twice in xe_device_probe:
xe_device_probe -> xe_display_init_nommio -> intel_power_domains_init(xe)
xe_device_probe -> xe_display_init_noirq -> intel_display_driver_probe_noirq
-> intel_power_domains_init(i915)


ok, once upon a time intel_power_domains_init() was called by the driver
initialization code and not initialized inside the display. I think.
Now it's part of the display probe and we never updated the xe side.



It needs remove one to avoid power_domains->power_wells double malloc.

unreferenced object 0x88811150ee00 (size 512):
  comm "systemd-udevd", pid 506, jiffies 4294674198 (age 3605.560s)
  hex dump (first 32 bytes):
10 b4 9d a0 ff ff ff ff ff ff ff ff ff ff ff ff  
ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00  
  backtrace:
[] __kmem_cache_alloc_node+0x1c1/0x2b0
[] __kmalloc+0x52/0x150
[] __set_power_wells+0xc3/0x360 [xe]
[] xe_display_init_nommio+0x4c/0x70 [xe]
[] xe_device_probe+0x3c/0x5a0 [xe]
[] xe_pci_probe+0x33f/0x5a0 [xe]
[] local_pci_probe+0x47/0xa0
[] pci_device_probe+0xc3/0x1f0
[] really_probe+0x1a2/0x410
[] __driver_probe_device+0x78/0x160
[] driver_probe_device+0x1e/0x90
[] __driver_attach+0xda/0x1d0
[] bus_for_each_dev+0x7c/0xd0
[] bus_add_driver+0x119/0x220
[] driver_register+0x60/0x120
[] 0xa05e50a0



This will need a Fixes trailer.  This seems to be a suitable one:

Fixes: 44e694958b95 ("drm/xe/display: Implement display support")


Signed-off-by: wangxiaoming321 
---
drivers/gpu/drm/xe/xe_display.c | 6 --
1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_display.c b/drivers/gpu/drm/xe/xe_display.c
index 74391d9b11ae..e4db069f0db3 100644
--- a/drivers/gpu/drm/xe/xe_display.c
+++ b/drivers/gpu/drm/xe/xe_display.c
@@ -134,8 +134,6 @@ static void xe_display_fini_nommio(struct drm_device *dev, 
void *dummy)

int xe_display_init_nommio(struct xe_device *xe)
{
-   int err;
-
if (!xe->info.enable_display)
return 0;

@@ -145,10 +143,6 @@ int xe_display_init_nommio(struct xe_device *xe)
/* This must be called before any calls to HAS_PCH_* */
intel_detect_pch(xe);

-   err = intel_power_domains_init(xe);
-   if (err)
-   return err;


xe_display_init_nommio() has xe_display_fini_nommio() as its destructor
counter part. Unfortunately display side looks wrong as it does:

init:
intel_display_driver_probe_noirq() -> intel_power_domains_init()

destroy:
i915_driver_late_release() -> intel_power_domains_cleanup()

I think leaving intel_power_domains_cleanup() as is for now so it's
called by xe works, but this needs to go through CI, which apparently
this series didn't go. I re-triggered it.

+Jani if he thinks this can be changed in another way or already have
the complete solution.


I don't. But it is and will be a recurring problem. i915 and xe core
drivers should handle display init and cleanup the same way. But
currently i915 goes on to call e.g. intel_power_domains_cleanup()
directly from top level driver code. There are other examples.

And we seem to have recently added *more*. See e.g. bd738d859e71
("drm/i915: Prevent modesets during driver init/shutdown").
That commit seems terrible Should we instead not only enable any code 
that can cause modesets after it's safe to do so?


Cheers,
~Maarten


[CI 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-01-31 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 28 ++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 28 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 06c2455bdd788..cb4153ca1867b 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,21 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
+   /*
+* This branch can only ever be called after plane update is succesful,
+* the error path will not cause unpin_work to be set.
+*/
+   if (old_plane_state->unpin_work.vblank) {
+   int i = drm_plane_index(old_plane_state->uapi.plane);
+
+   /*
+* Remove plane from atomic commit,
+* free is done from vblank worker
+*/
+   memset(>base.planes[i], 0, sizeof(*state->base.planes));
+   return;
+   }
+
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1191,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e6..5a897cf6fa021 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 8a84a31c7b48a..13fa7423b029c 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -566,6 +566,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_crtc_vblank_evade_scanlines(state, crtc, , , 
_start);
if (min <= 0 || max <= 0)
goto irq_disable;
@@ -728,6 +741,21 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->ua

[CI 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-01-31 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 926e2de00eb58..64bdf0eb7943c 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -635,6 +635,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -762,14 +773,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
local_irq_enable();
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index b10aad15a63d9..b3d73ded097c4 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -64,6 +64,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6771,6 +6772,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 3fdd8a5179831..b7faeeb5ddc1c 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -713,6 +713,9 @@ struct intel_plane_state {
 
struct intel_fb_view view;
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[CI 1/3] drm: Add drm_vblank_work_flush_all().

2024-01-31 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6fb..ff86f2b2e052e 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4ff..e04d436b72973 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



[[CI] 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely

2024-01-31 Thread Maarten Lankhorst
From: Ville Syrjälä 

The cursor hardware only does sync updates, and thus the hardware
will be scanning out from the old fb until the next start of vblank.
So in order to make the legacy cursor fastpath actually safe we
should not unpin the old fb until we're sure the hardware has
ceased accessing it. The simplest approach is to just use a vblank
work here to do the delayed unpin.

Not 100% sure it's a good idea to put this onto the same high
priority vblank worker as eg. our timing critical gamma updates.
But let's keep it simple for now, and it we later discover that
this is causing problems we can think about adding a lower
priority worker for such things.

This patch is slightly reworked by Maarten

Cc: Maarten Lankhorst 
Signed-off-by: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/display/intel_cursor.c   | 26 +--
 drivers/gpu/drm/i915/display/intel_display.c  |  3 +++
 .../drm/i915/display/intel_display_types.h|  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 926e2de00eb58..64bdf0eb7943c 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -635,6 +635,17 @@ static bool intel_cursor_format_mod_supported(struct 
drm_plane *_plane,
return format == DRM_FORMAT_ARGB;
 }
 
+static void intel_cursor_unpin_work(struct kthread_work *base)
+{
+   struct drm_vblank_work *work = to_drm_vblank_work(base);
+   struct intel_plane_state *plane_state =
+   container_of(work, typeof(*plane_state), unpin_work);
+   struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+
+   intel_plane_unpin_fb(plane_state);
+   intel_plane_destroy_state(>base, _state->uapi);
+}
+
 static int
 intel_legacy_cursor_update(struct drm_plane *_plane,
   struct drm_crtc *_crtc,
@@ -762,14 +773,25 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
local_irq_enable();
 
-   intel_plane_unpin_fb(old_plane_state);
+   if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+   drm_vblank_work_init(_plane_state->unpin_work, >base,
+intel_cursor_unpin_work);
+
+   drm_vblank_work_schedule(_plane_state->unpin_work,
+
drm_crtc_accurate_vblank_count(>base) + 1,
+false);
+
+   old_plane_state = NULL;
+   } else {
+   intel_plane_unpin_fb(old_plane_state);
+   }
 
 out_free:
if (new_crtc_state)
intel_crtc_destroy_state(>base, _crtc_state->uapi);
if (ret)
intel_plane_destroy_state(>base, _plane_state->uapi);
-   else
+   else if (old_plane_state)
intel_plane_destroy_state(>base, _plane_state->uapi);
return ret;
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index b10aad15a63d9..b3d73ded097c4 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -64,6 +64,7 @@
 #include "intel_crt.h"
 #include "intel_crtc.h"
 #include "intel_crtc_state_dump.h"
+#include "intel_cursor.h"
 #include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display_driver.h"
@@ -6771,6 +6772,8 @@ static void intel_commit_modeset_disables(struct 
intel_atomic_state *state)
continue;
 
intel_crtc_disable_planes(state, crtc);
+
+   drm_vblank_work_flush_all(>base);
}
 
/* Only disable port sync and MST slaves */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 3fdd8a5179831..b7faeeb5ddc1c 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -713,6 +713,9 @@ struct intel_plane_state {
 
struct intel_fb_view view;
 
+   /* for legacy cursor fb unpin */
+   struct drm_vblank_work unpin_work;
+
/* Plane pxp decryption state */
bool decrypt;
 
-- 
2.43.0



[[CI] 3/3] drm/i915: Use the same vblank worker for atomic unpin

2024-01-31 Thread Maarten Lankhorst
In case of legacy cursor update, the cursor VMA needs to be unpinned
only after vblank. This exceeds the lifetime of the whole atomic commit.

Any trick I attempted to keep the atomic commit alive didn't work, as
drm_atomic_helper_setup_commit() force throttles on any old commit that
wasn't cleaned up.

The only option remaining is to remove the plane from the atomic commit,
and use the same path as the legacy cursor update to clean the state
after vblank.

Signed-off-by: Maarten Lankhorst 
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 28 ++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c | 28 +++
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.h   |  3 ++
 5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 06c2455bdd788..cb4153ca1867b 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -42,6 +42,7 @@
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
 #include "intel_cdclk.h"
+#include "intel_cursor.h"
 #include "intel_display_rps.h"
 #include "intel_display_trace.h"
 #include "intel_display_types.h"
@@ -1163,7 +1164,21 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
intel_display_rps_mark_interactive(dev_priv, state, false);
 
-   /* Should only be called after a successful intel_prepare_plane_fb()! */
+   /*
+* This branch can only ever be called after plane update is succesful,
+* the error path will not cause unpin_work to be set.
+*/
+   if (old_plane_state->unpin_work.vblank) {
+   int i = drm_plane_index(old_plane_state->uapi.plane);
+
+   /*
+* Remove plane from atomic commit,
+* free is done from vblank worker
+*/
+   memset(>base.planes[i], 0, sizeof(*state->base.planes));
+   return;
+   }
+
intel_plane_unpin_fb(old_plane_state);
 }
 
@@ -1176,3 +1191,14 @@ void intel_plane_helper_add(struct intel_plane *plane)
 {
drm_plane_helper_add(>base, _plane_helper_funcs);
 }
+
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state)
+{
+   if (!old_plane_state->ggtt_vma ||
+   old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
+   return;
+
+   drm_vblank_work_init(_plane_state->unpin_work, 
old_plane_state->uapi.crtc,
+intel_cursor_unpin_work);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h 
b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 191dad0efc8e6..5a897cf6fa021 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -66,5 +66,7 @@ int intel_plane_check_src_coordinates(struct 
intel_plane_state *plane_state);
 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state,
   struct intel_plane_state *plane_state);
 void intel_plane_helper_add(struct intel_plane *plane);
+void intel_plane_init_cursor_vblank_work(struct intel_plane_state 
*old_plane_state,
+struct intel_plane_state 
*new_plane_state);
 
 #endif /* __INTEL_ATOMIC_PLANE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 8a84a31c7b48a..13fa7423b029c 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -566,6 +566,19 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
if (intel_crtc_needs_vblank_work(new_crtc_state))
intel_crtc_vblank_work_init(new_crtc_state);
 
+   if (state->base.legacy_cursor_update) {
+   struct intel_plane *plane;
+   struct intel_plane_state *old_plane_state, *new_plane_state;
+   int i;
+
+   for_each_oldnew_intel_plane_in_state(state, plane, 
old_plane_state,
+new_plane_state, i) {
+   if (old_plane_state->uapi.crtc == >base)
+   
intel_plane_init_cursor_vblank_work(old_plane_state,
+   
new_plane_state);
+   }
+   }
+
intel_crtc_vblank_evade_scanlines(state, crtc, , , 
_start);
if (min <= 0 || max <= 0)
goto irq_disable;
@@ -728,6 +741,21 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
new_crtc_state->ua

[[CI] 1/3] drm: Add drm_vblank_work_flush_all().

2024-01-31 Thread Maarten Lankhorst
From: Maarten Lankhorst 

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++
 include/drm/drm_vblank_work.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_vblank_work.c 
b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6fb..ff86f2b2e052e 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_vblank_crtc *vblank = >vblank[drm_crtc_index(crtc)];
+
+   spin_lock_irq(>event_lock);
+   wait_event_lock_irq(vblank->work_wait_queue,
+   waitqueue_active(>work_wait_queue),
+   dev->event_lock);
+   spin_unlock_irq(>event_lock);
+
+   kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index eb41d0810c4ff..e04d436b72973 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, 
struct drm_crtc *crtc,
  void (*func)(struct kthread_work *work));
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
+void drm_vblank_work_flush_all(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0



Re: [PATCH 4/5] drm/xe/xe2: Limit ccs framebuffers to tile4 only

2024-01-31 Thread Maarten Lankhorst

Hey,

On 2024-01-30 20:16, Juha-Pekka Heikkila wrote:

On 29.1.2024 14.02, Matthew Auld wrote:

On 26/01/2024 21:08, Juha-Pekka Heikkila wrote:

Display engine support ccs only with tile4, prevent other modifiers
from using compressed memory. Store pin time pat index to xe_bo.

Signed-off-by: Juha-Pekka Heikkila 
---
  drivers/gpu/drm/xe/display/xe_fb_pin.c | 19 +++
  1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c 
b/drivers/gpu/drm/xe/display/xe_fb_pin.c

index 722c84a56607..b2930a226f54 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -10,9 +10,18 @@
  #include "intel_fb_pin.h"
  #include "xe_ggtt.h"
  #include "xe_gt.h"
+#include "xe_pat.h"
  #include 
+static bool is_compressed(const struct drm_framebuffer *fb)
+{
+    struct xe_bo *bo = intel_fb_obj(fb);
+    struct xe_device *xe = 
to_xe_device(to_intel_framebuffer(fb)->base.dev);

+
+    return xe_pat_index_has_compression(xe, bo->pat_index);
+}
+
  static void
  write_dpt_rotated(struct xe_bo *bo, struct iosys_map *map, u32 
*dpt_ofs, u32 bo_ofs,

    u32 width, u32 height, u32 src_stride, u32 dst_stride)
@@ -349,12 +358,22 @@ void intel_unpin_fb_vma(struct i915_vma *vma, 
unsigned long flags)

  int intel_plane_pin_fb(struct intel_plane_state *plane_state)
  {
  struct drm_framebuffer *fb = plane_state->hw.fb;
+    struct xe_device *xe = 
to_xe_device(to_intel_framebuffer(fb)->base.dev);

  struct xe_bo *bo = intel_fb_obj(fb);
  struct i915_vma *vma;
  /* We reject creating !SCANOUT fb's, so this is weird.. */
  drm_WARN_ON(bo->ttm.base.dev, !(bo->flags & XE_BO_SCANOUT_BIT));
+    if (GRAPHICS_VER(xe) >= 20) {
+    if (fb->modifier != I915_FORMAT_MOD_4_TILED &&
+    is_compressed(fb)) {
+    drm_warn(>drm, "Cannot create ccs framebuffer with 
other than tile4 mofifier\n");

+    return -EINVAL;
+    }
+    bo->pat_index_scanout = bo->pat_index;
+    }


I think this needs to be moved into __xe_pin_fb_vma() after acquiring 
the object lock. Also not sure what prevents vm_bind appearing after 
we drop the lock? Do we need to prevent modifications until the end of 
_xe_unpin_fb_vma()?


I did now put in __xe_unpin_fb_vma()
..
vma->bo->has_sealed_pat_index = false;
..

as well as moved this above block to correct place.
I'm pretty sure this will fail if the BO is pinned more than once 
simultaneously. Should probably be a refcount protected by bo lock instead.


Is the harm from allowing this only having a garbled display?

If so, we might as well allow it, and avoid complicating the bind code 
even more.


Cheers,
~Maarten


[PULL] drm-misc-fixes

2024-01-03 Thread Maarten Lankhorst

Hi Dave, Daniel,

Happy new year!

~Maarten

drm-misc-fixes-2024-01-03:
drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.
The following changes since commit 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2024-01-03

for you to fetch changes up to 11f9eb899ecc8c02b769cf8d2532ba12786a7af7:

  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE 
(2023-12-20 13:26:57 +0100)



drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.


Douglas Anderson (3):
  drm/bridge: parade-ps8640: Never store more than msg->size bytes 
in AUX xfer
  drm/bridge: ti-sn65dsi86: Never store more than msg->size bytes 
in AUX xfer

  drm/bridge: ps8640: Fix size mismatch warning w/ len

Jeffrey Hugo (1):
  accel/qaic: Implement quirk for SOC_HW_VERSION

Jocelyn Falempe (1):
  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE

Pranjal Ramajor Asha Kanojiya (1):
  accel/qaic: Fix GEM import path code

 drivers/accel/qaic/mhi_controller.c  | 15 ++-
 drivers/accel/qaic/qaic_data.c   |  6 ++
 drivers/gpu/drm/bridge/parade-ps8640.c   |  7 ---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c|  4 +++-
 drivers/gpu/drm/mgag200/mgag200_drv.h|  5 +
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 10 +-
 9 files changed, 48 insertions(+), 14 deletions(-)


[PULL] drm-misc-fixes

2024-01-03 Thread Maarten Lankhorst

Hi Dave, Daniel,

Happy new year!

~Maarten

drm-misc-fixes-2024-01-03:
drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.
The following changes since commit 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2024-01-03

for you to fetch changes up to 11f9eb899ecc8c02b769cf8d2532ba12786a7af7:

  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE 
(2023-12-20 13:26:57 +0100)



drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.


Douglas Anderson (3):
  drm/bridge: parade-ps8640: Never store more than msg->size bytes 
in AUX xfer
  drm/bridge: ti-sn65dsi86: Never store more than msg->size bytes 
in AUX xfer

  drm/bridge: ps8640: Fix size mismatch warning w/ len

Jeffrey Hugo (1):
  accel/qaic: Implement quirk for SOC_HW_VERSION

Jocelyn Falempe (1):
  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE

Pranjal Ramajor Asha Kanojiya (1):
  accel/qaic: Fix GEM import path code

 drivers/accel/qaic/mhi_controller.c  | 15 ++-
 drivers/accel/qaic/qaic_data.c   |  6 ++
 drivers/gpu/drm/bridge/parade-ps8640.c   |  7 ---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c|  4 +++-
 drivers/gpu/drm/mgag200/mgag200_drv.h|  5 +
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 10 +-
 9 files changed, 48 insertions(+), 14 deletions(-)


[PULL] drm-misc-fixes

2024-01-03 Thread Maarten Lankhorst

Hi Dave, Daniel,

Happy new year!

~Maarten

drm-misc-fixes-2024-01-03:
drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.
The following changes since commit 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2024-01-03

for you to fetch changes up to 11f9eb899ecc8c02b769cf8d2532ba12786a7af7:

  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE 
(2023-12-20 13:26:57 +0100)



drm-misc-fixes for v6.7 final:
- 2 small qaic fixes.
- Fixes for overflow in aux xfer.
- Fix uninitialised gamma lut in gmag200.
- Small compiler warning fix for backports of a ps8640 fix.


Douglas Anderson (3):
  drm/bridge: parade-ps8640: Never store more than msg->size bytes 
in AUX xfer
  drm/bridge: ti-sn65dsi86: Never store more than msg->size bytes 
in AUX xfer

  drm/bridge: ps8640: Fix size mismatch warning w/ len

Jeffrey Hugo (1):
  accel/qaic: Implement quirk for SOC_HW_VERSION

Jocelyn Falempe (1):
  drm/mgag200: Fix gamma lut not initialized for G200ER, G200EV, G200SE

Pranjal Ramajor Asha Kanojiya (1):
  accel/qaic: Fix GEM import path code

 drivers/accel/qaic/mhi_controller.c  | 15 ++-
 drivers/accel/qaic/qaic_data.c   |  6 ++
 drivers/gpu/drm/bridge/parade-ps8640.c   |  7 ---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c|  4 +++-
 drivers/gpu/drm/mgag200/mgag200_drv.h|  5 +
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  5 +
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 10 +-
 9 files changed, 48 insertions(+), 14 deletions(-)


[PULL] drm-misc-fixes

2023-12-14 Thread Maarten Lankhorst

Hi Dave, Daniel,

Small fixes all over the place, one regression fix for master capability.

Cheers,
~Maarten

drm-misc-fixes-2023-12-14:
drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.
The following changes since commit e0f04e41e8eedd4e5a1275f2318df7e1841855f2:

  drm/atomic-helpers: Invoke end_fb_access while owning plane state 
(2023-12-06 10:51:27 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2023-12-14

for you to fetch changes up to 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)



drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.


Andrzej Kacprowski (1):
  accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization

David Heidelberg (1):
  dt-bindings: panel-simple-dsi: move LG 5" HD TFT LCD panel into 
DSI yaml


Farouk Bouabid (1):
  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w

Jani Nikula (2):
  drm/crtc: fix uninitialized variable use
  drm/edid: also call add modes in EDID connector update fallback

Lingkai Dong (1):
  drm: Fix FD ownership check in drm_master_check_perm()

Ziqi Zhao (1):
  drm/crtc: Fix uninit-value bug in drm_mode_setcrtc

 .../devicetree/bindings/display/panel/panel-simple-dsi.yaml  |  2 ++
 .../devicetree/bindings/display/panel/panel-simple.yaml  |  2 --
 drivers/accel/ivpu/ivpu_hw_37xx.c| 12 
+---

 drivers/gpu/drm/drm_auth.c   |  2 +-
 drivers/gpu/drm/drm_crtc.c   |  8 
 drivers/gpu/drm/drm_edid.c   |  3 ++-
 drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c   |  2 +-
 7 files changed, 19 insertions(+), 12 deletions(-)


[PULL] drm-misc-fixes

2023-12-14 Thread Maarten Lankhorst

Hi Dave, Daniel,

Small fixes all over the place, one regression fix for master capability.

Cheers,
~Maarten

drm-misc-fixes-2023-12-14:
drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.
The following changes since commit e0f04e41e8eedd4e5a1275f2318df7e1841855f2:

  drm/atomic-helpers: Invoke end_fb_access while owning plane state 
(2023-12-06 10:51:27 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2023-12-14

for you to fetch changes up to 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)



drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.


Andrzej Kacprowski (1):
  accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization

David Heidelberg (1):
  dt-bindings: panel-simple-dsi: move LG 5" HD TFT LCD panel into 
DSI yaml


Farouk Bouabid (1):
  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w

Jani Nikula (2):
  drm/crtc: fix uninitialized variable use
  drm/edid: also call add modes in EDID connector update fallback

Lingkai Dong (1):
  drm: Fix FD ownership check in drm_master_check_perm()

Ziqi Zhao (1):
  drm/crtc: Fix uninit-value bug in drm_mode_setcrtc

 .../devicetree/bindings/display/panel/panel-simple-dsi.yaml  |  2 ++
 .../devicetree/bindings/display/panel/panel-simple.yaml  |  2 --
 drivers/accel/ivpu/ivpu_hw_37xx.c| 12 
+---

 drivers/gpu/drm/drm_auth.c   |  2 +-
 drivers/gpu/drm/drm_crtc.c   |  8 
 drivers/gpu/drm/drm_edid.c   |  3 ++-
 drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c   |  2 +-
 7 files changed, 19 insertions(+), 12 deletions(-)


[PULL] drm-misc-fixes

2023-12-14 Thread Maarten Lankhorst

Hi Dave, Daniel,

Small fixes all over the place, one regression fix for master capability.

Cheers,
~Maarten

drm-misc-fixes-2023-12-14:
drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.
The following changes since commit e0f04e41e8eedd4e5a1275f2318df7e1841855f2:

  drm/atomic-helpers: Invoke end_fb_access while owning plane state 
(2023-12-06 10:51:27 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2023-12-14

for you to fetch changes up to 6c9dbee84cd005bed5f9d07b3a2797ae6414b435:

  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w (2023-12-13 
18:33:43 +0100)



drm-misc-fixes for v6.7-rc6:
- Fix regression for checking if FD is master capable.
- Fix uninitialized variables in drm/crtc.
- Fix ivpu w/a.
- Refresh modes correctly when updating EDID.
- Small panel fixes.


Andrzej Kacprowski (1):
  accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization

David Heidelberg (1):
  dt-bindings: panel-simple-dsi: move LG 5" HD TFT LCD panel into 
DSI yaml


Farouk Bouabid (1):
  drm/panel: ltk050h3146w: Set burst mode for ltk050h3148w

Jani Nikula (2):
  drm/crtc: fix uninitialized variable use
  drm/edid: also call add modes in EDID connector update fallback

Lingkai Dong (1):
  drm: Fix FD ownership check in drm_master_check_perm()

Ziqi Zhao (1):
  drm/crtc: Fix uninit-value bug in drm_mode_setcrtc

 .../devicetree/bindings/display/panel/panel-simple-dsi.yaml  |  2 ++
 .../devicetree/bindings/display/panel/panel-simple.yaml  |  2 --
 drivers/accel/ivpu/ivpu_hw_37xx.c| 12 
+---

 drivers/gpu/drm/drm_auth.c   |  2 +-
 drivers/gpu/drm/drm_crtc.c   |  8 
 drivers/gpu/drm/drm_edid.c   |  3 ++-
 drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c   |  2 +-
 7 files changed, 19 insertions(+), 12 deletions(-)


[PULL] drm-misc-fixes

2023-12-07 Thread Maarten Lankhorst

Hi Dave, Daniel,

Pull request for v6.7-rc5.

Cheers,
~Maarten

drm-misc-fixes-2023-12-07:
drm-misc-fixes for v6.7-rc5:
- Document nouveau's GSP-RM.
- Flush vmm harder on nouveau tu102.
- Panfrost fix for imported dma-buf objects, and device frequency.
- Kconfig Build fix for tc358768.
- Call end_fb_access after atomic commit.
The following changes since commit fb18fe0fdf22a2f4512a8b644bb5ea1473829cda:

  drm/panel: nt36523: fix return value check in nt36523_probe() 
(2023-11-29 16:54:23 +0100)


are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2023-12-07

for you to fetch changes up to e0f04e41e8eedd4e5a1275f2318df7e1841855f2:

  drm/atomic-helpers: Invoke end_fb_access while owning plane state 
(2023-12-06 10:51:27 +0100)



drm-misc-fixes for v6.7-rc5:
- Document nouveau's GSP-RM.
- Flush vmm harder on nouveau tu102.
- Panfrost fix for imported dma-buf objects, and device frequency.
- Kconfig Build fix for tc358768.
- Call end_fb_access after atomic commit.


Adrián Larumbe (2):
  drm/panfrost: Consider dma-buf imported objects as resident
  drm/panfrost: Fix incorrect updating of current device frequency

Arnd Bergmann (1):
  drm/bridge: tc358768: select CONFIG_VIDEOMODE_HELPERS

Dave Airlie (1):
  nouveau/tu102: flush all pdbs on vmm flush

Thomas Zimmermann (1):
  drm/atomic-helpers: Invoke end_fb_access while owning plane state

Timur Tabi (1):
  nouveau/gsp: document some aspects of GSP-RM

 drivers/gpu/drm/bridge/Kconfig |  1 +
 drivers/gpu/drm/drm_atomic_helper.c| 78 
+---

 drivers/gpu/drm/i915/display/intel_display.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c|  2 +-
 .../common/shared/msgq/inc/msgq/msgq_priv.h| 51 ++
 drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 82 
++

 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c |  2 +-
 drivers/gpu/drm/panfrost/panfrost_devfreq.c| 17 -
 drivers/gpu/drm/panfrost/panfrost_gem.c|  2 +-
 include/drm/drm_atomic_helper.h|  2 +
 10 files changed, 207 insertions(+), 32 deletions(-)


  1   2   3   4   5   6   7   8   9   10   >