panfrost: Remove out-of-band CRC support

Without additional signalling of modifiers, CRCs cannot possibly in a correct
way work across process boundaries. Since we don't do that signalling, we should
not be allocating private CRCs for imported resources, and we should not be
using our own private CRCs for internal resources.

The entire out-of-bands CRC infrastructure is a hack to let us do CRCs even for
imported/exported BOs, but that can't possibly work. Remove it, and remove a
pile of special cases across the driver.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19576>
This commit is contained in:
Alyssa Rosenzweig 2022-11-07 10:00:48 -05:00 committed by Marge Bot
parent cf7a3906b0
commit f8553ef44c
6 changed files with 17 additions and 68 deletions

View file

@ -336,9 +336,6 @@ panfrost_batch_read_rsrc(struct panfrost_batch *batch,
panfrost_batch_add_bo_old(batch, rsrc->image.data.bo, access);
if (rsrc->image.crc.bo)
panfrost_batch_add_bo_old(batch, rsrc->image.crc.bo, access);
if (rsrc->separate_stencil)
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->image.data.bo, access);
@ -355,9 +352,6 @@ panfrost_batch_write_rsrc(struct panfrost_batch *batch,
panfrost_batch_add_bo_old(batch, rsrc->image.data.bo, access);
if (rsrc->image.crc.bo)
panfrost_batch_add_bo_old(batch, rsrc->image.crc.bo, access);
if (rsrc->separate_stencil)
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->image.data.bo, access);

View file

@ -51,9 +51,6 @@
#include "pan_tiling.h"
#include "decode.h"
static bool
panfrost_should_checksum(const struct panfrost_device *dev, const struct panfrost_resource *pres);
static struct pipe_resource *
panfrost_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *templat,
@ -81,9 +78,6 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
DRM_FORMAT_MOD_LINEAR : whandle->modifier;
enum mali_texture_dimension dim =
panfrost_translate_texture_dimension(templat->target);
enum pan_image_crc_mode crc_mode =
panfrost_should_checksum(dev, rsc) ?
PAN_IMAGE_CRC_OOB : PAN_IMAGE_CRC_NONE;
struct pan_image_explicit_layout explicit_layout = {
.offset = whandle->offset,
.row_stride = panfrost_from_legacy_stride(whandle->stride, templat->format, mod)
@ -99,7 +93,6 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
.array_size = prsc->array_size,
.nr_samples = MAX2(prsc->nr_samples, 1),
.nr_slices = 1,
.crc_mode = crc_mode
};
bool valid = pan_image_layout_init(&rsc->image.layout, &explicit_layout);
@ -117,8 +110,6 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
FREE(rsc);
return NULL;
}
if (rsc->image.layout.crc_mode == PAN_IMAGE_CRC_OOB)
rsc->image.crc.bo = panfrost_bo_create(dev, rsc->image.layout.crc_size, 0, "CRC data");
rsc->modifier_constant = true;
@ -445,9 +436,6 @@ panfrost_resource_setup(struct panfrost_device *dev,
{
uint64_t chosen_mod = modifier != DRM_FORMAT_MOD_INVALID ?
modifier : panfrost_best_modifier(dev, pres, fmt);
enum pan_image_crc_mode crc_mode =
panfrost_should_checksum(dev, pres) ?
PAN_IMAGE_CRC_INBAND : PAN_IMAGE_CRC_NONE;
enum mali_texture_dimension dim =
panfrost_translate_texture_dimension(pres->base.target);
@ -473,7 +461,7 @@ panfrost_resource_setup(struct panfrost_device *dev,
.array_size = pres->base.array_size,
.nr_samples = MAX2(pres->base.nr_samples, 1),
.nr_slices = pres->base.last_level + 1,
.crc_mode = crc_mode
.crc = panfrost_should_checksum(dev, pres)
};
ASSERTED bool valid = pan_image_layout_init(&pres->image.layout, NULL);
@ -776,9 +764,6 @@ panfrost_resource_destroy(struct pipe_screen *screen,
if (rsrc->image.data.bo)
panfrost_bo_unreference(rsrc->image.data.bo);
if (rsrc->image.crc.bo)
panfrost_bo_unreference(rsrc->image.crc.bo);
free(rsrc->index_cache);
free(rsrc->damage.tile_map.data);
@ -1204,8 +1189,6 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
}
panfrost_bo_unreference(rsrc->image.data.bo);
if (rsrc->image.crc.bo)
panfrost_bo_unreference(rsrc->image.crc.bo);
rsrc->image.data.bo = tmp_rsrc->image.data.bo;
panfrost_bo_reference(rsrc->image.data.bo);
@ -1299,8 +1282,6 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
if (panfrost_should_linear_convert(dev, prsrc, transfer)) {
panfrost_bo_unreference(prsrc->image.data.bo);
if (prsrc->image.crc.bo)
panfrost_bo_unreference(prsrc->image.crc.bo);
panfrost_resource_setup(dev, prsrc, DRM_FORMAT_MOD_LINEAR,
prsrc->image.layout.format);

View file

@ -107,7 +107,7 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size)
#if PAN_ARCH <= 6
if (fb->rt_count == 1 && fb->rts[0].view && !fb->rts[0].discard &&
fb->rts[0].view->image->layout.crc_mode != PAN_IMAGE_CRC_NONE)
fb->rts[0].view->image->layout.crc)
return 0;
return -1;
@ -117,7 +117,7 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size)
for (unsigned i = 0; i < fb->rt_count; i++) {
if (!fb->rts[i].view || fb->rts[0].discard ||
fb->rts[i].view->image->layout.crc_mode == PAN_IMAGE_CRC_NONE)
!fb->rts[i].view->image->layout.crc)
continue;
bool valid = *(fb->rts[i].crc_valid);
@ -274,10 +274,8 @@ pan_prepare_crc(const struct pan_fb_info *fb, int rt_crc,
const struct pan_image_view *rt = fb->rts[rt_crc].view;
const struct pan_image_slice_layout *slice = &rt->image->layout.slices[rt->first_level];
ext->crc_base = (rt->image->layout.crc_mode == PAN_IMAGE_CRC_INBAND ?
(rt->image->data.bo->ptr.gpu + rt->image->data.offset) :
(rt->image->crc.bo->ptr.gpu + rt->image->crc.offset)) +
slice->crc.offset;
ext->crc_base = rt->image->data.bo->ptr.gpu + rt->image->data.offset
+ slice->crc.offset;
ext->crc_row_stride = slice->crc.stride;
#if PAN_ARCH >= 7
@ -883,20 +881,14 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev,
assert(cfg.color_block_format == MALI_BLOCK_FORMAT_LINEAR ||
cfg.color_block_format == MALI_BLOCK_FORMAT_TILED_U_INTERLEAVED);
if (rt->image->layout.crc_mode != PAN_IMAGE_CRC_NONE) {
if (rt->image->layout.crc) {
const struct pan_image_slice_layout *slice =
&rt->image->layout.slices[level];
cfg.crc_buffer.row_stride = slice->crc.stride;
if (rt->image->layout.crc_mode == PAN_IMAGE_CRC_INBAND) {
cfg.crc_buffer.base = rt->image->data.bo->ptr.gpu +
rt->image->data.offset +
slice->crc.offset;
} else {
cfg.crc_buffer.base = rt->image->crc.bo->ptr.gpu +
rt->image->crc.offset +
slice->crc.offset;
}
cfg.crc_buffer.base = rt->image->data.bo->ptr.gpu +
rt->image->data.offset +
slice->crc.offset;
}
}

View file

@ -279,13 +279,13 @@ bool
pan_image_layout_init(struct pan_image_layout *layout,
const struct pan_image_explicit_layout *explicit_layout)
{
/* Explicit stride only work with non-mipmap, non-array; single-sample
* 2D image, and in-band CRC can't be used.
/* Explicit stride only work with non-mipmap, non-array, single-sample
* 2D image without CRC.
*/
if (explicit_layout &&
(layout->depth > 1 || layout->nr_samples > 1 ||
layout->array_size > 1 || layout->dim != MALI_TEXTURE_DIMENSION_2D ||
layout->nr_slices > 1 || layout->crc_mode == PAN_IMAGE_CRC_INBAND))
layout->nr_slices > 1 || layout->crc))
return false;
/* Mandate 64 byte alignement */
@ -303,7 +303,6 @@ pan_image_layout_init(struct pan_image_layout *layout,
bool linear = layout->modifier == DRM_FORMAT_MOD_LINEAR;
bool is_3d = layout->dim == MALI_TEXTURE_DIMENSION_3D;
unsigned oob_crc_offset = 0;
unsigned offset = explicit_layout ? explicit_layout->offset : 0;
struct pan_block_size block_size =
panfrost_block_size(layout->modifier, layout->format);
@ -392,18 +391,13 @@ pan_image_layout_init(struct pan_image_layout *layout,
slice->size = slice_full_size;
/* Add a checksum region if necessary */
if (layout->crc_mode != PAN_IMAGE_CRC_NONE) {
if (layout->crc) {
slice->crc.size =
panfrost_compute_checksum_size(slice, width, height);
if (layout->crc_mode == PAN_IMAGE_CRC_INBAND) {
slice->crc.offset = offset;
offset += slice->crc.size;
slice->size += slice->crc.size;
} else {
slice->crc.offset = oob_crc_offset;
oob_crc_offset += slice->crc.size;
}
slice->crc.offset = offset;
offset += slice->crc.size;
slice->size += slice->crc.size;
}
width = u_minify(width, 1);
@ -417,7 +411,6 @@ pan_image_layout_init(struct pan_image_layout *layout,
layout->data_size = offset;
else
layout->data_size = ALIGN_POT(layout->array_stride * layout->array_size, 4096);
layout->crc_size = oob_crc_offset;
return true;
}

View file

@ -89,12 +89,6 @@ struct pan_image_slice_layout {
unsigned size;
};
enum pan_image_crc_mode {
PAN_IMAGE_CRC_NONE,
PAN_IMAGE_CRC_INBAND,
PAN_IMAGE_CRC_OOB,
};
struct pan_image_layout {
uint64_t modifier;
enum pipe_format format;
@ -103,7 +97,7 @@ struct pan_image_layout {
enum mali_texture_dimension dim;
unsigned nr_slices;
unsigned array_size;
enum pan_image_crc_mode crc_mode;
bool crc;
/* The remaining fields may be derived from the above by calling
* pan_image_layout_init
@ -111,9 +105,6 @@ struct pan_image_layout {
struct pan_image_slice_layout slices[MAX_MIP_LEVELS];
/* crc_size != 0 only if crc_mode == OOB otherwise CRC words are
* counted in data_size */
unsigned crc_size;
unsigned data_size;
unsigned array_stride;
};
@ -125,7 +116,6 @@ struct pan_image_mem {
struct pan_image {
struct pan_image_mem data;
struct pan_image_mem crc;
struct pan_image_layout layout;
};

View file

@ -85,7 +85,6 @@ panvk_image_create(VkDevice _device,
.array_size = image->vk.array_layers,
.nr_samples = image->vk.samples,
.nr_slices = image->vk.mip_levels,
.crc_mode = PAN_IMAGE_CRC_NONE
};
pan_image_layout_init(&image->pimage.layout, NULL);