2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2014-08-29 10:12:40 +00:00
|
|
|
* Internal Header for the Direct Rendering Manager
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
2010-05-27 19:40:25 +00:00
|
|
|
* Copyright (c) 2009-2010, Code Aurora Forum.
|
2005-04-16 22:20:36 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-08-29 10:12:40 +00:00
|
|
|
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
* Author: Gareth Hughes <gareth@valinux.com>
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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
|
|
|
|
* VA LINUX SYSTEMS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DRM_P_H_
|
|
|
|
#define _DRM_P_H_
|
|
|
|
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/agp_backend.h>
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/file.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/fs.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/idr.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/init.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/jiffies.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/miscdevice.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/mm.h>
|
2006-02-02 08:37:46 +00:00
|
|
|
#include <linux/mutex.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/poll.h>
|
2013-11-21 19:29:51 +00:00
|
|
|
#include <linux/ratelimit.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/types.h>
|
2014-08-29 10:12:35 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/workqueue.h>
|
2016-10-25 12:00:45 +00:00
|
|
|
#include <linux/dma-fence.h>
|
2017-03-08 14:12:35 +00:00
|
|
|
#include <linux/module.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
|
|
|
|
#include <asm/mman.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/pgalloc.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
|
2014-08-29 10:12:40 +00:00
|
|
|
#include <uapi/drm/drm.h>
|
|
|
|
#include <uapi/drm/drm_mode.h>
|
|
|
|
|
|
|
|
#include <drm/drm_agpsupport.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
2016-06-09 09:54:08 +00:00
|
|
|
#include <drm/drm_fourcc.h>
|
2014-08-29 10:12:40 +00:00
|
|
|
#include <drm/drm_global.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <drm/drm_hashtab.h>
|
|
|
|
#include <drm/drm_mm.h>
|
|
|
|
#include <drm/drm_os_linux.h>
|
2012-10-02 17:01:03 +00:00
|
|
|
#include <drm/drm_sarea.h>
|
2016-11-14 11:58:19 +00:00
|
|
|
#include <drm/drm_drv.h>
|
2017-03-08 14:12:35 +00:00
|
|
|
#include <drm/drm_prime.h>
|
2017-03-08 14:12:37 +00:00
|
|
|
#include <drm/drm_pci.h>
|
2017-03-08 14:12:42 +00:00
|
|
|
#include <drm/drm_file.h>
|
2017-03-22 20:53:36 +00:00
|
|
|
#include <drm/drm_debugfs.h>
|
2017-03-22 20:54:47 +00:00
|
|
|
#include <drm/drm_ioctl.h>
|
2017-04-04 09:52:55 +00:00
|
|
|
#include <drm/drm_sysfs.h>
|
2017-05-31 09:21:46 +00:00
|
|
|
#include <drm/drm_vblank.h>
|
|
|
|
#include <drm/drm_irq.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-05-26 17:46:22 +00:00
|
|
|
struct module;
|
|
|
|
|
2007-09-03 02:06:45 +00:00
|
|
|
struct drm_device;
|
2014-08-29 10:12:32 +00:00
|
|
|
struct drm_agp_head;
|
2014-09-11 05:43:25 +00:00
|
|
|
struct drm_local_map;
|
|
|
|
struct drm_device_dma;
|
2014-09-23 13:46:53 +00:00
|
|
|
struct drm_gem_object;
|
2016-06-21 08:54:22 +00:00
|
|
|
struct drm_master;
|
2016-07-15 19:48:01 +00:00
|
|
|
struct drm_vblank_crtc;
|
2017-03-08 14:12:35 +00:00
|
|
|
struct drm_vma_offset_manager;
|
2007-09-03 02:06:45 +00:00
|
|
|
|
2012-10-28 17:28:06 +00:00
|
|
|
struct device_node;
|
2012-11-14 10:22:52 +00:00
|
|
|
struct videomode;
|
2014-07-01 10:57:26 +00:00
|
|
|
struct reservation_object;
|
2014-01-09 10:03:14 +00:00
|
|
|
struct dma_buf_attachment;
|
2012-11-14 10:22:52 +00:00
|
|
|
|
2017-03-08 14:12:37 +00:00
|
|
|
struct pci_dev;
|
|
|
|
struct pci_controller;
|
|
|
|
|
2009-07-20 05:48:06 +00:00
|
|
|
/*
|
2016-04-14 14:34:16 +00:00
|
|
|
* The following categories are defined:
|
2014-03-24 15:53:08 +00:00
|
|
|
*
|
|
|
|
* CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
|
|
|
|
* This is the category used by the DRM_DEBUG() macro.
|
|
|
|
*
|
|
|
|
* DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
|
|
|
|
* This is the category used by the DRM_DEBUG_DRIVER() macro.
|
2009-07-20 05:48:06 +00:00
|
|
|
*
|
2014-03-24 15:53:08 +00:00
|
|
|
* KMS: used in the modesetting code.
|
|
|
|
* This is the category used by the DRM_DEBUG_KMS() macro.
|
2009-07-20 05:48:06 +00:00
|
|
|
*
|
2014-03-24 15:53:08 +00:00
|
|
|
* PRIME: used in the prime code.
|
|
|
|
* This is the category used by the DRM_DEBUG_PRIME() macro.
|
2009-07-20 05:48:06 +00:00
|
|
|
*
|
2015-02-22 11:24:16 +00:00
|
|
|
* ATOMIC: used in the atomic code.
|
|
|
|
* This is the category used by the DRM_DEBUG_ATOMIC() macro.
|
|
|
|
*
|
2015-10-09 19:57:37 +00:00
|
|
|
* VBL: used for verbose debug message in the vblank code
|
|
|
|
* This is the category used by the DRM_DEBUG_VBL() macro.
|
|
|
|
*
|
2014-03-24 15:53:08 +00:00
|
|
|
* Enabling verbose debug messages is done through the drm.debug parameter,
|
|
|
|
* each category being enabled by a bit.
|
|
|
|
*
|
|
|
|
* drm.debug=0x1 will enable CORE messages
|
|
|
|
* drm.debug=0x2 will enable DRIVER messages
|
|
|
|
* drm.debug=0x3 will enable CORE and DRIVER messages
|
|
|
|
* ...
|
2015-10-09 19:57:37 +00:00
|
|
|
* drm.debug=0x3f will enable all messages
|
2014-03-24 15:53:08 +00:00
|
|
|
*
|
|
|
|
* An interesting feature is that it's possible to enable verbose logging at
|
|
|
|
* run-time by echoing the debug value in its sysfs node:
|
|
|
|
* # echo 0xf > /sys/module/drm/parameters/debug
|
2009-07-20 05:48:06 +00:00
|
|
|
*/
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_UT_NONE 0x00
|
2014-03-24 15:53:08 +00:00
|
|
|
#define DRM_UT_CORE 0x01
|
|
|
|
#define DRM_UT_DRIVER 0x02
|
|
|
|
#define DRM_UT_KMS 0x04
|
|
|
|
#define DRM_UT_PRIME 0x08
|
2015-02-22 11:24:16 +00:00
|
|
|
#define DRM_UT_ATOMIC 0x10
|
2015-10-09 19:57:37 +00:00
|
|
|
#define DRM_UT_VBL 0x20
|
2016-11-05 15:08:09 +00:00
|
|
|
#define DRM_UT_STATE 0x40
|
drm: add separate drm debugging levels
Now all the DRM debug info will be reported if the boot option of
"drm.debug=1" is added. Sometimes it is inconvenient to get the debug
info in KMS mode. We will get too much unrelated info.
This will separate several DRM debug levels and the debug level can be used
to print the different debug info. And the debug level is controlled by the
module parameter of drm.debug
In this patch it is divided into four debug levels;
drm_core, drm_driver, drm_kms, drm_mode.
At the same time we can get the different debug info by changing the debug
level. This can be done by adding the module parameter. Of course it can
be changed through the /sys/module/drm/parameters/debug after the system is
booted.
Four debug macro definitions are provided.
DRM_DEBUG(fmt, args...)
DRM_DEBUG_DRIVER(prefix, fmt, args...)
DRM_DEBUG_KMS(prefix, fmt, args...)
DRM_DEBUG_MODE(prefix, fmt, args...)
When the boot option of "drm.debug=4" is added, it will print the debug info
using DRM_DEBUG_KMS macro definition.
When the boot option of "drm.debug=6" is added, it will print the debug info
using DRM_DEBUG_KMS/DRM_DEBUG_DRIVER.
Sometimes we expect to print the value of an array.
For example: SDVO command,
In such case the following four DRM debug macro definitions are added:
DRM_LOG(fmt, args...)
DRM_LOG_DRIVER(fmt, args...)
DRM_LOG_KMS(fmt, args...)
DRM_LOG_MODE(fmt, args...)
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2009-06-02 06:09:47 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
/** \name DRM template customization defaults */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Macros to make printk easier */
|
|
|
|
/*@{*/
|
|
|
|
|
2016-08-18 17:17:22 +00:00
|
|
|
#define _DRM_PRINTK(once, level, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
|
|
|
|
##__VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define DRM_INFO(fmt, ...) \
|
|
|
|
_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
|
|
|
|
#define DRM_NOTE(fmt, ...) \
|
|
|
|
_DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
|
|
|
|
#define DRM_WARN(fmt, ...) \
|
|
|
|
_DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define DRM_INFO_ONCE(fmt, ...) \
|
|
|
|
_DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
|
|
|
|
#define DRM_NOTE_ONCE(fmt, ...) \
|
|
|
|
_DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
|
|
|
|
#define DRM_WARN_ONCE(fmt, ...) \
|
|
|
|
_DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* Error output.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_ERROR(dev, fmt, ...) \
|
|
|
|
drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
|
|
|
|
fmt, ##__VA_ARGS__)
|
|
|
|
#define DRM_ERROR(fmt, ...) \
|
2016-09-26 02:18:34 +00:00
|
|
|
drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-11-21 19:29:51 +00:00
|
|
|
/**
|
|
|
|
* Rate limited error output. Like DRM_ERROR() but won't flood the log.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \
|
2013-11-21 19:29:51 +00:00
|
|
|
({ \
|
|
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
|
|
\
|
|
|
|
if (__ratelimit(&_rs)) \
|
2016-08-15 23:18:04 +00:00
|
|
|
DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \
|
2013-11-21 19:29:51 +00:00
|
|
|
})
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_ERROR_RATELIMITED(fmt, ...) \
|
|
|
|
DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
|
2013-11-21 19:29:51 +00:00
|
|
|
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_INFO(dev, fmt, ...) \
|
|
|
|
drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \
|
|
|
|
##__VA_ARGS__)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_INFO_ONCE(dev, fmt, ...) \
|
|
|
|
({ \
|
|
|
|
static bool __print_once __read_mostly; \
|
|
|
|
if (!__print_once) { \
|
|
|
|
__print_once = true; \
|
|
|
|
DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
})
|
2014-01-31 13:49:07 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* Debug output.
|
2005-09-25 04:28:13 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_DEBUG(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
|
drm: add separate drm debugging levels
Now all the DRM debug info will be reported if the boot option of
"drm.debug=1" is added. Sometimes it is inconvenient to get the debug
info in KMS mode. We will get too much unrelated info.
This will separate several DRM debug levels and the debug level can be used
to print the different debug info. And the debug level is controlled by the
module parameter of drm.debug
In this patch it is divided into four debug levels;
drm_core, drm_driver, drm_kms, drm_mode.
At the same time we can get the different debug info by changing the debug
level. This can be done by adding the module parameter. Of course it can
be changed through the /sys/module/drm/parameters/debug after the system is
booted.
Four debug macro definitions are provided.
DRM_DEBUG(fmt, args...)
DRM_DEBUG_DRIVER(prefix, fmt, args...)
DRM_DEBUG_KMS(prefix, fmt, args...)
DRM_DEBUG_MODE(prefix, fmt, args...)
When the boot option of "drm.debug=4" is added, it will print the debug info
using DRM_DEBUG_KMS macro definition.
When the boot option of "drm.debug=6" is added, it will print the debug info
using DRM_DEBUG_KMS/DRM_DEBUG_DRIVER.
Sometimes we expect to print the value of an array.
For example: SDVO command,
In such case the following four DRM debug macro definitions are added:
DRM_LOG(fmt, args...)
DRM_LOG_DRIVER(fmt, args...)
DRM_LOG_KMS(fmt, args...)
DRM_LOG_MODE(fmt, args...)
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2009-06-02 06:09:47 +00:00
|
|
|
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG_DRIVER(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
|
2016-08-15 23:18:04 +00:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG_KMS(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
|
2016-08-15 23:18:04 +00:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG_PRIME(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
|
2016-08-15 23:18:04 +00:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG_ATOMIC(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
|
2016-08-15 23:18:04 +00:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 02:18:34 +00:00
|
|
|
#define DRM_DEBUG_VBL(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-08-15 23:18:04 +00:00
|
|
|
#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \
|
|
|
|
({ \
|
|
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
|
|
if (__ratelimit(&_rs)) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \
|
|
|
|
__func__, "", fmt, ##args); \
|
|
|
|
})
|
2016-08-06 00:30:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-15 23:18:04 +00:00
|
|
|
#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \
|
|
|
|
DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
|
2016-08-06 00:30:38 +00:00
|
|
|
#define DRM_DEBUG_RATELIMITED(fmt, args...) \
|
2016-08-15 23:18:04 +00:00
|
|
|
DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
|
|
|
|
#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \
|
|
|
|
_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
|
2016-08-06 00:30:38 +00:00
|
|
|
#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
|
2016-08-15 23:18:04 +00:00
|
|
|
DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
|
|
|
|
#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \
|
|
|
|
_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
|
2016-08-06 00:30:38 +00:00
|
|
|
#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
|
2016-08-15 23:18:04 +00:00
|
|
|
DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
|
|
|
|
#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \
|
|
|
|
_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
|
2016-08-06 00:30:38 +00:00
|
|
|
#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
|
2016-08-15 23:18:04 +00:00
|
|
|
DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
|
2016-08-06 00:30:38 +00:00
|
|
|
|
2016-11-05 15:08:06 +00:00
|
|
|
/* Format strings and argument splitters to simplify printing
|
|
|
|
* various "complex" objects
|
|
|
|
*/
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Internal types and structures */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRM device structure. This structure represent a complete card that
|
|
|
|
* may contain multiple heads.
|
|
|
|
*/
|
2007-07-11 05:53:27 +00:00
|
|
|
struct drm_device {
|
2013-12-11 10:34:31 +00:00
|
|
|
struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
|
2005-09-25 04:28:13 +00:00
|
|
|
int if_version; /**< Highest interface version set */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-01-28 15:00:35 +00:00
|
|
|
/** \name Lifetime Management */
|
|
|
|
/*@{ */
|
drm: provide device-refcount
Lets not trick ourselves into thinking "drm_device" objects are not
ref-counted. That's just utterly stupid. We manage "drm_minor" objects on
each drm-device and each minor can have an unlimited number of open
handles. Each of these handles has the drm_minor (and thus the drm_device)
as private-data in the file-handle. Therefore, we may not destroy
"drm_device" until all these handles are closed.
It is *not* possible to reset all these pointers atomically and restrict
access to them, and this is *not* how this is done! Instead, we use
ref-counts to make sure the object is valid and not freed.
Note that we currently use "dev->open_count" for that, which is *exactly*
the same as a reference-count, just open coded. So this patch doesn't
change any semantics on DRM devices (well, this patch just introduces the
ref-count, anyway. Follow-up patches will replace open_count by it).
Also note that generic VFS revoke support could allow us to drop this
ref-count again. We could then just synchronously disable any fops->xy()
calls. However, this is not the case, yet, and no such patches are
in sight (and I seriously question the idea of dropping the ref-cnt
again).
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-01-29 09:21:36 +00:00
|
|
|
struct kref ref; /**< Object ref-count */
|
2014-01-28 15:00:35 +00:00
|
|
|
struct device *dev; /**< Device structure of bus-device */
|
|
|
|
struct drm_driver *driver; /**< DRM driver managing the device */
|
|
|
|
void *dev_private; /**< DRM driver private data */
|
|
|
|
struct drm_minor *control; /**< Control node */
|
|
|
|
struct drm_minor *primary; /**< Primary node */
|
|
|
|
struct drm_minor *render; /**< Render node */
|
2017-01-12 16:15:56 +00:00
|
|
|
bool registered;
|
2016-06-21 08:54:12 +00:00
|
|
|
|
|
|
|
/* currently active master for this device. Protected by master_mutex */
|
|
|
|
struct drm_master *master;
|
|
|
|
|
2014-01-28 15:00:35 +00:00
|
|
|
atomic_t unplugged; /**< Flag whether dev is dead */
|
2014-03-16 12:13:51 +00:00
|
|
|
struct inode *anon_inode; /**< inode for private address-space */
|
2014-04-11 13:23:00 +00:00
|
|
|
char *unique; /**< unique name of the device */
|
2014-01-28 15:00:35 +00:00
|
|
|
/*@} */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/** \name Locks */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2006-02-02 08:37:46 +00:00
|
|
|
struct mutex struct_mutex; /**< For others */
|
2014-02-25 18:57:44 +00:00
|
|
|
struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@} */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/** \name Usage Counters */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2013-11-03 19:46:34 +00:00
|
|
|
int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
|
2013-12-16 10:21:06 +00:00
|
|
|
spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
|
2005-09-25 04:28:13 +00:00
|
|
|
int buf_use; /**< Buffers in use -- cannot alloc */
|
|
|
|
atomic_t buf_alloc; /**< Buffer allocation in progress */
|
|
|
|
/*@} */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-04-26 17:29:41 +00:00
|
|
|
struct mutex filelist_mutex;
|
2007-05-25 19:01:51 +00:00
|
|
|
struct list_head filelist;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/** \name Memory management */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2007-05-25 19:01:51 +00:00
|
|
|
struct list_head maplist; /**< Linked list of regions */
|
2007-07-12 00:26:44 +00:00
|
|
|
struct drm_open_hash map_hash; /**< User token hash table for maps */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/** \name Context handle management */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2007-05-25 19:01:51 +00:00
|
|
|
struct list_head ctxlist; /**< Linked list of context handles */
|
2006-02-02 08:37:46 +00:00
|
|
|
struct mutex ctxlist_mutex; /**< For ctxlist */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-07-17 00:46:52 +00:00
|
|
|
struct idr ctx_idr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-05-25 19:01:51 +00:00
|
|
|
struct list_head vmalist; /**< List of vmas (for debugging) */
|
2008-11-07 22:05:41 +00:00
|
|
|
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@} */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-10-25 22:54:41 +00:00
|
|
|
/** \name DMA support */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2007-07-11 06:32:08 +00:00
|
|
|
struct drm_device_dma *dma; /**< Optional pointer for DMA support */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@} */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/** \name Context support */
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@{ */
|
2013-12-16 10:21:15 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
__volatile__ long context_flag; /**< Context swapping flag */
|
2005-09-25 04:28:13 +00:00
|
|
|
int last_context; /**< Last current context */
|
|
|
|
/*@} */
|
|
|
|
|
2017-05-31 09:22:53 +00:00
|
|
|
/**
|
|
|
|
* @irq_enabled:
|
|
|
|
*
|
|
|
|
* Indicates that interrupt handling is enabled, specifically vblank
|
|
|
|
* handling. Drivers which don't use drm_irq_install() need to set this
|
|
|
|
* to true manually.
|
|
|
|
*/
|
2014-12-17 15:41:41 +00:00
|
|
|
bool irq_enabled;
|
|
|
|
int irq;
|
2005-09-25 04:28:13 +00:00
|
|
|
|
2017-05-24 14:51:45 +00:00
|
|
|
/**
|
|
|
|
* @vblank_disable_immediate:
|
|
|
|
*
|
2014-08-06 11:49:54 +00:00
|
|
|
* If true, vblank interrupt will be disabled immediately when the
|
|
|
|
* refcount drops to zero, as opposed to via the vblank disable
|
|
|
|
* timer.
|
2017-05-24 14:51:45 +00:00
|
|
|
*
|
|
|
|
* This can be set to true it the hardware has a working vblank counter
|
|
|
|
* with high-precision timestamping (otherwise there are races) and the
|
|
|
|
* driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
|
|
|
|
* appropriately. See also @max_vblank_count and
|
|
|
|
* &drm_crtc_funcs.get_vblank_counter.
|
2014-08-06 11:49:54 +00:00
|
|
|
*/
|
|
|
|
bool vblank_disable_immediate;
|
|
|
|
|
2017-05-24 14:51:45 +00:00
|
|
|
/**
|
|
|
|
* @vblank:
|
|
|
|
*
|
|
|
|
* Array of vblank tracking structures, one per &struct drm_crtc. For
|
|
|
|
* historical reasons (vblank support predates kernel modesetting) this
|
|
|
|
* is free-standing and not part of &struct drm_crtc itself. It must be
|
|
|
|
* initialized explicitly by calling drm_vblank_init().
|
|
|
|
*/
|
2013-10-04 11:53:36 +00:00
|
|
|
struct drm_vblank_crtc *vblank;
|
2008-09-30 19:14:26 +00:00
|
|
|
|
drm/vblank: Add support for precise vblank timestamping.
The DRI2 swap & sync implementation needs precise
vblank counts and precise timestamps corresponding
to those vblank counts. For conformance to the OpenML
OML_sync_control extension specification the DRM
timestamp associated with a vblank count should
correspond to the start of video scanout of the first
scanline of the video frame following the vblank
interval for that vblank count.
Therefore we need to carry around precise timestamps
for vblanks. Currently the DRM and KMS drivers generate
timestamps ad-hoc via do_gettimeofday() in some
places. The resulting timestamps are sometimes not
very precise due to interrupt handling delays, they
don't conform to OML_sync_control and some are wrong,
as they aren't taken synchronized to the vblank.
This patch implements support inside the drm core
for precise and robust timestamping. It consists
of the following interrelated pieces.
1. Vblank timestamp caching:
A per-crtc ringbuffer stores the most recent vblank
timestamps corresponding to vblank counts.
The ringbuffer can be read out lock-free via the
accessor function:
struct timeval timestamp;
vblankcount = drm_vblank_count_and_time(dev, crtcid, ×tamp).
The function returns the current vblank count and
the corresponding timestamp for start of video
scanout following the vblank interval. It can be
used anywhere between enclosing drm_vblank_get(dev, crtcid)
and drm_vblank_put(dev,crtcid) statements. It is used
inside the drmWaitVblank ioctl and in the vblank event
queueing and handling. It should be used by kms drivers for
timestamping of bufferswap completion.
The timestamp ringbuffer is reinitialized each time
vblank irq's get reenabled in drm_vblank_get()/
drm_update_vblank_count(). It is invalidated when
vblank irq's get disabled.
The ringbuffer is updated inside drm_handle_vblank()
at each vblank irq.
2. Calculation of precise vblank timestamps:
drm_get_last_vbltimestamp() is used to compute the
timestamp for the end of the most recent vblank (if
inside active scanout), or the expected end of the
current vblank interval (if called inside a vblank
interval). The function calls into a new optional kms
driver entry point dev->driver->get_vblank_timestamp()
which is supposed to provide the precise timestamp.
If a kms driver doesn't implement the entry point or
if the call fails, a simple do_gettimeofday() timestamp
is returned as crude approximation of the true vblank time.
A new drm module parameter drm.timestamp_precision_usec
allows to disable high precision timestamps (if set to
zero) or to specify the maximum acceptable error in
the timestamps in microseconds.
Kms drivers could implement their get_vblank_timestamp()
function in a gpu specific way, as long as returned
timestamps conform to OML_sync_control, e.g., by use
of gpu specific hardware timestamps.
Optionally, kms drivers can simply wrap and use the new
utility function drm_calc_vbltimestamp_from_scanoutpos().
This function calls a new optional kms driver function
dev->driver->get_scanout_position() which returns the
current horizontal and vertical video scanout position
of the crtc. The scanout position together with the
drm_display_timing of the current video mode is used
to calculate elapsed time relative to start of active scanout
for the current video frame. This elapsed time is subtracted
from the current do_gettimeofday() time to get the timestamp
corresponding to start of video scanout. Currently
non-interlaced, non-doublescan video modes, with or
without panel scaling are handled correctly. Interlaced/
doublescan modes are tbd in a future patch.
3. Filtering of redundant vblank irq's and removal of
some race-conditions in the vblank irq enable/disable path:
Some gpu's (e.g., Radeon R500/R600) send spurious vblank
irq's outside the vblank if vblank irq's get reenabled.
These get detected by use of the vblank timestamps and
filtered out to avoid miscounting of vblanks.
Some race-conditions between the vblank irq enable/disable
functions, the vblank irq handler and the gpu itself (updating
its hardware vblank counter in the "wrong" moment) are
fixed inside vblank_disable_and_save() and
drm_update_vblank_count() by use of the vblank timestamps and
a new spinlock dev->vblank_time_lock.
The time until vblank irq disable is now configurable via
a new drm module parameter drm.vblankoffdelay to allow
experimentation with timeouts that are much shorter than
the current 5 seconds and should allow longer vblank off
periods for better power savings.
Followup patches will use these new functions to
implement precise timestamping for the intel and radeon
kms drivers.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2010-10-23 02:20:23 +00:00
|
|
|
spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
|
2005-09-25 04:28:13 +00:00
|
|
|
spinlock_t vbl_lock;
|
2008-09-30 19:14:26 +00:00
|
|
|
|
2017-05-24 14:51:45 +00:00
|
|
|
/**
|
|
|
|
* @max_vblank_count:
|
|
|
|
*
|
|
|
|
* Maximum value of the vblank registers. This value +1 will result in a
|
|
|
|
* wrap-around of the vblank register. It is used by the vblank core to
|
|
|
|
* handle wrap-arounds.
|
|
|
|
*
|
|
|
|
* If set to zero the vblank core will try to guess the elapsed vblanks
|
|
|
|
* between times when the vblank interrupt is disabled through
|
|
|
|
* high-precision timestamps. That approach is suffering from small
|
|
|
|
* races and imprecision over longer time periods, hence exposing a
|
|
|
|
* hardware vblank counter is always recommended.
|
|
|
|
*
|
|
|
|
* If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
|
|
|
|
*/
|
2008-09-30 19:14:26 +00:00
|
|
|
u32 max_vblank_count; /**< size of vblank counter register */
|
2005-09-25 04:28:13 +00:00
|
|
|
|
2009-09-11 18:33:34 +00:00
|
|
|
/**
|
|
|
|
* List of events
|
|
|
|
*/
|
|
|
|
struct list_head vblank_event_list;
|
|
|
|
spinlock_t event_lock;
|
|
|
|
|
2005-09-25 04:28:13 +00:00
|
|
|
/*@} */
|
|
|
|
|
2007-07-11 06:53:40 +00:00
|
|
|
struct drm_agp_head *agp; /**< AGP data */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-25 04:28:13 +00:00
|
|
|
struct pci_dev *pdev; /**< PCI device structure */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef __alpha__
|
|
|
|
struct pci_controller *hose;
|
|
|
|
#endif
|
2010-05-27 19:40:25 +00:00
|
|
|
|
2007-07-11 06:53:40 +00:00
|
|
|
struct drm_sg_mem *sg; /**< Scatter gather memory */
|
2011-02-23 22:35:06 +00:00
|
|
|
unsigned int num_crtcs; /**< Number of CRTCs on this device */
|
2005-09-25 04:28:13 +00:00
|
|
|
|
2014-08-29 10:12:39 +00:00
|
|
|
struct {
|
|
|
|
int context;
|
|
|
|
struct drm_hw_lock *lock;
|
|
|
|
} sigdata;
|
|
|
|
|
2009-02-02 05:55:46 +00:00
|
|
|
struct drm_local_map *agp_buffer_map;
|
2005-08-05 12:11:22 +00:00
|
|
|
unsigned int agp_buffer_token;
|
2006-10-24 13:04:19 +00:00
|
|
|
|
2014-11-26 01:33:10 +00:00
|
|
|
struct drm_mode_config mode_config; /**< Current mode config */
|
2008-11-07 22:05:41 +00:00
|
|
|
|
2008-07-30 19:06:12 +00:00
|
|
|
/** \name GEM information */
|
|
|
|
/*@{ */
|
2013-08-14 22:02:44 +00:00
|
|
|
struct mutex object_name_lock;
|
2008-07-30 19:06:12 +00:00
|
|
|
struct idr object_name_idr;
|
2013-12-11 13:24:46 +00:00
|
|
|
struct drm_vma_offset_manager *vma_offset_manager;
|
2008-07-30 19:06:12 +00:00
|
|
|
/*@} */
|
2010-12-06 23:20:40 +00:00
|
|
|
int switch_power_state;
|
2007-07-11 05:53:27 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-12-22 08:50:42 +00:00
|
|
|
/**
|
|
|
|
* drm_drv_uses_atomic_modeset - check if the driver implements
|
|
|
|
* atomic_commit()
|
|
|
|
* @dev: DRM device
|
|
|
|
*
|
|
|
|
* This check is useful if drivers do not have DRIVER_ATOMIC set but
|
|
|
|
* have atomic modesetting internally implemented.
|
|
|
|
*/
|
|
|
|
static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return dev->mode_config.funcs->atomic_commit != NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-06 23:20:40 +00:00
|
|
|
#define DRM_SWITCH_POWER_ON 0
|
|
|
|
#define DRM_SWITCH_POWER_OFF 1
|
|
|
|
#define DRM_SWITCH_POWER_CHANGING 2
|
2012-09-12 05:55:05 +00:00
|
|
|
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
|
2010-12-06 23:20:40 +00:00
|
|
|
|
2005-09-25 04:28:13 +00:00
|
|
|
static __inline__ int drm_core_check_feature(struct drm_device *dev,
|
|
|
|
int feature)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return ((dev->driver->driver_features & feature) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2012-02-20 14:18:07 +00:00
|
|
|
static inline void drm_device_set_unplugged(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
smp_wmb();
|
|
|
|
atomic_set(&dev->unplugged, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int drm_device_is_unplugged(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
int ret = atomic_read(&dev->unplugged);
|
|
|
|
smp_rmb();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/******************************************************************/
|
|
|
|
/** \name Internal function definitions */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/* Driver support (drm_drv.h) */
|
|
|
|
|
2007-03-23 02:28:33 +00:00
|
|
|
/*
|
|
|
|
* These are exported to drivers so that they can implement fencing using
|
|
|
|
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
|
|
|
|
*/
|
|
|
|
|
2010-12-14 17:16:38 +00:00
|
|
|
/*@}*/
|
|
|
|
|
2012-01-05 09:55:22 +00:00
|
|
|
/* returns true if currently okay to sleep */
|
|
|
|
static __inline__ bool drm_can_sleep(void)
|
|
|
|
{
|
|
|
|
if (in_atomic() || in_dbg_master() || irqs_disabled())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
drm: fix potential dangling else problems in for_each_ macros
We have serious dangling else bugs waiting to happen in our for_each_
style macros with ifs. Consider, for example,
#define drm_for_each_plane_mask(plane, dev, plane_mask) \
list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
if ((plane_mask) & (1 << drm_plane_index(plane)))
If this is used in context:
if (condition)
drm_for_each_plane_mask(plane, dev, plane_mask);
else
foo();
foo() will be called for each plane *not* in plane_mask, if condition
holds, and not at all if condition doesn't hold.
Fix this by reversing the conditions in the macros, and adding an else
branch for the "for each" block, so that other if/else blocks can't
interfere. Provide a "for_each_if" helper macro to make it easier to get
this right.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1448392916-2281-1-git-send-email-jani.nikula@intel.com
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-11-24 19:21:55 +00:00
|
|
|
/* helper for handling conditionals in various for_each macros */
|
|
|
|
#define for_each_if(condition) if (!(condition)) {} else
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|