freedreno/drm/virtio: Fix issues with 16k (or larger) page sizes

Signed-off-by: Rob Clark <robdclark@chromium.org>
Fixes: e6b2785811 ("freedreno/drm/virtio: Use userspace IOVA allocation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30431>
(cherry picked from commit 87c889cd8a)
This commit is contained in:
Rob Clark 2024-07-30 13:18:43 -07:00 committed by Eric Engestrom
parent 9e11264df4
commit c8c0d44252
7 changed files with 14 additions and 9 deletions

View file

@ -2254,7 +2254,7 @@
"description": "freedreno/drm/virtio: Fix issues with 16k (or larger) page sizes",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "e6b2785811c23e44d3acfeef71ef240d95fc1663",
"notes": null

View file

@ -123,13 +123,13 @@ fd_bo_cache_init(struct fd_bo_cache *cache, int coarse, const char *name)
* width/height alignment and rounding of sizes to pages will
* get us useful cache hit rates anyway)
*/
add_bucket(cache, 4096);
add_bucket(cache, 4096 * 2);
add_bucket(cache, os_page_size);
add_bucket(cache, os_page_size * 2);
if (!coarse)
add_bucket(cache, 4096 * 3);
add_bucket(cache, os_page_size * 3);
/* Initialize the linked lists for BO reuse cache. */
for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
for (size = 4 * os_page_size; size <= cache_max_size; size *= 2) {
add_bucket(cache, size);
if (!coarse) {
add_bucket(cache, size + size * 1 / 4);
@ -241,7 +241,7 @@ fd_bo_cache_alloc(struct fd_bo_cache *cache, uint32_t *size, uint32_t flags)
struct fd_bo *bo = NULL;
struct fd_bo_bucket *bucket;
*size = align(*size, 4096);
*size = align(*size, os_page_size);
bucket = get_bucket(cache, *size);
struct list_head freelist;

View file

@ -42,6 +42,8 @@ struct fd_device *msm_device_new(int fd, drmVersionPtr version);
struct fd_device *virtio_device_new(int fd, drmVersionPtr version);
#endif
uint64_t os_page_size = 4096;
struct fd_device *
fd_device_new(int fd)
{
@ -49,6 +51,8 @@ fd_device_new(int fd)
drmVersionPtr version;
bool use_heap = false;
os_get_page_size(&os_page_size);
/* figure out if we are kgsl or msm drm driver: */
version = drmGetVersion(fd);
if (!version) {

View file

@ -57,6 +57,7 @@
extern simple_mtx_t table_lock;
extern simple_mtx_t fence_lock;
extern uint64_t os_page_size;
#define SUBALLOC_SIZE (32 * 1024)
/* Maximum known alignment requirement is a6xx's TEX_CONST at 16 dwords */

View file

@ -782,7 +782,7 @@ fd_ringbuffer_sp_new_object(struct fd_pipe *pipe, uint32_t size)
if (dev->suballoc_bo)
fd_bo_del(dev->suballoc_bo);
dev->suballoc_bo =
fd_bo_new_ring(dev, MAX2(SUBALLOC_SIZE, align(size, 4096)));
fd_bo_new_ring(dev, MAX2(SUBALLOC_SIZE, align(size, os_page_size)));
fd_ring->offset = 0;
}

View file

@ -65,7 +65,7 @@ msm_device_new(int fd, drmVersionPtr version)
if (version->version_minor >= FD_VERSION_CACHED_COHERENT) {
struct drm_msm_gem_new new_req = {
.size = 0x1000,
.size = os_page_size,
.flags = MSM_BO_CACHED_COHERENT,
};

View file

@ -93,7 +93,7 @@ virtio_dev_alloc_iova(struct fd_device *dev, uint32_t size)
uint64_t iova;
simple_mtx_lock(&virtio_dev->address_space_lock);
iova = util_vma_heap_alloc(&virtio_dev->address_space, size, 0x1000);
iova = util_vma_heap_alloc(&virtio_dev->address_space, size, os_page_size);
simple_mtx_unlock(&virtio_dev->address_space_lock);
return iova;