Skip to content

Commit

Permalink
drm/xe: Refactor xe_ggtt balloon functions to make the node clear
Browse files Browse the repository at this point in the history
These operations are related to node. Convert them to the
new appropriate name space xe_ggtt_node.

v2: Also move arguments around for consistency (Lucas).
v3: s/node_balloon/node_insert_balloon and
    s/node_deballoon/node_remove_balloon (Michal).

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240821193842.352557-10-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
  • Loading branch information
rodrigovivi committed Aug 22, 2024
1 parent 1363672 commit 15ca094
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
16 changes: 8 additions & 8 deletions drivers/gpu/drm/xe/xe_ggtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,17 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
}

/**
* xe_ggtt_balloon - prevent allocation of specified GGTT addresses
* xe_ggtt_node_insert_balloon - prevent allocation of specified GGTT addresses
* @ggtt: the &xe_ggtt where we want to make reservation
* @node: the &xe_ggtt_node to hold reserved GGTT node
* @start: the starting GGTT address of the reserved region
* @end: then end GGTT address of the reserved region
* @node: the &xe_ggtt_node to hold reserved GGTT node
*
* Use xe_ggtt_deballoon() to release a reserved GGTT node.
* Use xe_ggtt_node_remove_balloon() to release a reserved GGTT node.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
int xe_ggtt_node_insert_balloon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node, u64 start, u64 end)
{
int err;

Expand All @@ -384,18 +384,18 @@ int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_nod
}

/**
* xe_ggtt_deballoon - release a reserved GGTT region
* xe_ggtt_node_remove_balloon - release a reserved GGTT region
* @ggtt: the &xe_ggtt where reserved node belongs
* @node: the &xe_ggtt_node with reserved GGTT region
*
* See xe_ggtt_balloon() for details.
* See xe_ggtt_node_insert_balloon() for details.
*/
void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
void xe_ggtt_node_remove_balloon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
{
if (!drm_mm_node_allocated(&node->base))
return;

xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
xe_ggtt_dump_node(ggtt, &node->base, "remove-balloon");

mutex_lock(&ggtt->lock);
drm_mm_remove_node(&node->base);
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/xe/xe_ggtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ struct drm_printer;
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);

int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
int xe_ggtt_node_insert_balloon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u64 start, u64 size);
void xe_ggtt_node_remove_balloon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);

int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align);
Expand Down
12 changes: 7 additions & 5 deletions drivers/gpu/drm/xe/xe_gt_sriov_vf.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,23 +528,25 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
start = xe_wopcm_size(xe);
end = config->ggtt_base;
if (end != start) {
err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
err = xe_ggtt_node_insert_balloon(ggtt, &tile->sriov.vf.ggtt_balloon[0],
start, end);
if (err)
goto failed;
}

start = config->ggtt_base + config->ggtt_size;
end = GUC_GGTT_TOP;
if (end != start) {
err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
err = xe_ggtt_node_insert_balloon(ggtt, &tile->sriov.vf.ggtt_balloon[1],
start, end);
if (err)
goto deballoon;
}

return 0;

deballoon:
xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
xe_ggtt_node_remove_balloon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
failed:
return err;
}
Expand All @@ -555,8 +557,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
struct xe_ggtt *ggtt = tile->mem.ggtt;

xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
xe_ggtt_node_remove_balloon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
xe_ggtt_node_remove_balloon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
}

/**
Expand Down

0 comments on commit 15ca094

Please sign in to comment.