linux/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

// SPDX-License-Identifier: GPL-2.0 OR MIT
/**************************************************************************
 *
 * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
 *
 * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
 *
 **************************************************************************/


#include "vmwgfx_drv.h"

#include "vmwgfx_bo.h"
#include "vmwgfx_binding.h"
#include "vmwgfx_devcaps.h"
#include "vmwgfx_mksstat.h"
#include "vmwgfx_vkms.h"
#include "ttm_object.h"

#include <drm/drm_aperture.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_module.h>
#include <drm/drm_sysfs.h>
#include <drm/ttm/ttm_range_manager.h>
#include <drm/ttm/ttm_placement.h>
#include <generated/utsrelease.h>

#ifdef CONFIG_X86
#include <asm/hypervisor.h>
#endif
#include <linux/cc_platform.h>
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/version.h>
#include <linux/vmalloc.h>

#define VMWGFX_DRIVER_DESC

/*
 * Fully encoded drm commands. Might move to vmw_drm.h
 */

#define DRM_IOCTL_VMW_GET_PARAM
#define DRM_IOCTL_VMW_ALLOC_DMABUF
#define DRM_IOCTL_VMW_UNREF_DMABUF
#define DRM_IOCTL_VMW_CURSOR_BYPASS

#define DRM_IOCTL_VMW_CONTROL_STREAM
#define DRM_IOCTL_VMW_CLAIM_STREAM
#define DRM_IOCTL_VMW_UNREF_STREAM

#define DRM_IOCTL_VMW_CREATE_CONTEXT
#define DRM_IOCTL_VMW_UNREF_CONTEXT
#define DRM_IOCTL_VMW_CREATE_SURFACE
#define DRM_IOCTL_VMW_UNREF_SURFACE
#define DRM_IOCTL_VMW_REF_SURFACE
#define DRM_IOCTL_VMW_EXECBUF
#define DRM_IOCTL_VMW_GET_3D_CAP
#define DRM_IOCTL_VMW_FENCE_WAIT
#define DRM_IOCTL_VMW_FENCE_SIGNALED
#define DRM_IOCTL_VMW_FENCE_UNREF
#define DRM_IOCTL_VMW_FENCE_EVENT
#define DRM_IOCTL_VMW_PRESENT
#define DRM_IOCTL_VMW_PRESENT_READBACK
#define DRM_IOCTL_VMW_UPDATE_LAYOUT
#define DRM_IOCTL_VMW_CREATE_SHADER
#define DRM_IOCTL_VMW_UNREF_SHADER
#define DRM_IOCTL_VMW_GB_SURFACE_CREATE
#define DRM_IOCTL_VMW_GB_SURFACE_REF
#define DRM_IOCTL_VMW_SYNCCPU
#define DRM_IOCTL_VMW_CREATE_EXTENDED_CONTEXT
#define DRM_IOCTL_VMW_GB_SURFACE_CREATE_EXT
#define DRM_IOCTL_VMW_GB_SURFACE_REF_EXT
#define DRM_IOCTL_VMW_MSG
#define DRM_IOCTL_VMW_MKSSTAT_RESET
#define DRM_IOCTL_VMW_MKSSTAT_ADD
#define DRM_IOCTL_VMW_MKSSTAT_REMOVE

/*
 * Ioctl definitions.
 */

static const struct drm_ioctl_desc vmw_ioctls[] =;

static const struct pci_device_id vmw_pci_id_list[] =;
MODULE_DEVICE_TABLE(pci, vmw_pci_id_list);

static int vmw_restrict_iommu;
static int vmw_force_coherent;
static int vmw_restrict_dma_mask;
static int vmw_assume_16bpp;

static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
			      void *ptr);

MODULE_PARM_DESC();
module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
MODULE_PARM_DESC();
module_param_named(force_coherent, vmw_force_coherent, int, 0600);
MODULE_PARM_DESC();
module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
MODULE_PARM_DESC();
module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);


struct bitmap_name {};

static const struct bitmap_name cap1_names[] =;


static const struct bitmap_name cap2_names[] =;

static void vmw_print_bitmap(struct drm_device *drm,
			     const char *prefix, uint32_t bitmap,
			     const struct bitmap_name *bnames,
			     uint32_t num_names)
{}


static void vmw_print_sm_type(struct vmw_private *dev_priv)
{}

/**
 * vmw_dummy_query_bo_create - create a bo to hold a dummy query result
 *
 * @dev_priv: A device private structure.
 *
 * This function creates a small buffer object that holds the query
 * result for dummy queries emitted as query barriers.
 * The function will then map the first page and initialize a pending
 * occlusion query result structure, Finally it will unmap the buffer.
 * No interruptible waits are done within this function.
 *
 * Returns an error if bo creation or initialization fails.
 */
static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
{}

static int vmw_device_init(struct vmw_private *dev_priv)
{}

static void vmw_device_fini(struct vmw_private *vmw)
{}

/**
 * vmw_request_device_late - Perform late device setup
 *
 * @dev_priv: Pointer to device private.
 *
 * This function performs setup of otables and enables large command
 * buffer submission. These tasks are split out to a separate function
 * because it reverts vmw_release_device_early and is intended to be used
 * by an error path in the hibernation code.
 */
static int vmw_request_device_late(struct vmw_private *dev_priv)
{}

static int vmw_request_device(struct vmw_private *dev_priv)
{}

/**
 * vmw_release_device_early - Early part of fifo takedown.
 *
 * @dev_priv: Pointer to device private struct.
 *
 * This is the first part of command submission takedown, to be called before
 * buffer management is taken down.
 */
static void vmw_release_device_early(struct vmw_private *dev_priv)
{}

/**
 * vmw_release_device_late - Late part of fifo takedown.
 *
 * @dev_priv: Pointer to device private struct.
 *
 * This is the last part of the command submission takedown, to be called when
 * command submission is no longer needed. It may wait on pending fences.
 */
static void vmw_release_device_late(struct vmw_private *dev_priv)
{}

/*
 * Sets the initial_[width|height] fields on the given vmw_private.
 *
 * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then
 * clamping the value to fb_max_[width|height] fields and the
 * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
 * If the values appear to be invalid, set them to
 * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
 */
static void vmw_get_initial_size(struct vmw_private *dev_priv)
{}

/**
 * vmw_dma_select_mode - Determine how DMA mappings should be set up for this
 * system.
 *
 * @dev_priv: Pointer to a struct vmw_private
 *
 * This functions tries to determine what actions need to be taken by the
 * driver to make system pages visible to the device.
 * If this function decides that DMA is not possible, it returns -EINVAL.
 * The driver may then try to disable features of the device that require
 * DMA.
 */
static int vmw_dma_select_mode(struct vmw_private *dev_priv)
{}

/**
 * vmw_dma_masks - set required page- and dma masks
 *
 * @dev_priv: Pointer to struct drm-device
 *
 * With 32-bit we can only handle 32 bit PFNs. Optionally set that
 * restriction also for 64-bit systems.
 */
static int vmw_dma_masks(struct vmw_private *dev_priv)
{}

static int vmw_vram_manager_init(struct vmw_private *dev_priv)
{}

static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
{}

static int vmw_setup_pci_resources(struct vmw_private *dev,
				   u32 pci_id)
{}

static int vmw_detect_version(struct vmw_private *dev)
{}

static void vmw_write_driver_id(struct vmw_private *dev)
{}

static void vmw_sw_context_init(struct vmw_private *dev_priv)
{}

static void vmw_sw_context_fini(struct vmw_private *dev_priv)
{}

static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
{}

static void vmw_driver_unload(struct drm_device *dev)
{}

static void vmw_postclose(struct drm_device *dev,
			 struct drm_file *file_priv)
{}

static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)
{}

static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,
			      unsigned long arg,
			      long (*ioctl_func)(struct file *, unsigned int,
						 unsigned long))
{}

static long vmw_unlocked_ioctl(struct file *filp, unsigned int cmd,
			       unsigned long arg)
{}

#ifdef CONFIG_COMPAT
static long vmw_compat_ioctl(struct file *filp, unsigned int cmd,
			     unsigned long arg)
{}
#endif

static void vmw_master_set(struct drm_device *dev,
			   struct drm_file *file_priv,
			   bool from_open)
{}

static void vmw_master_drop(struct drm_device *dev,
			    struct drm_file *file_priv)
{}

bool vmwgfx_supported(struct vmw_private *vmw)
{}

/**
 * __vmw_svga_enable - Enable SVGA mode, FIFO and use of VRAM.
 *
 * @dev_priv: Pointer to device private struct.
 * Needs the reservation sem to be held in non-exclusive mode.
 */
static void __vmw_svga_enable(struct vmw_private *dev_priv)
{}

/**
 * vmw_svga_enable - Enable SVGA mode, FIFO and use of VRAM.
 *
 * @dev_priv: Pointer to device private struct.
 */
void vmw_svga_enable(struct vmw_private *dev_priv)
{}

/**
 * __vmw_svga_disable - Disable SVGA mode and use of VRAM.
 *
 * @dev_priv: Pointer to device private struct.
 * Needs the reservation sem to be held in exclusive mode.
 * Will not empty VRAM. VRAM must be emptied by caller.
 */
static void __vmw_svga_disable(struct vmw_private *dev_priv)
{}

/**
 * vmw_svga_disable - Disable SVGA_MODE, and use of VRAM. Keep the fifo
 * running.
 *
 * @dev_priv: Pointer to device private struct.
 * Will empty VRAM.
 */
void vmw_svga_disable(struct vmw_private *dev_priv)
{}

static void vmw_remove(struct pci_dev *pdev)
{}

static void vmw_debugfs_resource_managers_init(struct vmw_private *vmw)
{}

static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
			      void *ptr)
{}

static int vmw_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{}

static int vmw_pci_resume(struct pci_dev *pdev)
{}

static int vmw_pm_suspend(struct device *kdev)
{}

static int vmw_pm_resume(struct device *kdev)
{}

static int vmw_pm_freeze(struct device *kdev)
{}

static int vmw_pm_restore(struct device *kdev)
{}

static const struct dev_pm_ops vmw_pm_ops =;

static const struct file_operations vmwgfx_driver_fops =;

static const struct drm_driver driver =;

static struct pci_driver vmw_pci_driver =;

static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{}

drm_module_pci_driver();

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