linux/drivers/gpu/drm/vc4/vc4_bo.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Copyright © 2015 Broadcom
 */

/**
 * DOC: VC4 GEM BO management support
 *
 * The VC4 GPU architecture (both scanout and rendering) has direct
 * access to system memory with no MMU in between.  To support it, we
 * use the GEM DMA helper functions to allocate contiguous ranges of
 * physical memory for our BOs.
 *
 * Since the DMA allocator is very slow, we keep a cache of recently
 * freed BOs around so that the kernel's allocation of objects for 3D
 * rendering can return quickly.
 */

#include <linux/dma-buf.h>

#include <drm/drm_fourcc.h>

#include "vc4_drv.h"
#include "uapi/drm/vc4_drm.h"

static const struct drm_gem_object_funcs vc4_gem_object_funcs;

static const char * const bo_type_names[] =;

static bool is_user_label(int label)
{}

static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4)
{}

static int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
{}

/* Takes ownership of *name and returns the appropriate slot for it in
 * the bo_labels[] array, extending it as necessary.
 *
 * This is inefficient and could use a hash table instead of walking
 * an array and strcmp()ing.  However, the assumption is that user
 * labeling will be infrequent (scanout buffers and other long-lived
 * objects, or debug driver builds), so we can live with it for now.
 */
static int vc4_get_user_label(struct vc4_dev *vc4, const char *name)
{}

static void vc4_bo_set_label(struct drm_gem_object *gem_obj, int label)
{}

static uint32_t bo_page_index(size_t size)
{}

static void vc4_bo_destroy(struct vc4_bo *bo)
{}

static void vc4_bo_remove_from_cache(struct vc4_bo *bo)
{}

static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
						     size_t size)
{}

static void vc4_bo_cache_purge(struct drm_device *dev)
{}

void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo)
{}

static void vc4_bo_remove_from_purgeable_pool_locked(struct vc4_bo *bo)
{}

void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo)
{}

static void vc4_bo_purge(struct drm_gem_object *obj)
{}

static void vc4_bo_userspace_cache_purge(struct drm_device *dev)
{}

static struct vc4_bo *vc4_bo_get_from_cache(struct drm_device *dev,
					    uint32_t size,
					    enum vc4_kernel_bo_type type)
{}

/**
 * vc4_create_object - Implementation of driver->gem_create_object.
 * @dev: DRM device
 * @size: Size in bytes of the memory the object will reference
 *
 * This lets the DMA helpers allocate object structs for us, and keep
 * our BO stats correct.
 */
struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
{}

struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
			     bool allow_unzeroed, enum vc4_kernel_bo_type type)
{}

int vc4_bo_dumb_create(struct drm_file *file_priv,
		       struct drm_device *dev,
		       struct drm_mode_create_dumb *args)
{}

static void vc4_bo_cache_free_old(struct drm_device *dev)
{}

/* Called on the last userspace/kernel unreference of the BO.  Returns
 * it to the BO cache if possible, otherwise frees it.
 */
static void vc4_free_object(struct drm_gem_object *gem_bo)
{}

static void vc4_bo_cache_time_work(struct work_struct *work)
{}

int vc4_bo_inc_usecnt(struct vc4_bo *bo)
{}

void vc4_bo_dec_usecnt(struct vc4_bo *bo)
{}

static void vc4_bo_cache_time_timer(struct timer_list *t)
{}

static struct dma_buf *vc4_prime_export(struct drm_gem_object *obj, int flags)
{}

static vm_fault_t vc4_fault(struct vm_fault *vmf)
{}

static int vc4_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
{}

static const struct vm_operations_struct vc4_vm_ops =;

static const struct drm_gem_object_funcs vc4_gem_object_funcs =;

static int vc4_grab_bin_bo(struct vc4_dev *vc4, struct vc4_file *vc4file)
{}

int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
			struct drm_file *file_priv)
{}

int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
		      struct drm_file *file_priv)
{}

int
vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
			   struct drm_file *file_priv)
{}

/**
 * vc4_set_tiling_ioctl() - Sets the tiling modifier for a BO.
 * @dev: DRM device
 * @data: ioctl argument
 * @file_priv: DRM file for this fd
 *
 * The tiling state of the BO decides the default modifier of an fb if
 * no specific modifier was set by userspace, and the return value of
 * vc4_get_tiling_ioctl() (so that userspace can treat a BO it
 * received from dmabuf as the same tiling format as the producer
 * used).
 */
int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
			 struct drm_file *file_priv)
{}

/**
 * vc4_get_tiling_ioctl() - Gets the tiling modifier for a BO.
 * @dev: DRM device
 * @data: ioctl argument
 * @file_priv: DRM file for this fd
 *
 * Returns the tiling modifier for a BO as set by vc4_set_tiling_ioctl().
 */
int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
			 struct drm_file *file_priv)
{}

int vc4_bo_debugfs_init(struct drm_minor *minor)
{}

static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused);
int vc4_bo_cache_init(struct drm_device *dev)
{}

static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)
{}

int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
		       struct drm_file *file_priv)
{}