linux/drivers/gpu/drm/msm/msm_drv.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2016-2018, 2020-2021 The Linux Foundation. All rights reserved.
 * Copyright (C) 2013 Red Hat
 * Author: Rob Clark <[email protected]>
 */

#include <linux/dma-mapping.h>
#include <linux/fault-inject.h>
#include <linux/of_address.h>
#include <linux/uaccess.h>

#include <drm/drm_drv.h>
#include <drm/drm_file.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_of.h>

#include "msm_drv.h"
#include "msm_debugfs.h"
#include "msm_gem.h"
#include "msm_gpu.h"
#include "msm_kms.h"

/*
 * MSM driver version:
 * - 1.0.0 - initial interface
 * - 1.1.0 - adds madvise, and support for submits with > 4 cmd buffers
 * - 1.2.0 - adds explicit fence support for submit ioctl
 * - 1.3.0 - adds GMEM_BASE + NR_RINGS params, SUBMITQUEUE_NEW +
 *           SUBMITQUEUE_CLOSE ioctls, and MSM_INFO_IOVA flag for
 *           MSM_GEM_INFO ioctl.
 * - 1.4.0 - softpin, MSM_RELOC_BO_DUMP, and GEM_INFO support to set/get
 *           GEM object's debug name
 * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
 * - 1.6.0 - Syncobj support
 * - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count
 * - 1.8.0 - Add MSM_BO_CACHED_COHERENT for supported GPUs (a6xx)
 * - 1.9.0 - Add MSM_SUBMIT_FENCE_SN_IN
 * - 1.10.0 - Add MSM_SUBMIT_BO_NO_IMPLICIT
 * - 1.11.0 - Add wait boost (MSM_WAIT_FENCE_BOOST, MSM_PREP_BOOST)
 * - 1.12.0 - Add MSM_INFO_SET_METADATA and MSM_INFO_GET_METADATA
 */
#define MSM_VERSION_MAJOR
#define MSM_VERSION_MINOR
#define MSM_VERSION_PATCHLEVEL

static void msm_deinit_vram(struct drm_device *ddev);

static char *vram =;
MODULE_PARM_DESC();
module_param(vram, charp, 0);

bool dumpstate;
MODULE_PARM_DESC();
module_param(dumpstate, bool, 0600);

static bool modeset =;
MODULE_PARM_DESC();
module_param(modeset, bool, 0600);

#ifdef CONFIG_FAULT_INJECTION
DECLARE_FAULT_ATTR(fail_gem_alloc);
DECLARE_FAULT_ATTR(fail_gem_iova);
#endif

static int msm_drm_uninit(struct device *dev)
{}

bool msm_use_mmu(struct drm_device *dev)
{}

static int msm_init_vram(struct drm_device *dev)
{}

static void msm_deinit_vram(struct drm_device *ddev)
{}

static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
{}

/*
 * DRM operations:
 */

static void load_gpu(struct drm_device *dev)
{}

static int context_init(struct drm_device *dev, struct drm_file *file)
{}

static int msm_open(struct drm_device *dev, struct drm_file *file)
{}

static void context_close(struct msm_file_private *ctx)
{}

static void msm_postclose(struct drm_device *dev, struct drm_file *file)
{}

/*
 * DRM ioctls:
 */

static int msm_ioctl_get_param(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_set_param(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static inline ktime_t to_ktime(struct drm_msm_timespec timeout)
{}

static int msm_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_gem_info_iova(struct drm_device *dev,
		struct drm_file *file, struct drm_gem_object *obj,
		uint64_t *iova)
{}

static int msm_ioctl_gem_info_set_iova(struct drm_device *dev,
		struct drm_file *file, struct drm_gem_object *obj,
		uint64_t iova)
{}

static int msm_ioctl_gem_info_set_metadata(struct drm_gem_object *obj,
					   __user void *metadata,
					   u32 metadata_size)
{}

static int msm_ioctl_gem_info_get_metadata(struct drm_gem_object *obj,
					   __user void *metadata,
					   u32 *metadata_size)
{}

static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
		      ktime_t timeout, uint32_t flags)
{}

static int msm_ioctl_wait_fence(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_gem_madvise(struct drm_device *dev, void *data,
		struct drm_file *file)
{}


static int msm_ioctl_submitqueue_new(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_submitqueue_query(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
		struct drm_file *file)
{}

static const struct drm_ioctl_desc msm_ioctls[] =;

static void msm_show_fdinfo(struct drm_printer *p, struct drm_file *file)
{}

static const struct file_operations fops =;

static const struct drm_driver msm_driver =;

/*
 * Componentized driver support:
 */

/*
 * Identify what components need to be added by parsing what remote-endpoints
 * our MDP output ports are connected to. In the case of LVDS on MDP4, there
 * is no external component that we need to add since LVDS is within MDP4
 * itself.
 */
static int add_components_mdp(struct device *master_dev,
			      struct component_match **matchptr)
{}

#if !IS_REACHABLE(CONFIG_DRM_MSM_MDP5) || !IS_REACHABLE(CONFIG_DRM_MSM_DPU)
bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver)
{
	/* If just a single driver is enabled, use it no matter what */
	return true;
}
#else

static bool prefer_mdp5 =;
MODULE_PARM_DESC();
module_param(prefer_mdp5, bool, 0444);

/* list all platforms supported by both mdp5 and dpu drivers */
static const char *const msm_mdp5_dpu_migration[] =;

bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver)
{}
#endif

/*
 * We don't know what's the best binding to link the gpu with the drm device.
 * Fow now, we just hunt for all the possible gpus that we support, and add them
 * as components.
 */
static const struct of_device_id msm_gpu_match[] =;

static int add_gpu_components(struct device *dev,
			      struct component_match **matchptr)
{}

static int msm_drm_bind(struct device *dev)
{}

static void msm_drm_unbind(struct device *dev)
{}

const struct component_master_ops msm_drm_ops =;

int msm_drv_probe(struct device *master_dev,
	int (*kms_init)(struct drm_device *dev),
	struct msm_kms *kms)
{}

/*
 * Platform driver:
 * Used only for headlesss GPU instances
 */

static int msm_pdev_probe(struct platform_device *pdev)
{}

static void msm_pdev_remove(struct platform_device *pdev)
{}

static struct platform_driver msm_platform_driver =;

static int __init msm_drm_register(void)
{}

static void __exit msm_drm_unregister(void)
{}

module_init();
module_exit(msm_drm_unregister);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();