2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2014-08-29 18:12:40 +08:00
|
|
|
* Internal Header for the Direct Rendering Manager
|
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
2010-05-28 03:40:25 +08:00
|
|
|
* Copyright (c) 2009-2010, Code Aurora Forum.
|
2005-04-17 06:20:36 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-08-29 18:12:40 +08:00
|
|
|
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
* Author: Gareth Hughes <gareth@valinux.com>
|
|
|
|
*
|
2005-04-17 06:20:36 +08: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 18:12:37 +08:00
|
|
|
#include <linux/agp_backend.h>
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/file.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/fs.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/idr.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/init.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/jiffies.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/miscdevice.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/mm.h>
|
2006-02-02 16:37:46 +08:00
|
|
|
#include <linux/mutex.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/poll.h>
|
2013-11-22 03:29:51 +08:00
|
|
|
#include <linux/ratelimit.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
2014-08-29 18:12:35 +08:00
|
|
|
#include <linux/vmalloc.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <linux/workqueue.h>
|
2016-10-25 20:00:45 +08:00
|
|
|
#include <linux/dma-fence.h>
|
2017-03-08 22:12:35 +08:00
|
|
|
#include <linux/module.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
|
|
|
|
#include <asm/mman.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/pgalloc.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
|
2014-08-29 18:12:40 +08: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 17:54:08 +08:00
|
|
|
#include <drm/drm_fourcc.h>
|
2014-08-29 18:12:40 +08:00
|
|
|
#include <drm/drm_global.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <drm/drm_hashtab.h>
|
2014-08-29 18:12:40 +08:00
|
|
|
#include <drm/drm_mem_util.h>
|
2014-08-29 18:12:37 +08:00
|
|
|
#include <drm/drm_mm.h>
|
|
|
|
#include <drm/drm_os_linux.h>
|
2012-10-03 01:01:03 +08:00
|
|
|
#include <drm/drm_sarea.h>
|
2016-11-14 19:58:19 +08:00
|
|
|
#include <drm/drm_drv.h>
|
2017-03-08 22:12:35 +08:00
|
|
|
#include <drm/drm_prime.h>
|
2017-03-08 22:12:37 +08:00
|
|
|
#include <drm/drm_pci.h>
|
2017-03-08 22:12:42 +08:00
|
|
|
#include <drm/drm_file.h>
|
2017-03-23 04:53:36 +08:00
|
|
|
#include <drm/drm_debugfs.h>
|
2017-03-23 04:54:47 +08:00
|
|
|
#include <drm/drm_ioctl.h>
|
2017-04-04 17:52:55 +08:00
|
|
|
#include <drm/drm_sysfs.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-05-27 01:46:22 +08:00
|
|
|
struct module;
|
|
|
|
|
2007-09-03 10:06:45 +08:00
|
|
|
struct drm_device;
|
2014-08-29 18:12:32 +08:00
|
|
|
struct drm_agp_head;
|
2014-09-11 13:43:25 +08:00
|
|
|
struct drm_local_map;
|
|
|
|
struct drm_device_dma;
|
2014-09-23 21:46:53 +08:00
|
|
|
struct drm_gem_object;
|
2016-06-21 16:54:22 +08:00
|
|
|
struct drm_master;
|
2016-07-16 03:48:01 +08:00
|
|
|
struct drm_vblank_crtc;
|
2017-03-08 22:12:35 +08:00
|
|
|
struct drm_vma_offset_manager;
|
2007-09-03 10:06:45 +08:00
|
|
|
|
2012-10-29 01:28:06 +08:00
|
|
|
struct device_node;
|
2012-11-14 18:22:52 +08:00
|
|
|
struct videomode;
|
2014-07-01 18:57:26 +08:00
|
|
|
struct reservation_object;
|
2014-01-09 18:03:14 +08:00
|
|
|
struct dma_buf_attachment;
|
2012-11-14 18:22:52 +08:00
|
|
|
|
2017-03-08 22:12:37 +08:00
|
|
|
struct pci_dev;
|
|
|
|
struct pci_controller;
|
|
|
|
|
2009-07-20 13:48:06 +08:00
|
|
|
/*
|
2016-04-14 22:34:16 +08:00
|
|
|
* The following categories are defined:
|
2014-03-24 23:53:08 +08: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 13:48:06 +08:00
|
|
|
*
|
2014-03-24 23:53:08 +08:00
|
|
|
* KMS: used in the modesetting code.
|
|
|
|
* This is the category used by the DRM_DEBUG_KMS() macro.
|
2009-07-20 13:48:06 +08:00
|
|
|
*
|
2014-03-24 23:53:08 +08:00
|
|
|
* PRIME: used in the prime code.
|
|
|
|
* This is the category used by the DRM_DEBUG_PRIME() macro.
|
2009-07-20 13:48:06 +08:00
|
|
|
*
|
2015-02-22 19:24:16 +08:00
|
|
|
* ATOMIC: used in the atomic code.
|
|
|
|
* This is the category used by the DRM_DEBUG_ATOMIC() macro.
|
|
|
|
*
|
2015-10-10 03:57:37 +08: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 23:53:08 +08: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-10 03:57:37 +08:00
|
|
|
* drm.debug=0x3f will enable all messages
|
2014-03-24 23:53:08 +08: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 13:48:06 +08:00
|
|
|
*/
|
2016-08-16 07:18:04 +08:00
|
|
|
#define DRM_UT_NONE 0x00
|
2014-03-24 23:53:08 +08:00
|
|
|
#define DRM_UT_CORE 0x01
|
|
|
|
#define DRM_UT_DRIVER 0x02
|
|
|
|
#define DRM_UT_KMS 0x04
|
|
|
|
#define DRM_UT_PRIME 0x08
|
2015-02-22 19:24:16 +08:00
|
|
|
#define DRM_UT_ATOMIC 0x10
|
2015-10-10 03:57:37 +08:00
|
|
|
#define DRM_UT_VBL 0x20
|
2016-11-05 23:08:09 +08: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 14:09:47 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/***********************************************************************/
|
|
|
|
/** \name DRM template customization defaults */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Macros to make printk easier */
|
|
|
|
/*@{*/
|
|
|
|
|
2016-08-19 01:17:22 +08: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-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* Error output.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-16 07:18:04 +08: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 10:18:34 +08:00
|
|
|
drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-11-22 03:29:51 +08: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-16 07:18:04 +08:00
|
|
|
#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \
|
2013-11-22 03:29:51 +08:00
|
|
|
({ \
|
|
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
|
|
\
|
|
|
|
if (__ratelimit(&_rs)) \
|
2016-08-16 07:18:04 +08:00
|
|
|
DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \
|
2013-11-22 03:29:51 +08:00
|
|
|
})
|
2016-08-16 07:18:04 +08:00
|
|
|
#define DRM_ERROR_RATELIMITED(fmt, ...) \
|
|
|
|
DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
|
2013-11-22 03:29:51 +08:00
|
|
|
|
2016-08-16 07:18:04 +08:00
|
|
|
#define DRM_DEV_INFO(dev, fmt, ...) \
|
|
|
|
drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \
|
|
|
|
##__VA_ARGS__)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-16 07:18:04 +08: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 21:49:07 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* Debug output.
|
2005-09-25 12:28:13 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2016-08-16 07:18:04 +08:00
|
|
|
#define DRM_DEV_DEBUG(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 10:18:34 +08: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 14:09:47 +08:00
|
|
|
|
2016-08-16 07:18:04 +08:00
|
|
|
#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 10:18:34 +08:00
|
|
|
#define DRM_DEBUG_DRIVER(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
|
2016-08-16 07:18:04 +08:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 10:18:34 +08:00
|
|
|
#define DRM_DEBUG_KMS(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
|
2016-08-16 07:18:04 +08:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 10:18:34 +08:00
|
|
|
#define DRM_DEBUG_PRIME(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
|
2016-08-16 07:18:04 +08:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \
|
|
|
|
fmt, ##args)
|
2016-09-26 10:18:34 +08:00
|
|
|
#define DRM_DEBUG_ATOMIC(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
|
2016-08-16 07:18:04 +08:00
|
|
|
|
|
|
|
#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \
|
|
|
|
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \
|
|
|
|
##args)
|
2016-09-26 10:18:34 +08:00
|
|
|
#define DRM_DEBUG_VBL(fmt, ...) \
|
|
|
|
drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-16 07:18:04 +08: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 08:30:38 +08: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-16 07:18:04 +08:00
|
|
|
#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \
|
|
|
|
DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
|
2016-08-06 08:30:38 +08:00
|
|
|
#define DRM_DEBUG_RATELIMITED(fmt, args...) \
|
2016-08-16 07:18:04 +08: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 08:30:38 +08:00
|
|
|
#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
|
2016-08-16 07:18:04 +08: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 08:30:38 +08:00
|
|
|
#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
|
2016-08-16 07:18:04 +08: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 08:30:38 +08:00
|
|
|
#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
|
2016-08-16 07:18:04 +08:00
|
|
|
DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
|
2016-08-06 08:30:38 +08:00
|
|
|
|
2016-11-05 23:08:06 +08:00
|
|
|
/* Format strings and argument splitters to simplify printing
|
|
|
|
* various "complex" objects
|
|
|
|
*/
|
|
|
|
#define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
|
|
|
|
#define DRM_MODE_ARG(m) \
|
|
|
|
(m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
|
|
|
|
(m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
|
|
|
|
(m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
|
|
|
|
(m)->type, (m)->flags
|
|
|
|
|
|
|
|
#define DRM_RECT_FMT "%dx%d%+d%+d"
|
|
|
|
#define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
|
|
|
|
|
|
|
|
/* for rect's in fixed-point format: */
|
|
|
|
#define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
|
|
|
|
#define DRM_RECT_FP_ARG(r) \
|
|
|
|
drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
|
|
|
|
drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
|
|
|
|
(r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
|
|
|
|
(r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Internal types and structures */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
|
|
|
|
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 10:20:23 +08:00
|
|
|
/* Flags and return codes for get_vblank_timestamp() driver function. */
|
|
|
|
#define DRM_CALLED_FROM_VBLIRQ 1
|
|
|
|
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
|
|
|
|
|
|
|
|
/* get_scanout_position() return flags */
|
|
|
|
#define DRM_SCANOUTPOS_VALID (1 << 0)
|
2014-09-10 23:36:11 +08:00
|
|
|
#define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
|
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 10:20:23 +08:00
|
|
|
#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* DRM device structure. This structure represent a complete card that
|
|
|
|
* may contain multiple heads.
|
|
|
|
*/
|
2007-07-11 13:53:27 +08:00
|
|
|
struct drm_device {
|
2013-12-11 18:34:31 +08:00
|
|
|
struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
|
2005-09-25 12:28:13 +08:00
|
|
|
int if_version; /**< Highest interface version set */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-01-28 23:00:35 +08: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 17:21:36 +08:00
|
|
|
struct kref ref; /**< Object ref-count */
|
2014-01-28 23:00:35 +08: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-13 00:15:56 +08:00
|
|
|
bool registered;
|
2016-06-21 16:54:12 +08:00
|
|
|
|
|
|
|
/* currently active master for this device. Protected by master_mutex */
|
|
|
|
struct drm_master *master;
|
|
|
|
|
2014-01-28 23:00:35 +08:00
|
|
|
atomic_t unplugged; /**< Flag whether dev is dead */
|
2014-03-16 20:13:51 +08:00
|
|
|
struct inode *anon_inode; /**< inode for private address-space */
|
2014-04-11 21:23:00 +08:00
|
|
|
char *unique; /**< unique name of the device */
|
2014-01-28 23:00:35 +08:00
|
|
|
/*@} */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/** \name Locks */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2006-02-02 16:37:46 +08:00
|
|
|
struct mutex struct_mutex; /**< For others */
|
2014-02-26 02:57:44 +08:00
|
|
|
struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@} */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/** \name Usage Counters */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2013-11-04 03:46:34 +08:00
|
|
|
int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
|
2013-12-16 18:21:06 +08:00
|
|
|
spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
|
2005-09-25 12:28:13 +08:00
|
|
|
int buf_use; /**< Buffers in use -- cannot alloc */
|
|
|
|
atomic_t buf_alloc; /**< Buffer allocation in progress */
|
|
|
|
/*@} */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-04-27 01:29:41 +08:00
|
|
|
struct mutex filelist_mutex;
|
2007-05-26 03:01:51 +08:00
|
|
|
struct list_head filelist;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/** \name Memory management */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2007-05-26 03:01:51 +08:00
|
|
|
struct list_head maplist; /**< Linked list of regions */
|
2007-07-12 08:26:44 +08:00
|
|
|
struct drm_open_hash map_hash; /**< User token hash table for maps */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/** \name Context handle management */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2007-05-26 03:01:51 +08:00
|
|
|
struct list_head ctxlist; /**< Linked list of context handles */
|
2006-02-02 16:37:46 +08:00
|
|
|
struct mutex ctxlist_mutex; /**< For ctxlist */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-07-17 08:46:52 +08:00
|
|
|
struct idr ctx_idr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-26 03:01:51 +08:00
|
|
|
struct list_head vmalist; /**< List of vmas (for debugging) */
|
2008-11-08 06:05:41 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@} */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-10-26 06:54:41 +08:00
|
|
|
/** \name DMA support */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2007-07-11 14:32:08 +08:00
|
|
|
struct drm_device_dma *dma; /**< Optional pointer for DMA support */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@} */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/** \name Context support */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2013-12-16 18:21:15 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__volatile__ long context_flag; /**< Context swapping flag */
|
2005-09-25 12:28:13 +08:00
|
|
|
int last_context; /**< Last current context */
|
|
|
|
/*@} */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/** \name VBLANK IRQ support */
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@{ */
|
2014-12-17 23:41:41 +08:00
|
|
|
bool irq_enabled;
|
|
|
|
int irq;
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2014-08-06 19:49:54 +08:00
|
|
|
/*
|
|
|
|
* If true, vblank interrupt will be disabled immediately when the
|
|
|
|
* refcount drops to zero, as opposed to via the vblank disable
|
|
|
|
* timer.
|
|
|
|
* This can be set to true it the hardware has a working vblank
|
|
|
|
* counter and the driver uses drm_vblank_on() and drm_vblank_off()
|
|
|
|
* appropriately.
|
|
|
|
*/
|
|
|
|
bool vblank_disable_immediate;
|
|
|
|
|
2013-10-04 19:53:36 +08:00
|
|
|
/* array of size num_crtcs */
|
|
|
|
struct drm_vblank_crtc *vblank;
|
2008-10-01 03:14:26 +08: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 10:20:23 +08:00
|
|
|
spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
|
2005-09-25 12:28:13 +08:00
|
|
|
spinlock_t vbl_lock;
|
2008-10-01 03:14:26 +08:00
|
|
|
|
|
|
|
u32 max_vblank_count; /**< size of vblank counter register */
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2009-09-12 02:33:34 +08:00
|
|
|
/**
|
|
|
|
* List of events
|
|
|
|
*/
|
|
|
|
struct list_head vblank_event_list;
|
|
|
|
spinlock_t event_lock;
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
/*@} */
|
|
|
|
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_agp_head *agp; /**< AGP data */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
struct pci_dev *pdev; /**< PCI device structure */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef __alpha__
|
|
|
|
struct pci_controller *hose;
|
|
|
|
#endif
|
2010-05-28 03:40:25 +08:00
|
|
|
|
2013-09-09 08:02:56 +08:00
|
|
|
struct virtio_device *virtdev;
|
2010-05-28 03:40:25 +08:00
|
|
|
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_sg_mem *sg; /**< Scatter gather memory */
|
2011-02-24 06:35:06 +08:00
|
|
|
unsigned int num_crtcs; /**< Number of CRTCs on this device */
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2014-08-29 18:12:39 +08:00
|
|
|
struct {
|
|
|
|
int context;
|
|
|
|
struct drm_hw_lock *lock;
|
|
|
|
} sigdata;
|
|
|
|
|
2009-02-02 13:55:46 +08:00
|
|
|
struct drm_local_map *agp_buffer_map;
|
2005-08-05 20:11:22 +08:00
|
|
|
unsigned int agp_buffer_token;
|
2006-10-24 21:04:19 +08:00
|
|
|
|
2014-11-26 09:33:10 +08:00
|
|
|
struct drm_mode_config mode_config; /**< Current mode config */
|
2008-11-08 06:05:41 +08:00
|
|
|
|
2008-07-31 03:06:12 +08:00
|
|
|
/** \name GEM information */
|
|
|
|
/*@{ */
|
2013-08-15 06:02:44 +08:00
|
|
|
struct mutex object_name_lock;
|
2008-07-31 03:06:12 +08:00
|
|
|
struct idr object_name_idr;
|
2013-12-11 21:24:46 +08:00
|
|
|
struct drm_vma_offset_manager *vma_offset_manager;
|
2008-07-31 03:06:12 +08:00
|
|
|
/*@} */
|
2010-12-07 07:20:40 +08:00
|
|
|
int switch_power_state;
|
2007-07-11 13:53:27 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-12-22 16:50:42 +08: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;
|
|
|
|
}
|
|
|
|
|
2016-07-16 03:48:01 +08:00
|
|
|
#include <drm/drm_irq.h>
|
|
|
|
|
2010-12-07 07:20:40 +08:00
|
|
|
#define DRM_SWITCH_POWER_ON 0
|
|
|
|
#define DRM_SWITCH_POWER_OFF 1
|
|
|
|
#define DRM_SWITCH_POWER_CHANGING 2
|
2012-09-12 13:55:05 +08:00
|
|
|
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
|
2010-12-07 07:20:40 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
static __inline__ int drm_core_check_feature(struct drm_device *dev,
|
|
|
|
int feature)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return ((dev->driver->driver_features & feature) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2012-02-20 22:18:07 +08: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-17 06:20:36 +08:00
|
|
|
/******************************************************************/
|
|
|
|
/** \name Internal function definitions */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/* Driver support (drm_drv.h) */
|
|
|
|
|
2007-03-23 10:28:33 +08: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-15 01:16:38 +08:00
|
|
|
/*@}*/
|
|
|
|
|
2012-01-05 17:55:22 +08: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-25 03:21:55 +08:00
|
|
|
/* helper for handling conditionals in various for_each macros */
|
|
|
|
#define for_each_if(condition) if (!(condition)) {} else
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|