mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-15 22:41:38 +00:00
The flags stored in the BO grew over time without following much a naming pattern. First of all, get rid of the _BIT suffix that was banned from everywhere else due to the guideline in drivers/gpu/drm/i915/i915_reg.h that xe kind of follows: Define bits using ``REG_BIT(N)``. Do **not** add ``_BIT`` suffix to the name. Here the flags aren't for a register, but it's good practice to keep it consistent. Second divergence on names is the use or not of "CREATE". This is because most of the flags are passed to xe_bo_create*() family of functions, changing its behavior. However, since the flags are also stored in the bo itself and checked elsewhere in the code, it seems better to just omit the CREATE part. With those 2 guidelines, all the flags are given the form XE_BO_FLAG_<FLAG_NAME> with the following commands: git grep -le "XE_BO_" -- drivers/gpu/drm/xe | xargs sed -i \ -e "s/XE_BO_\([_A-Z0-9]*\)_BIT/XE_BO_\1/g" \ -e 's/XE_BO_CREATE_/XE_BO_FLAG_/g' git grep -le "XE_BO_" -- drivers/gpu/drm/xe | xargs sed -i -r \ -e 's/XE_BO_(DEFER_BACKING|SCANOUT|FIXED_PLACEMENT|PAGETABLE|NEEDS_CPU_ACCESS|NEEDS_UC|INTERNAL_TEST|INTERNAL_64K|GGTT_INVALIDATE)/XE_BO_FLAG_\1/g' And then the defines in drivers/gpu/drm/xe/xe_bo.h are adjusted to follow the coding style. Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240322142702.186529-3-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
106 lines
2.1 KiB
C
106 lines
2.1 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2022 Intel Corporation
|
|
*/
|
|
|
|
#include "xe_guc_hwconfig.h"
|
|
|
|
#include <drm/drm_managed.h>
|
|
|
|
#include "abi/guc_actions_abi.h"
|
|
#include "xe_bo.h"
|
|
#include "xe_device.h"
|
|
#include "xe_gt.h"
|
|
#include "xe_guc.h"
|
|
#include "xe_map.h"
|
|
|
|
static int send_get_hwconfig(struct xe_guc *guc, u64 ggtt_addr, u32 size)
|
|
{
|
|
u32 action[] = {
|
|
XE_GUC_ACTION_GET_HWCONFIG,
|
|
lower_32_bits(ggtt_addr),
|
|
upper_32_bits(ggtt_addr),
|
|
size,
|
|
};
|
|
|
|
return xe_guc_mmio_send(guc, action, ARRAY_SIZE(action));
|
|
}
|
|
|
|
static int guc_hwconfig_size(struct xe_guc *guc, u32 *size)
|
|
{
|
|
int ret = send_get_hwconfig(guc, 0, 0);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*size = ret;
|
|
return 0;
|
|
}
|
|
|
|
static int guc_hwconfig_copy(struct xe_guc *guc)
|
|
{
|
|
int ret = send_get_hwconfig(guc, xe_bo_ggtt_addr(guc->hwconfig.bo),
|
|
guc->hwconfig.size);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int xe_guc_hwconfig_init(struct xe_guc *guc)
|
|
{
|
|
struct xe_device *xe = guc_to_xe(guc);
|
|
struct xe_gt *gt = guc_to_gt(guc);
|
|
struct xe_tile *tile = gt_to_tile(gt);
|
|
struct xe_bo *bo;
|
|
u32 size;
|
|
int err;
|
|
|
|
/* Initialization already done */
|
|
if (guc->hwconfig.bo)
|
|
return 0;
|
|
|
|
/*
|
|
* All hwconfig the same across GTs so only GT0 needs to be configured
|
|
*/
|
|
if (gt->info.id != XE_GT0)
|
|
return 0;
|
|
|
|
/* ADL_P, DG2+ supports hwconfig table */
|
|
if (GRAPHICS_VERx100(xe) < 1255 && xe->info.platform != XE_ALDERLAKE_P)
|
|
return 0;
|
|
|
|
err = guc_hwconfig_size(guc, &size);
|
|
if (err)
|
|
return err;
|
|
if (!size)
|
|
return -EINVAL;
|
|
|
|
bo = xe_managed_bo_create_pin_map(xe, tile, PAGE_ALIGN(size),
|
|
XE_BO_FLAG_SYSTEM |
|
|
XE_BO_FLAG_GGTT |
|
|
XE_BO_FLAG_GGTT_INVALIDATE);
|
|
if (IS_ERR(bo))
|
|
return PTR_ERR(bo);
|
|
guc->hwconfig.bo = bo;
|
|
guc->hwconfig.size = size;
|
|
|
|
return guc_hwconfig_copy(guc);
|
|
}
|
|
|
|
u32 xe_guc_hwconfig_size(struct xe_guc *guc)
|
|
{
|
|
return !guc->hwconfig.bo ? 0 : guc->hwconfig.size;
|
|
}
|
|
|
|
void xe_guc_hwconfig_copy(struct xe_guc *guc, void *dst)
|
|
{
|
|
struct xe_device *xe = guc_to_xe(guc);
|
|
|
|
XE_WARN_ON(!guc->hwconfig.bo);
|
|
|
|
xe_map_memcpy_from(xe, dst, &guc->hwconfig.bo->vmap, 0,
|
|
guc->hwconfig.size);
|
|
}
|