mirror of
https://github.com/torvalds/linux.git
synced 2026-03-13 22:36:17 +01:00
drm/xe: Add xe_ggtt_node_addr() to avoid dereferencing xe_ggtt_node
This function makes it possible to add an offset that is applied to all xe_ggtt_node's, and hides the internals from all its users. Signed-off-by: Maarten Lankhorst <dev@lankhorst.se> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260108101014.579906-12-dev@lankhorst.se
This commit is contained in:
parent
004311aa7d
commit
c818b26515
3 changed files with 18 additions and 3 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <drm/ttm/ttm_tt.h>
|
||||
|
||||
#include "xe_bo_types.h"
|
||||
#include "xe_ggtt.h"
|
||||
#include "xe_macros.h"
|
||||
#include "xe_validation.h"
|
||||
#include "xe_vm_types.h"
|
||||
|
|
@ -252,13 +253,14 @@ static inline u32
|
|||
__xe_bo_ggtt_addr(struct xe_bo *bo, u8 tile_id)
|
||||
{
|
||||
struct xe_ggtt_node *ggtt_node = bo->ggtt_node[tile_id];
|
||||
u64 offset;
|
||||
|
||||
if (XE_WARN_ON(!ggtt_node))
|
||||
return 0;
|
||||
|
||||
XE_WARN_ON(ggtt_node->base.size > xe_bo_size(bo));
|
||||
XE_WARN_ON(ggtt_node->base.start + ggtt_node->base.size > (1ull << 32));
|
||||
return ggtt_node->base.start;
|
||||
offset = xe_ggtt_node_addr(ggtt_node);
|
||||
XE_WARN_ON(offset + xe_bo_size(bo) > (1ull << 32));
|
||||
return offset;
|
||||
}
|
||||
|
||||
static inline u32
|
||||
|
|
|
|||
|
|
@ -1185,3 +1185,14 @@ u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)
|
|||
{
|
||||
return ioread64(ggtt->gsm + (offset / XE_PAGE_SIZE));
|
||||
}
|
||||
|
||||
/**
|
||||
* xe_ggtt_node_addr - Get @node offset in GGTT.
|
||||
* @node: &xe_ggtt_node
|
||||
*
|
||||
* Get the GGTT offset for allocated node.
|
||||
*/
|
||||
u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node)
|
||||
{
|
||||
return node->base.start;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,4 +61,6 @@ void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
|
|||
u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
|
||||
u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
|
||||
|
||||
u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue