diff options
| author | Thomas Hellström <thomas.hellstrom@linux.intel.com> | 2025-12-19 12:33:06 +0100 |
|---|---|---|
| committer | Thomas Hellström <thomas.hellstrom@linux.intel.com> | 2025-12-23 10:00:47 +0100 |
| commit | e44f47a9bf5104c9b9efcc8fc95a858c66f2d1e6 (patch) | |
| tree | 7cc9a531b31fcebf11c140eaa34c9725b11467c5 /include | |
| parent | 33ac8d150af6be100161ec11106a8dd3f1f5b9e0 (diff) | |
drm/pagemap_util: Add a utility to assign an owner to a set of interconnected gpus
The hmm_range_fault() and the migration helpers currently need a common
"owner" to identify pagemaps and clients with fast interconnect.
Add a drm_pagemap utility to setup such owners by registering
drm_pagemaps, in a registry, and for each new drm_pagemap,
query which existing drm_pagemaps have fast interconnects with the new
drm_pagemap.
The "owner" scheme is limited in that it is static at drm_pagemap creation.
Ideally one would want the owner to be adjusted at run-time, but that
requires changes to hmm. If the proposed scheme becomes too limited,
we need to revisit.
v2:
- Improve documentation of DRM_PAGEMAP_OWNER_LIST_DEFINE(). (Matt Brost)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> # For merging through drm-xe.
Link: https://patch.msgid.link/20251219113320.183860-11-thomas.hellstrom@linux.intel.com
Diffstat (limited to 'include')
| -rw-r--r-- | include/drm/drm_pagemap_util.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/include/drm/drm_pagemap_util.h b/include/drm/drm_pagemap_util.h index 924244d5b899..19169b42b891 100644 --- a/include/drm/drm_pagemap_util.h +++ b/include/drm/drm_pagemap_util.h @@ -6,11 +6,55 @@ #ifndef _DRM_PAGEMAP_UTIL_H_ #define _DRM_PAGEMAP_UTIL_H_ +#include <linux/list.h> +#include <linux/mutex.h> + struct drm_device; struct drm_pagemap; struct drm_pagemap_cache; +struct drm_pagemap_owner; struct drm_pagemap_shrinker; +/** + * struct drm_pagemap_peer - Structure representing a fast interconnect peer + * @list: Pointer to a &struct drm_pagemap_owner_list used to keep track of peers + * @link: List link for @list's list of peers. + * @owner: Pointer to a &struct drm_pagemap_owner, common for a set of peers having + * fast interconnects. + * @private: Pointer private to the struct embedding this struct. + */ +struct drm_pagemap_peer { + struct drm_pagemap_owner_list *list; + struct list_head link; + struct drm_pagemap_owner *owner; + void *private; +}; + +/** + * struct drm_pagemap_owner_list - Keeping track of peers and owners + * @peer: List of peers. + * + * The owner list defines the scope where we identify peers having fast interconnects + * and a common owner. Typically a driver has a single global owner list to + * keep track of common owners for the driver's pagemaps. + */ +struct drm_pagemap_owner_list { + /** @lock: Mutex protecting the @peers list. */ + struct mutex lock; + /** @peers: List of peers. */ + struct list_head peers; +}; + +/* + * Convenience macro to define an owner list. + * Typically the owner list statically declared + * driver-wide. + */ +#define DRM_PAGEMAP_OWNER_LIST_DEFINE(_name) \ + struct drm_pagemap_owner_list _name = { \ + .lock = __MUTEX_INITIALIZER((_name).lock), \ + .peers = LIST_HEAD_INIT((_name).peers) } + void drm_pagemap_shrinker_add(struct drm_pagemap *dpagemap); int drm_pagemap_cache_lock_lookup(struct drm_pagemap_cache *cache); @@ -39,4 +83,10 @@ static inline void drm_pagemap_shrinker_might_lock(struct drm_pagemap *dpagemap) #endif /* CONFIG_PROVE_LOCKING */ +void drm_pagemap_release_owner(struct drm_pagemap_peer *peer); + +int drm_pagemap_acquire_owner(struct drm_pagemap_peer *peer, + struct drm_pagemap_owner_list *owner_list, + bool (*has_interconnect)(struct drm_pagemap_peer *peer1, + struct drm_pagemap_peer *peer2)); #endif |
