mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 16:53:59 -04:00
drm/xe feature pull for v6.9: UAPI Changes: - New query to the GuC firmware submission version. (José Roberto de Souza) - Remove unused persistent exec_queues (Thomas Hellström) - Add vram frequency sysfs attributes (Sujaritha Sundaresan, Rodrigo Vivi) - Add the flag XE_VM_BIND_FLAG_DUMPABLE to notify devcoredump that mapping should be dumped (Maarten Lankhorst) Cross-drivers Changes: - Make sure intel_wakeref_t is treated as opaque type on i915-display and fix its type on xe Driver Changes: - Drop pre-production workarounds (Matt Roper) - Drop kunit tests for unsuported platforms: PVC and pre-production DG2 (Lucas De Marchi) - Start pumbling SR-IOV support with memory based interrupts for VF (Michal Wajdeczko) - Allow to map BO in GGTT with PAT index corresponding to XE_CACHE_UC to work with memory based interrupts (Michal Wajdeczko) - Improve logging with GT-oriented drm_printers (Michal Wajdeczko) - Add GuC Doorbells Manager as prep work SR-IOV during VF provisioning ((Michal Wajdeczko) - Refactor fake device handling in kunit integration ((Michal Wajdeczko) - Implement additional workarounds for xe2 and MTL (Tejas Upadhyay, Lucas De Marchi, Shekhar Chauhan, Karthik Poosa) - Program a few registers according to perfomance guide spec for Xe2 (Shekhar Chauhan) - Add error handling for non-blocking communication with GuC (Daniele Ceraolo Spurio) - Fix remaining 32b build issues and enable it back (Lucas De Marchi) - Fix build with CONFIG_DEBUG_FS=n (Jani Nikula) - Fix warnings from GuC ABI headers (Matthew Brost) - Introduce Relay Communication for SR-IOV for VF <-> GuC <-> PF (Michal Wajdeczko) - Add mocs reset kunit (Ruthuvikas Ravikumar) - Fix spellings (Colin Ian King) - Disable mid-thread preemption when not properly supported by hardware (Nirmoy Das) - Release mmap mappings on rpm suspend (Badal Nilawar) - Fix BUG_ON on xe_exec by moving fence reservation to the validate stage (Matthew Auld) - Fix xe_exec by reserving extra fence slot for CPU bind (Matthew Brost) - Fix xe_exec with full long running exec queue, now returning -EWOULDBLOCK to userspace (Matthew Brost) - Fix CT irq handler when CT is disabled (Matthew Brost) - Fix VM_BIND_OP_UNMAP_ALL without any bound vmas (Thomas Hellström) - Fix missing __iomem annotations (Thomas Hellström) - Fix exec queue priority handling with GuC (Brian Welty) - Fix setting SLPC flag to GuC when it's not supported (Vinay Belgaumkar) - Fix C6 disabling without SLPC (Matt Roper) - Drop -Wstringop-overflow to fix build with GCC11 (Paul E. McKenney) - Circumvent bogus -Wstringop-overflow in one case (Arnd Bergmann) - Refactor exec_queue user extensions handling and fix USM attributes being applied too late (Brian Welty) - Use circ_buf head/tail convention (Matthew Brost) - Fail build if circ_buf-related defines are modified with incompatible values (Matthew Brost) - Fix several error paths (Dan Carpenter) - Fix CCS copy for small VRAM copy chunks (Thomas Hellström) - Rework driver initialization order and paths to account for driver running in VF mode (Michal Wajdeczko) - Initialize GuC earlier during probe to handle driver in VF mode (Michał Winiarski) - Fix migration use of MI_STORE_DATA_IMM to write PTEs (Matt Roper) - Fix bounds checking in __xe_bo_placement_for_flags (Brian Welty) - Drop display dependency on CONFIG_EXPERT (Jani Nikula) - Do not hand-roll kstrdup when creating snapshot (Michal Wajdeczko) - Stop creating one kunit module per kunit suite (Lucas De Marchi) - Reduce scope and constify variables (Thomas Hellström, Jani Nikula, Michal Wajdeczko) - Improve and document xe_guc_ct_send_recv() (Michal Wajdeczko) - Add proxy communication between CSME and GSC uC (Daniele Ceraolo Spurio) - Fix size calculation when writing pgtable (Fei Yang) - Make sure cfb is page size aligned in stolen memory (Vinod Govindapillai) - Stop printing guc log to dmesg when waiting for GuC fails (Rodrigo Vivi) - Use XE_CACHE_WB instead of XE_CACHE_NONE for cpu coherency on migration (Himal Prasad Ghimiray) - Fix error path in xe_vm_create (Moti Haimovski) - Fix warnings in doc generation (Thomas Hellström, Badal Nilawar) - Improve devcoredump content for mesa debugging (José Roberto de Souza) - Fix crash in trace_dma_fence_init() (José Roberto de Souza) - Improve CT state change handling (Matthew Brost) - Toggle USM support for Xe2 (Lucas De Marchi) - Reduces code duplication to emit PIPE_CONTROL (José Roberto de Souza) - Canonicalize addresses where needed for Xe2 and add to devcoredump (José Roberto de Souza) - Only allow 1 ufence per exec / bind IOCTL (Matthew Brost) - Move all display code to display/ (Jani Nikula) - Fix sparse warnings by correctly using annotations (Thomas Hellström) - Warn on job timeouts instead of using asserts (Matt Roper) - Prefix macros to avoid clashes with sparc (Matthew Brost) - Fix -Walloc-size by subclassing instead of allocating size smaller than struct (Thomas Hellström) - Add status check during gsc header readout (Suraj Kandpal) - Fix infinite loop in vm_bind_ioctl_ops_unwind() (Matthew Brost) - Fix fence refcounting (Matthew Brost) - Fix picking incorrect userptr VMA (Matthew Brost) - Fix USM on integrated by mapping both mem.kernel_bb_pool and usm.bb_pool (Matthew Brost) - Fix double initialization of display power domains (Xiaoming Wang) - Check expected uC versions by major.minor.patch instead of just major.minor (John Harrison) - Bump minimum GuC version to 70.19.2 for all platforms under force-probe (John Harrison) - Add GuC firmware loading for Lunar Lake (John Harrison) - Use kzalloc() instead of hand-rolled alloc + memset (Nirmoy Das) - Fix max page size of VMA during a REMAP (Matthew Brost) - Don't ignore error when pinning pages in kthread (Matthew Auld) - Refactor xe hwmon (Karthik Poosa) - Add debug logs for D3cold (Riana Tauro) - Remove broken TEST_VM_ASYNC_OPS_ERROR (Matthew Brost) - Always allow to override firmware blob with module param and improve log when no firmware is found (Lucas De Marchi) - Fix shift-out-of-bounds due to xe_vm_prepare_vma() accepting zero fences (Thomas Hellström) - Fix shift-out-of-bounds by distinguishing xe_pt/xe_pt_dir subclass (Thomas Hellström) - Fail driver bind if platform supports MSIX, but fails to allocate all of them (Dani Liberman) - Fix intel_fbdev thinking memory is backed by shmem (Matthew Auld) - Prefer drm_dbg() over dev_dbg() (Jani Nikula) - Avoid function cast warnings with clang-16 (Arnd Bergmann) - Enhance xe_bo_move trace (Priyanka Dandamudi) - Fix xe_vma_set_pte_size() not setting the right gpuva.flags for 4K size (Matthew Brost) - Add XE_VMA_PTE_64K VMA flag (Matthew Brost) - Return 2MB page size for compact 64k PTEs (Matthew Brost) - Remove usage of the deprecated ida_simple_xx() API (Christophe JAILLET) - Fix modpost warning on xe_mocs live kunit module (Ashutosh Dixit) - Drop extra newline in from sysfs files (Ashutosh Dixit) - Implement VM snapshot support for BO's and userptr (Maarten Lankhorst) - Add debug logs when skipping rebinds (Matthew Brost) - Fix code generation when mixing build directories (Dafna Hirschfeld) - Prefer struct_size over open coded arithmetic (Erick Archer) Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> From: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/dbdkrwmcoqqlwftuc3olbauazc3pbamj26wa34puztowsnauoh@i3zms7ut4yuw
197 lines
4.5 KiB
C
197 lines
4.5 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2023 Intel Corporation
|
|
*/
|
|
|
|
#include <drm/drm_print.h>
|
|
#include <drm/xe_drm.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/types.h>
|
|
|
|
#include "xe_bo.h"
|
|
#include "xe_bo_types.h"
|
|
#include "xe_device_types.h"
|
|
#include "xe_drm_client.h"
|
|
#include "xe_trace.h"
|
|
|
|
/**
|
|
* xe_drm_client_alloc() - Allocate drm client
|
|
* @void: No arg
|
|
*
|
|
* Allocate drm client struct to track client memory against
|
|
* same till client life. Call this API whenever new client
|
|
* has opened xe device.
|
|
*
|
|
* Return: pointer to client struct or NULL if can't allocate
|
|
*/
|
|
struct xe_drm_client *xe_drm_client_alloc(void)
|
|
{
|
|
struct xe_drm_client *client;
|
|
|
|
client = kzalloc(sizeof(*client), GFP_KERNEL);
|
|
if (!client)
|
|
return NULL;
|
|
|
|
kref_init(&client->kref);
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
spin_lock_init(&client->bos_lock);
|
|
INIT_LIST_HEAD(&client->bos_list);
|
|
#endif
|
|
return client;
|
|
}
|
|
|
|
/**
|
|
* __xe_drm_client_free() - Free client struct
|
|
* @kref: The reference
|
|
*
|
|
* This frees client struct. Call this API when xe device is closed
|
|
* by drm client.
|
|
*
|
|
* Return: void
|
|
*/
|
|
void __xe_drm_client_free(struct kref *kref)
|
|
{
|
|
struct xe_drm_client *client =
|
|
container_of(kref, typeof(*client), kref);
|
|
|
|
kfree(client);
|
|
}
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
/**
|
|
* xe_drm_client_add_bo() - Add BO for tracking client mem usage
|
|
* @client: The drm client ptr
|
|
* @bo: The xe BO ptr
|
|
*
|
|
* Add all BO created by individual drm client by calling this function.
|
|
* This helps in tracking client memory usage.
|
|
*
|
|
* Return: void
|
|
*/
|
|
void xe_drm_client_add_bo(struct xe_drm_client *client,
|
|
struct xe_bo *bo)
|
|
{
|
|
XE_WARN_ON(bo->client);
|
|
XE_WARN_ON(!list_empty(&bo->client_link));
|
|
|
|
spin_lock(&client->bos_lock);
|
|
bo->client = xe_drm_client_get(client);
|
|
list_add_tail_rcu(&bo->client_link, &client->bos_list);
|
|
spin_unlock(&client->bos_lock);
|
|
}
|
|
|
|
/**
|
|
* xe_drm_client_remove_bo() - Remove BO for tracking client mem usage
|
|
* @bo: The xe BO ptr
|
|
*
|
|
* Remove all BO removed by individual drm client by calling this function.
|
|
* This helps in tracking client memory usage.
|
|
*
|
|
* Return: void
|
|
*/
|
|
void xe_drm_client_remove_bo(struct xe_bo *bo)
|
|
{
|
|
struct xe_drm_client *client = bo->client;
|
|
|
|
spin_lock(&client->bos_lock);
|
|
list_del_rcu(&bo->client_link);
|
|
spin_unlock(&client->bos_lock);
|
|
|
|
xe_drm_client_put(client);
|
|
}
|
|
|
|
static void bo_meminfo(struct xe_bo *bo,
|
|
struct drm_memory_stats stats[TTM_NUM_MEM_TYPES])
|
|
{
|
|
u64 sz = bo->size;
|
|
u32 mem_type;
|
|
|
|
if (bo->placement.placement)
|
|
mem_type = bo->placement.placement->mem_type;
|
|
else
|
|
mem_type = XE_PL_TT;
|
|
|
|
if (drm_gem_object_is_shared_for_memory_stats(&bo->ttm.base))
|
|
stats[mem_type].shared += sz;
|
|
else
|
|
stats[mem_type].private += sz;
|
|
|
|
if (xe_bo_has_pages(bo)) {
|
|
stats[mem_type].resident += sz;
|
|
|
|
if (!dma_resv_test_signaled(bo->ttm.base.resv,
|
|
DMA_RESV_USAGE_BOOKKEEP))
|
|
stats[mem_type].active += sz;
|
|
else if (mem_type == XE_PL_SYSTEM)
|
|
stats[mem_type].purgeable += sz;
|
|
}
|
|
}
|
|
|
|
static void show_meminfo(struct drm_printer *p, struct drm_file *file)
|
|
{
|
|
struct drm_memory_stats stats[TTM_NUM_MEM_TYPES] = {};
|
|
struct xe_file *xef = file->driver_priv;
|
|
struct ttm_device *bdev = &xef->xe->ttm;
|
|
struct ttm_resource_manager *man;
|
|
struct xe_drm_client *client;
|
|
struct drm_gem_object *obj;
|
|
struct xe_bo *bo;
|
|
unsigned int id;
|
|
u32 mem_type;
|
|
|
|
client = xef->client;
|
|
|
|
/* Public objects. */
|
|
spin_lock(&file->table_lock);
|
|
idr_for_each_entry(&file->object_idr, obj, id) {
|
|
struct xe_bo *bo = gem_to_xe_bo(obj);
|
|
|
|
bo_meminfo(bo, stats);
|
|
}
|
|
spin_unlock(&file->table_lock);
|
|
|
|
/* Internal objects. */
|
|
spin_lock(&client->bos_lock);
|
|
list_for_each_entry_rcu(bo, &client->bos_list, client_link) {
|
|
if (!bo || !kref_get_unless_zero(&bo->ttm.base.refcount))
|
|
continue;
|
|
bo_meminfo(bo, stats);
|
|
xe_bo_put(bo);
|
|
}
|
|
spin_unlock(&client->bos_lock);
|
|
|
|
for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
|
|
if (!xe_mem_type_to_name[mem_type])
|
|
continue;
|
|
|
|
man = ttm_manager_type(bdev, mem_type);
|
|
|
|
if (man) {
|
|
drm_print_memory_stats(p,
|
|
&stats[mem_type],
|
|
DRM_GEM_OBJECT_RESIDENT |
|
|
(mem_type != XE_PL_SYSTEM ? 0 :
|
|
DRM_GEM_OBJECT_PURGEABLE),
|
|
xe_mem_type_to_name[mem_type]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* xe_drm_client_fdinfo() - Callback for fdinfo interface
|
|
* @p: The drm_printer ptr
|
|
* @file: The drm_file ptr
|
|
*
|
|
* This is callabck for drm fdinfo interface. Register this callback
|
|
* in drm driver ops for show_fdinfo.
|
|
*
|
|
* Return: void
|
|
*/
|
|
void xe_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file)
|
|
{
|
|
show_meminfo(p, file);
|
|
}
|
|
#endif
|