/** * xe_guc_id_mgr_init() - Initialize GuC context ID Manager. * @idm: the &xe_guc_id_mgr to initialize * @limit: number of IDs to manage * * The bare-metal or PF driver can pass ~0 as &limit to indicate that all * context IDs supported by the GuC firmware are available for use. * * Only VF drivers will have to provide explicit number of context IDs * that they can use. * * Return: 0 on success or a negative error code on failure.
*/ int xe_guc_id_mgr_init(struct xe_guc_id_mgr *idm, unsignedint limit)
{ int ret;
if (retain) { /* * For IDs reservations (used on PF for VFs) we want to make * sure there will be at least 'retain' available for the PF
*/ if (idm->used + count + retain > idm->total) return -EDQUOT; /* * ... and we want to reserve highest IDs close to the end.
*/
id = find_last_zero_area(idm->bitmap, idm->total, count);
} else { /* * For regular IDs reservations (used by submission code) * we start searching from the lower range of IDs.
*/
id = bitmap_find_next_zero_area(idm->bitmap, idm->total, 0, count, 0);
} if (id >= idm->total) return -ENOSPC;
if (IS_ENABLED(CONFIG_DRM_XE_DEBUG)) { unsignedint n;
for (n = 0; n < count; n++)
idm_assert(idm, test_bit(start + n, idm->bitmap));
}
bitmap_clear(idm->bitmap, start, count);
idm->used -= count;
}
/** * xe_guc_id_mgr_reserve_locked() - Reserve one or more GuC context IDs. * @idm: the &xe_guc_id_mgr * @count: number of IDs to allocate (can't be 0) * * This function is dedicated for the use by the GuC submission code, * where submission lock is already taken. * * Return: ID of allocated GuC context or a negative error code on failure.
*/ int xe_guc_id_mgr_reserve_locked(struct xe_guc_id_mgr *idm, unsignedint count)
{ return idm_reserve_chunk_locked(idm, count, 0);
}
/** * xe_guc_id_mgr_release_locked() - Release one or more GuC context IDs. * @idm: the &xe_guc_id_mgr * @id: the GuC context ID to release * @count: number of IDs to release (can't be 0) * * This function is dedicated for the use by the GuC submission code, * where submission lock is already taken.
*/ void xe_guc_id_mgr_release_locked(struct xe_guc_id_mgr *idm, unsignedint id, unsignedint count)
{ return idm_release_chunk_locked(idm, id, count);
}
/** * xe_guc_id_mgr_reserve() - Reserve a range of GuC context IDs. * @idm: the &xe_guc_id_mgr * @count: number of GuC context IDs to reserve (can't be 0) * @retain: number of GuC context IDs to keep available (can't be 0) * * This function is dedicated for the use by the PF driver which expects that * reserved range of IDs will be contiguous and that there will be at least * &retain IDs still available for the PF after this reservation. * * Return: starting ID of the allocated GuC context ID range or * a negative error code on failure.
*/ int xe_guc_id_mgr_reserve(struct xe_guc_id_mgr *idm, unsignedint count, unsignedint retain)
{ int ret;
idm_assert(idm, count);
idm_assert(idm, retain);
mutex_lock(idm_mutex(idm));
ret = idm_reserve_chunk_locked(idm, count, retain);
mutex_unlock(idm_mutex(idm));
return ret;
}
/** * xe_guc_id_mgr_release() - Release a range of GuC context IDs. * @idm: the &xe_guc_id_mgr * @start: the starting ID of GuC context range to release * @count: number of GuC context IDs to release
*/ void xe_guc_id_mgr_release(struct xe_guc_id_mgr *idm, unsignedint start, unsignedint count)
{
mutex_lock(idm_mutex(idm));
idm_release_chunk_locked(idm, start, count);
mutex_unlock(idm_mutex(idm));
}
drm_printf_indent(p, indent, "total %u\n", idm->total); if (!idm->bitmap) return;
drm_printf_indent(p, indent, "used %u\n", idm->used);
for_each_set_bitrange(rs, re, idm->bitmap, idm->total)
drm_printf_indent(p, indent, "range %u..%u (%u)\n", rs, re - 1, re - rs);
}
/** * xe_guc_id_mgr_print() - Print status of GuC ID Manager. * @idm: the &xe_guc_id_mgr to print * @p: the &drm_printer to print to * @indent: tab indentation level
*/ void xe_guc_id_mgr_print(struct xe_guc_id_mgr *idm, struct drm_printer *p, int indent)
{
mutex_lock(idm_mutex(idm));
idm_print_locked(idm, p, indent);
mutex_unlock(idm_mutex(idm));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.