linux/drivers/gpu/drm/xe/display/intel_fb_bo.c
Dave Airlie 33e26f3544 UAPI Changes:
- Add mmap support for PCI memory barrier (Tejas, Matthew Auld)
  - Enable integration with perf pmu, exposing event counters: for now, just
    GT C6 residency (Vinay, Lucas)
  - Add "survivability mode" to allow putting the driver in a state capable of
    firmware upgrade on critical failures (Riana, Rodrigo)
  - Add PXP HWDRM support and enable for compatible platforms:
    Meteor Lake and Lunar Lake (Daniele, John Harrison)
  - Expose package and vram temperature over hwmon subsystem (Raag, Badal, Rodrigo)
 
 Cross-subsystem Changes:
  - Backmege drm-next to synchronize with i915 display and other internal APIs
 
 Display Changes (including i915):
  - Device probe re-order to help with flicker-free boot (Maarten)
  - Align watermark, hpd and dsm with i915 (Rodrigo)
  - Better abstraction for d3cold (Rodrigo)
 
 Driver Changes:
  - Make sure changes to ccs_mode is with helper for gt sync reset (Maciej)
  - Drop mmio_ext abstraction since it didn't prove useful in its current form
    (Matt Roper)
  - Reject BO eviction if BO is bound to current VM (Oak, Thomas Hellström)
  - Add GuC Power Conservation debugfs (Rodrigo)
  - L3 cache topology updates for Xe3 (Francois, Matt Atwood)
  - Better logging about missing GuC logs (John Harrison)
  - Better logging for hwconfig-related data availability (John Harrison)
  - Tracepoint updates for xe_bo_create, xe_vm and xe_vma (Oak)
  - Add missing SPDX licenses (Francois)
  - Xe suballocator imporovements (Michal Wajdeczko)
  - Improve logging for native vs SR-IOV driver mode (Satyanarayana)
  - Make sure VF bootstrap is not attempted in execlist mode (Maarten)
  - Add GuC Buffer Cache abstraction for some CTB H2G actions and use
    during VF provisioning (Michal Wajdeczko)
  - Better synchronization in gtidle for new users (Vinay)
  - New workarounds for Panther Lake (Nirmoy, Vinay)
  - PCI ID updates for Panther Lake (Matt Atwood)
  - Enable SR-IOV for Panther Lake (Michal Wajdeczko)
  - Update MAINTAINERS to stop directing xe changes to drm-misc (Lucas)
  - New PCI IDs for Battle Mage (Shekhar)
  - Better pagefault logging (Francois)
  - SR-IOV fixes and refactors for past and new platforms (Michal Wajdeczko)
  - Platform descriptor refactors and updates (Sai Teja)
  - Add gt stats debugfs (Francois)
  - Add guc_log debugfs to dump to dmesg (Lucas)
  - Abstract per-platform LMTT availability (Piotr Piórkowski)
  - Refactor VRAM manager location (Piotr Piórkowski)
  - Add missing xe_pm_runtime_put when forcing wedged mode (Shuicheng)
  - Fix possible lockup when forcing wedged mode (Xin Wang)
  - Probe refactors to use cleanup actions with better error handling (Lucas)
  - XE_IOCTL_DBG clarification for userspace (Maarten)
  - Better xe_mmio initialization and abstraction (Ilia)
  - Drop unnecessary GT lookup (Matt Roper)
  - Skip client engine usage from fdinfo for VFs (Marcin Bernatowicz)
  - Allow to test xe_sync_entry_parse with error injection (Priyanka)
  - OA fix for polled read (Umesh)
 -----BEGIN PGP SIGNATURE-----
 
 iQJNBAABCAA3FiEE6rM8lpABPHM5FqyDm6KlpjDL6lMFAme8uvkZHGx1Y2FzLmRl
 bWFyY2hpQGludGVsLmNvbQAKCRCboqWmMMvqUyHzD/wNKA27p1P3AP4MW18uiLxW
 uR4PrGR1oj9CxIwqRREPUcXxnrxdydSeEso1VUVzFhj8pHpvHJt05VvC4f4Ibf+4
 N/KyJSHFsfhI4QxHjrD7+v0WCs8d1Jpl00PrHkXTI2KREFGAcvYijVGYt5oRdMEv
 YhwJkXPGza6eC3xmvAH6OUah4mfpkA6z2Q6lREGacofL4B9PRtZPIloTuPMfCJ5K
 LKWSDK6suHq7tb40Wb2qsHN2ejTF2Spt3JC//aaBIN5Vo/xnqHgXmr/mAK2oCfjR
 IrpgtwaRKAmfv/ZAH+xrL0Q5/M9Sj0HLUXkCa5NDXEacuDdwOKYOxsAvcSzRlxlF
 iLJR2mJ4AX1K6JECj6blSuklWqX6u1THZuMw7w8ICxWUH3INQMZqjTaNL9ID4IwM
 QM0Q25ruzTRHRSMGut9x3QGoqgmoCJgHqH7C2mz0v6iFgeNp8wxQnHlb5MHmh37F
 35tQCFHLu1agzeR2NBs7CNBN2OTTQVUbtjHV5s/b4MrENspsB6OO54VdRizu7FBX
 8Kyyiaxgu2Q5Qv3ayhoOZZmfrgZ7GMWGbkktmKiyukbnWrfYMBgfoiLoN40QLe5P
 f2cE6kJNJtDvl+/oNmFLkFcFji6pkN6ZrUmlQF8mqMFvZqYOQnqCKWFGugrtC6hZ
 gRkUTimfMUqOePBzE80/WA==
 =WDS6
 -----END PGP SIGNATURE-----

Merge tag 'drm-xe-next-2025-02-24' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-next

UAPI Changes:
 - Add mmap support for PCI memory barrier (Tejas, Matthew Auld)
 - Enable integration with perf pmu, exposing event counters: for now, just
   GT C6 residency (Vinay, Lucas)
 - Add "survivability mode" to allow putting the driver in a state capable of
   firmware upgrade on critical failures (Riana, Rodrigo)
 - Add PXP HWDRM support and enable for compatible platforms:
   Meteor Lake and Lunar Lake (Daniele, John Harrison)
 - Expose package and vram temperature over hwmon subsystem (Raag, Badal, Rodrigo)

Cross-subsystem Changes:
 - Backmege drm-next to synchronize with i915 display and other internal APIs

Display Changes (including i915):
 - Device probe re-order to help with flicker-free boot (Maarten)
 - Align watermark, hpd and dsm with i915 (Rodrigo)
 - Better abstraction for d3cold (Rodrigo)

Driver Changes:
 - Make sure changes to ccs_mode is with helper for gt sync reset (Maciej)
 - Drop mmio_ext abstraction since it didn't prove useful in its current form
   (Matt Roper)
 - Reject BO eviction if BO is bound to current VM (Oak, Thomas Hellström)
 - Add GuC Power Conservation debugfs (Rodrigo)
 - L3 cache topology updates for Xe3 (Francois, Matt Atwood)
 - Better logging about missing GuC logs (John Harrison)
 - Better logging for hwconfig-related data availability (John Harrison)
 - Tracepoint updates for xe_bo_create, xe_vm and xe_vma (Oak)
 - Add missing SPDX licenses (Francois)
 - Xe suballocator imporovements (Michal Wajdeczko)
 - Improve logging for native vs SR-IOV driver mode (Satyanarayana)
 - Make sure VF bootstrap is not attempted in execlist mode (Maarten)
 - Add GuC Buffer Cache abstraction for some CTB H2G actions and use
   during VF provisioning (Michal Wajdeczko)
 - Better synchronization in gtidle for new users (Vinay)
 - New workarounds for Panther Lake (Nirmoy, Vinay)
 - PCI ID updates for Panther Lake (Matt Atwood)
 - Enable SR-IOV for Panther Lake (Michal Wajdeczko)
 - Update MAINTAINERS to stop directing xe changes to drm-misc (Lucas)
 - New PCI IDs for Battle Mage (Shekhar)
 - Better pagefault logging (Francois)
 - SR-IOV fixes and refactors for past and new platforms (Michal Wajdeczko)
 - Platform descriptor refactors and updates (Sai Teja)
 - Add gt stats debugfs (Francois)
 - Add guc_log debugfs to dump to dmesg (Lucas)
 - Abstract per-platform LMTT availability (Piotr Piórkowski)
 - Refactor VRAM manager location (Piotr Piórkowski)
 - Add missing xe_pm_runtime_put when forcing wedged mode (Shuicheng)
 - Fix possible lockup when forcing wedged mode (Xin Wang)
 - Probe refactors to use cleanup actions with better error handling (Lucas)
 - XE_IOCTL_DBG clarification for userspace (Maarten)
 - Better xe_mmio initialization and abstraction (Ilia)
 - Drop unnecessary GT lookup (Matt Roper)
 - Skip client engine usage from fdinfo for VFs (Marcin Bernatowicz)
 - Allow to test xe_sync_entry_parse with error injection (Priyanka)
 - OA fix for polled read (Umesh)

Signed-off-by: Dave Airlie <airlied@redhat.com>

From: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/m3gbuh32wgiep43i4zxbyhxqbenvtgvtao5sczivlasj7tikwv@dmlba4bfg2ny
2025-02-27 10:08:29 +10:00

93 lines
2.2 KiB
C

/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2021 Intel Corporation
*/
#include <drm/drm_modeset_helper.h>
#include <drm/ttm/ttm_bo.h>
#include "intel_display_types.h"
#include "intel_fb.h"
#include "intel_fb_bo.h"
#include "xe_bo.h"
void intel_fb_bo_framebuffer_fini(struct drm_gem_object *obj)
{
struct xe_bo *bo = gem_to_xe_bo(obj);
if (bo->flags & XE_BO_FLAG_PINNED) {
/* Unpin our kernel fb first */
xe_bo_lock(bo, false);
xe_bo_unpin(bo);
xe_bo_unlock(bo);
}
xe_bo_put(bo);
}
int intel_fb_bo_framebuffer_init(struct drm_framebuffer *fb,
struct drm_gem_object *obj,
struct drm_mode_fb_cmd2 *mode_cmd)
{
struct xe_bo *bo = gem_to_xe_bo(obj);
struct xe_device *xe = to_xe_device(bo->ttm.base.dev);
int ret;
/*
* Some modifiers require physical alignment of 64KiB VRAM pages;
* require that the BO in those cases is created correctly.
*/
if (XE_IOCTL_DBG(xe, intel_fb_needs_64k_phys(mode_cmd->modifier[0]) &&
!(bo->flags & XE_BO_FLAG_NEEDS_64K)))
return -EINVAL;
xe_bo_get(bo);
ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
if (ret)
goto err;
if (!(bo->flags & XE_BO_FLAG_SCANOUT)) {
/*
* XE_BO_FLAG_SCANOUT should ideally be set at creation, or is
* automatically set when creating FB. We cannot change caching
* mode when the bo is VM_BINDed, so we can only set
* coherency with display when unbound.
*/
if (XE_IOCTL_DBG(xe, xe_bo_is_vm_bound(bo))) {
ttm_bo_unreserve(&bo->ttm);
ret = -EINVAL;
goto err;
}
bo->flags |= XE_BO_FLAG_SCANOUT;
}
ttm_bo_unreserve(&bo->ttm);
return 0;
err:
xe_bo_put(bo);
return ret;
}
struct drm_gem_object *intel_fb_bo_lookup_valid_bo(struct drm_device *drm,
struct drm_file *filp,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
struct xe_device *xe = to_xe_device(drm);
struct xe_bo *bo;
struct drm_gem_object *gem = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
if (!gem)
return ERR_PTR(-ENOENT);
bo = gem_to_xe_bo(gem);
/* Require vram placement or dma-buf import */
if (IS_DGFX(xe) &&
!xe_bo_can_migrate(bo, XE_PL_VRAM0) &&
bo->ttm.type != ttm_bo_type_sg) {
drm_gem_object_put(gem);
return ERR_PTR(-EREMOTE);
}
return gem;
}