panfrost: Stub out panfrost_bo_cache_get

We will use this function to fetch cached BOs instead of freshly
allocating them.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig
2019-07-15 08:13:10 -07:00
parent fea953e6c2
commit b5a28f61ae
4 changed files with 66 additions and 10 deletions

View File

@@ -33,6 +33,7 @@ files_panfrost = files(
'pan_context.c',
'pan_afbc.c',
'pan_bo_cache.c',
'pan_blit.c',
'pan_job.c',
'pan_drm.c',

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors (Collabora):
* Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
*/
#include "pan_screen.h"
struct panfrost_bo *
panfrost_bo_cache_fetch(
struct panfrost_screen *screen,
size_t size, uint32_t flags)
{
/* Stub */
return NULL;
}

View File

@@ -83,7 +83,7 @@ struct panfrost_bo *
panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
uint32_t flags)
{
struct panfrost_bo *bo = rzalloc(screen, struct panfrost_bo);
struct panfrost_bo *bo;
/* Kernel will fail (confusingly) with EPERM otherwise */
assert(size > 0);
@@ -96,18 +96,32 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
.size = size,
.flags = translated_flags,
};
int ret;
ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo);
if (ret) {
fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %d\n", ret);
assert(0);
/* Before creating a BO, we first want to check the cache */
bo = panfrost_bo_cache_fetch(screen, size, flags);
if (bo == NULL) {
/* Otherwise, the cache misses and we need to allocate a BO fresh from
* the kernel */
int ret;
ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo);
if (ret) {
fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %d\n", ret);
assert(0);
}
/* We have a BO allocated from the kernel; fill in the userspace
* version */
bo = rzalloc(screen, struct panfrost_bo);
bo->size = create_bo.size;
bo->gpu = create_bo.offset;
bo->gem_handle = create_bo.handle;
}
bo->size = create_bo.size;
bo->gpu = create_bo.offset;
bo->gem_handle = create_bo.handle;
/* Only mmap now if we know we need to. For CPU-invisible buffers, we
* never map since we don't care about their contents; they're purely
* for GPU-internal use. */

View File

@@ -161,5 +161,10 @@ panfrost_drm_fence_finish(struct pipe_screen *pscreen,
struct pipe_context *ctx,
struct pipe_fence_handle *fence,
uint64_t timeout);
struct panfrost_bo *
panfrost_bo_cache_fetch(
struct panfrost_screen *screen,
size_t size, uint32_t flags);
#endif /* PAN_SCREEN_H */