drmP.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. /*
  2. * Internal Header for the Direct Rendering Manager
  3. *
  4. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  5. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  6. * Copyright (c) 2009-2010, Code Aurora Forum.
  7. * All rights reserved.
  8. *
  9. * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  10. * Author: Gareth Hughes <gareth@valinux.com>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice (including the next
  20. * paragraph) shall be included in all copies or substantial portions of the
  21. * Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  27. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  28. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  29. * OTHER DEALINGS IN THE SOFTWARE.
  30. */
  31. #ifndef _DRM_P_H_
  32. #define _DRM_P_H_
  33. #include <linux/agp_backend.h>
  34. #include <linux/cdev.h>
  35. #include <linux/dma-mapping.h>
  36. #include <linux/file.h>
  37. #include <linux/fs.h>
  38. #include <linux/highmem.h>
  39. #include <linux/idr.h>
  40. #include <linux/init.h>
  41. #include <linux/io.h>
  42. #include <linux/jiffies.h>
  43. #include <linux/kernel.h>
  44. #include <linux/kref.h>
  45. #include <linux/miscdevice.h>
  46. #include <linux/mm.h>
  47. #include <linux/mutex.h>
  48. #include <linux/pci.h>
  49. #include <linux/platform_device.h>
  50. #include <linux/poll.h>
  51. #include <linux/ratelimit.h>
  52. #include <linux/sched.h>
  53. #include <linux/slab.h>
  54. #include <linux/types.h>
  55. #include <linux/vmalloc.h>
  56. #include <linux/workqueue.h>
  57. #include <asm/mman.h>
  58. #include <asm/pgalloc.h>
  59. #include <asm/uaccess.h>
  60. #include <uapi/drm/drm.h>
  61. #include <uapi/drm/drm_mode.h>
  62. #include <drm/drm_agpsupport.h>
  63. #include <drm/drm_crtc.h>
  64. #include <drm/drm_global.h>
  65. #include <drm/drm_hashtab.h>
  66. #include <drm/drm_mem_util.h>
  67. #include <drm/drm_mm.h>
  68. #include <drm/drm_os_linux.h>
  69. #include <drm/drm_sarea.h>
  70. #include <drm/drm_vma_manager.h>
  71. struct module;
  72. struct drm_file;
  73. struct drm_device;
  74. struct drm_agp_head;
  75. struct drm_local_map;
  76. struct drm_device_dma;
  77. struct drm_dma_handle;
  78. struct drm_gem_object;
  79. struct device_node;
  80. struct videomode;
  81. struct reservation_object;
  82. struct dma_buf_attachment;
  83. /*
  84. * 4 debug categories are defined:
  85. *
  86. * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
  87. * This is the category used by the DRM_DEBUG() macro.
  88. *
  89. * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
  90. * This is the category used by the DRM_DEBUG_DRIVER() macro.
  91. *
  92. * KMS: used in the modesetting code.
  93. * This is the category used by the DRM_DEBUG_KMS() macro.
  94. *
  95. * PRIME: used in the prime code.
  96. * This is the category used by the DRM_DEBUG_PRIME() macro.
  97. *
  98. * ATOMIC: used in the atomic code.
  99. * This is the category used by the DRM_DEBUG_ATOMIC() macro.
  100. *
  101. * VBL: used for verbose debug message in the vblank code
  102. * This is the category used by the DRM_DEBUG_VBL() macro.
  103. *
  104. * Enabling verbose debug messages is done through the drm.debug parameter,
  105. * each category being enabled by a bit.
  106. *
  107. * drm.debug=0x1 will enable CORE messages
  108. * drm.debug=0x2 will enable DRIVER messages
  109. * drm.debug=0x3 will enable CORE and DRIVER messages
  110. * ...
  111. * drm.debug=0x3f will enable all messages
  112. *
  113. * An interesting feature is that it's possible to enable verbose logging at
  114. * run-time by echoing the debug value in its sysfs node:
  115. * # echo 0xf > /sys/module/drm/parameters/debug
  116. */
  117. #define DRM_UT_CORE 0x01
  118. #define DRM_UT_DRIVER 0x02
  119. #define DRM_UT_KMS 0x04
  120. #define DRM_UT_PRIME 0x08
  121. #define DRM_UT_ATOMIC 0x10
  122. #define DRM_UT_VBL 0x20
  123. extern __printf(2, 3)
  124. void drm_ut_debug_printk(const char *function_name,
  125. const char *format, ...);
  126. extern __printf(1, 2)
  127. void drm_err(const char *format, ...);
  128. /***********************************************************************/
  129. /** \name DRM template customization defaults */
  130. /*@{*/
  131. /* driver capabilities and requirements mask */
  132. #define DRIVER_USE_AGP 0x1
  133. #define DRIVER_PCI_DMA 0x8
  134. #define DRIVER_SG 0x10
  135. #define DRIVER_HAVE_DMA 0x20
  136. #define DRIVER_HAVE_IRQ 0x40
  137. #define DRIVER_IRQ_SHARED 0x80
  138. #define DRIVER_GEM 0x1000
  139. #define DRIVER_MODESET 0x2000
  140. #define DRIVER_PRIME 0x4000
  141. #define DRIVER_RENDER 0x8000
  142. #define DRIVER_ATOMIC 0x10000
  143. #define DRIVER_KMS_LEGACY_CONTEXT 0x20000
  144. /***********************************************************************/
  145. /** \name Macros to make printk easier */
  146. /*@{*/
  147. #define _DRM_PRINTK(once, level, fmt, ...) \
  148. do { \
  149. printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
  150. ##__VA_ARGS__); \
  151. } while (0)
  152. #define DRM_INFO(fmt, ...) \
  153. _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
  154. #define DRM_NOTE(fmt, ...) \
  155. _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
  156. #define DRM_WARN(fmt, ...) \
  157. _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
  158. #define DRM_INFO_ONCE(fmt, ...) \
  159. _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
  160. #define DRM_NOTE_ONCE(fmt, ...) \
  161. _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
  162. #define DRM_WARN_ONCE(fmt, ...) \
  163. _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
  164. /**
  165. * Error output.
  166. *
  167. * \param fmt printf() like format string.
  168. * \param arg arguments
  169. */
  170. #define DRM_ERROR(fmt, ...) \
  171. drm_err(fmt, ##__VA_ARGS__)
  172. /**
  173. * Rate limited error output. Like DRM_ERROR() but won't flood the log.
  174. *
  175. * \param fmt printf() like format string.
  176. * \param arg arguments
  177. */
  178. #define DRM_ERROR_RATELIMITED(fmt, ...) \
  179. ({ \
  180. static DEFINE_RATELIMIT_STATE(_rs, \
  181. DEFAULT_RATELIMIT_INTERVAL, \
  182. DEFAULT_RATELIMIT_BURST); \
  183. \
  184. if (__ratelimit(&_rs)) \
  185. drm_err(fmt, ##__VA_ARGS__); \
  186. })
  187. /**
  188. * Debug output.
  189. *
  190. * \param fmt printf() like format string.
  191. * \param arg arguments
  192. */
  193. #define DRM_DEBUG(fmt, args...) \
  194. do { \
  195. if (unlikely(drm_debug & DRM_UT_CORE)) \
  196. drm_ut_debug_printk(__func__, fmt, ##args); \
  197. } while (0)
  198. #define DRM_DEBUG_DRIVER(fmt, args...) \
  199. do { \
  200. if (unlikely(drm_debug & DRM_UT_DRIVER)) \
  201. drm_ut_debug_printk(__func__, fmt, ##args); \
  202. } while (0)
  203. #define DRM_DEBUG_KMS(fmt, args...) \
  204. do { \
  205. if (unlikely(drm_debug & DRM_UT_KMS)) \
  206. drm_ut_debug_printk(__func__, fmt, ##args); \
  207. } while (0)
  208. #define DRM_DEBUG_PRIME(fmt, args...) \
  209. do { \
  210. if (unlikely(drm_debug & DRM_UT_PRIME)) \
  211. drm_ut_debug_printk(__func__, fmt, ##args); \
  212. } while (0)
  213. #define DRM_DEBUG_ATOMIC(fmt, args...) \
  214. do { \
  215. if (unlikely(drm_debug & DRM_UT_ATOMIC)) \
  216. drm_ut_debug_printk(__func__, fmt, ##args); \
  217. } while (0)
  218. #define DRM_DEBUG_VBL(fmt, args...) \
  219. do { \
  220. if (unlikely(drm_debug & DRM_UT_VBL)) \
  221. drm_ut_debug_printk(__func__, fmt, ##args); \
  222. } while (0)
  223. /*@}*/
  224. /***********************************************************************/
  225. /** \name Internal types and structures */
  226. /*@{*/
  227. #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
  228. /**
  229. * Ioctl function type.
  230. *
  231. * \param inode device inode.
  232. * \param file_priv DRM file private pointer.
  233. * \param cmd command.
  234. * \param arg argument.
  235. */
  236. typedef int drm_ioctl_t(struct drm_device *dev, void *data,
  237. struct drm_file *file_priv);
  238. typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
  239. unsigned long arg);
  240. #define DRM_IOCTL_NR(n) _IOC_NR(n)
  241. #define DRM_MAJOR 226
  242. #define DRM_AUTH 0x1
  243. #define DRM_MASTER 0x2
  244. #define DRM_ROOT_ONLY 0x4
  245. #define DRM_CONTROL_ALLOW 0x8
  246. #define DRM_UNLOCKED 0x10
  247. #define DRM_RENDER_ALLOW 0x20
  248. struct drm_ioctl_desc {
  249. unsigned int cmd;
  250. int flags;
  251. drm_ioctl_t *func;
  252. const char *name;
  253. };
  254. /**
  255. * Creates a driver or general drm_ioctl_desc array entry for the given
  256. * ioctl, for use by drm_ioctl().
  257. */
  258. #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
  259. [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \
  260. .cmd = DRM_IOCTL_##ioctl, \
  261. .func = _func, \
  262. .flags = _flags, \
  263. .name = #ioctl \
  264. }
  265. /* Event queued up for userspace to read */
  266. struct drm_pending_event {
  267. struct drm_event *event;
  268. struct list_head link;
  269. struct drm_file *file_priv;
  270. pid_t pid; /* pid of requester, no guarantee it's valid by the time
  271. we deliver the event, for tracing only */
  272. void (*destroy)(struct drm_pending_event *event);
  273. };
  274. /* initial implementaton using a linked list - todo hashtab */
  275. struct drm_prime_file_private {
  276. struct list_head head;
  277. struct mutex lock;
  278. };
  279. /** File private data */
  280. struct drm_file {
  281. unsigned authenticated :1;
  282. /* Whether we're master for a minor. Protected by master_mutex */
  283. unsigned is_master :1;
  284. /* true when the client has asked us to expose stereo 3D mode flags */
  285. unsigned stereo_allowed :1;
  286. /*
  287. * true if client understands CRTC primary planes and cursor planes
  288. * in the plane list
  289. */
  290. unsigned universal_planes:1;
  291. /* true if client understands atomic properties */
  292. unsigned atomic:1;
  293. /*
  294. * This client is allowed to gain master privileges for @master.
  295. * Protected by struct drm_device::master_mutex.
  296. */
  297. unsigned allowed_master:1;
  298. struct pid *pid;
  299. kuid_t uid;
  300. drm_magic_t magic;
  301. struct list_head lhead;
  302. struct drm_minor *minor;
  303. unsigned long lock_count;
  304. /** Mapping of mm object handles to object pointers. */
  305. struct idr object_idr;
  306. /** Lock for synchronization of access to object_idr. */
  307. spinlock_t table_lock;
  308. struct file *filp;
  309. void *driver_priv;
  310. struct drm_master *master; /* master this node is currently associated with
  311. N.B. not always minor->master */
  312. /**
  313. * fbs - List of framebuffers associated with this file.
  314. *
  315. * Protected by fbs_lock. Note that the fbs list holds a reference on
  316. * the fb object to prevent it from untimely disappearing.
  317. */
  318. struct list_head fbs;
  319. struct mutex fbs_lock;
  320. /** User-created blob properties; this retains a reference on the
  321. * property. */
  322. struct list_head blobs;
  323. wait_queue_head_t event_wait;
  324. struct list_head event_list;
  325. int event_space;
  326. struct drm_prime_file_private prime;
  327. };
  328. /**
  329. * Lock data.
  330. */
  331. struct drm_lock_data {
  332. struct drm_hw_lock *hw_lock; /**< Hardware lock */
  333. /** Private of lock holder's file (NULL=kernel) */
  334. struct drm_file *file_priv;
  335. wait_queue_head_t lock_queue; /**< Queue of blocked processes */
  336. unsigned long lock_time; /**< Time of last lock in jiffies */
  337. spinlock_t spinlock;
  338. uint32_t kernel_waiters;
  339. uint32_t user_waiters;
  340. int idle_has_lock;
  341. };
  342. /**
  343. * struct drm_master - drm master structure
  344. *
  345. * @refcount: Refcount for this master object.
  346. * @minor: Link back to minor char device we are master for. Immutable.
  347. * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
  348. * @unique_len: Length of unique field. Protected by drm_global_mutex.
  349. * @magic_map: Map of used authentication tokens. Protected by struct_mutex.
  350. * @lock: DRI lock information.
  351. * @driver_priv: Pointer to driver-private information.
  352. */
  353. struct drm_master {
  354. struct kref refcount;
  355. struct drm_minor *minor;
  356. char *unique;
  357. int unique_len;
  358. struct idr magic_map;
  359. struct drm_lock_data lock;
  360. void *driver_priv;
  361. };
  362. /* Size of ringbuffer for vblank timestamps. Just double-buffer
  363. * in initial implementation.
  364. */
  365. #define DRM_VBLANKTIME_RBSIZE 2
  366. /* Flags and return codes for get_vblank_timestamp() driver function. */
  367. #define DRM_CALLED_FROM_VBLIRQ 1
  368. #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
  369. #define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
  370. /* get_scanout_position() return flags */
  371. #define DRM_SCANOUTPOS_VALID (1 << 0)
  372. #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
  373. #define DRM_SCANOUTPOS_ACCURATE (1 << 2)
  374. /**
  375. * DRM driver structure. This structure represent the common code for
  376. * a family of cards. There will one drm_device for each card present
  377. * in this family
  378. */
  379. struct drm_driver {
  380. int (*load) (struct drm_device *, unsigned long flags);
  381. int (*firstopen) (struct drm_device *);
  382. int (*open) (struct drm_device *, struct drm_file *);
  383. void (*preclose) (struct drm_device *, struct drm_file *file_priv);
  384. void (*postclose) (struct drm_device *, struct drm_file *);
  385. void (*lastclose) (struct drm_device *);
  386. int (*unload) (struct drm_device *);
  387. int (*suspend) (struct drm_device *, pm_message_t state);
  388. int (*resume) (struct drm_device *);
  389. int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
  390. int (*dma_quiescent) (struct drm_device *);
  391. int (*context_dtor) (struct drm_device *dev, int context);
  392. int (*set_busid)(struct drm_device *dev, struct drm_master *master);
  393. /**
  394. * get_vblank_counter - get raw hardware vblank counter
  395. * @dev: DRM device
  396. * @pipe: counter to fetch
  397. *
  398. * Driver callback for fetching a raw hardware vblank counter for @crtc.
  399. * If a device doesn't have a hardware counter, the driver can simply
  400. * return the value of drm_vblank_count. The DRM core will account for
  401. * missed vblank events while interrupts where disabled based on system
  402. * timestamps.
  403. *
  404. * Wraparound handling and loss of events due to modesetting is dealt
  405. * with in the DRM core code.
  406. *
  407. * RETURNS
  408. * Raw vblank counter value.
  409. */
  410. u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
  411. /**
  412. * enable_vblank - enable vblank interrupt events
  413. * @dev: DRM device
  414. * @pipe: which irq to enable
  415. *
  416. * Enable vblank interrupts for @crtc. If the device doesn't have
  417. * a hardware vblank counter, this routine should be a no-op, since
  418. * interrupts will have to stay on to keep the count accurate.
  419. *
  420. * RETURNS
  421. * Zero on success, appropriate errno if the given @crtc's vblank
  422. * interrupt cannot be enabled.
  423. */
  424. int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
  425. /**
  426. * disable_vblank - disable vblank interrupt events
  427. * @dev: DRM device
  428. * @pipe: which irq to enable
  429. *
  430. * Disable vblank interrupts for @crtc. If the device doesn't have
  431. * a hardware vblank counter, this routine should be a no-op, since
  432. * interrupts will have to stay on to keep the count accurate.
  433. */
  434. void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
  435. /**
  436. * Called by \c drm_device_is_agp. Typically used to determine if a
  437. * card is really attached to AGP or not.
  438. *
  439. * \param dev DRM device handle
  440. *
  441. * \returns
  442. * One of three values is returned depending on whether or not the
  443. * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
  444. * (return of 1), or may or may not be AGP (return of 2).
  445. */
  446. int (*device_is_agp) (struct drm_device *dev);
  447. /**
  448. * Called by vblank timestamping code.
  449. *
  450. * Return the current display scanout position from a crtc, and an
  451. * optional accurate ktime_get timestamp of when position was measured.
  452. *
  453. * \param dev DRM device.
  454. * \param pipe Id of the crtc to query.
  455. * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
  456. * \param *vpos Target location for current vertical scanout position.
  457. * \param *hpos Target location for current horizontal scanout position.
  458. * \param *stime Target location for timestamp taken immediately before
  459. * scanout position query. Can be NULL to skip timestamp.
  460. * \param *etime Target location for timestamp taken immediately after
  461. * scanout position query. Can be NULL to skip timestamp.
  462. * \param mode Current display timings.
  463. *
  464. * Returns vpos as a positive number while in active scanout area.
  465. * Returns vpos as a negative number inside vblank, counting the number
  466. * of scanlines to go until end of vblank, e.g., -1 means "one scanline
  467. * until start of active scanout / end of vblank."
  468. *
  469. * \return Flags, or'ed together as follows:
  470. *
  471. * DRM_SCANOUTPOS_VALID = Query successful.
  472. * DRM_SCANOUTPOS_INVBL = Inside vblank.
  473. * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
  474. * this flag means that returned position may be offset by a constant
  475. * but unknown small number of scanlines wrt. real scanout position.
  476. *
  477. */
  478. int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
  479. unsigned int flags, int *vpos, int *hpos,
  480. ktime_t *stime, ktime_t *etime,
  481. const struct drm_display_mode *mode);
  482. /**
  483. * Called by \c drm_get_last_vbltimestamp. Should return a precise
  484. * timestamp when the most recent VBLANK interval ended or will end.
  485. *
  486. * Specifically, the timestamp in @vblank_time should correspond as
  487. * closely as possible to the time when the first video scanline of
  488. * the video frame after the end of VBLANK will start scanning out,
  489. * the time immediately after end of the VBLANK interval. If the
  490. * @crtc is currently inside VBLANK, this will be a time in the future.
  491. * If the @crtc is currently scanning out a frame, this will be the
  492. * past start time of the current scanout. This is meant to adhere
  493. * to the OpenML OML_sync_control extension specification.
  494. *
  495. * \param dev dev DRM device handle.
  496. * \param pipe crtc for which timestamp should be returned.
  497. * \param *max_error Maximum allowable timestamp error in nanoseconds.
  498. * Implementation should strive to provide timestamp
  499. * with an error of at most *max_error nanoseconds.
  500. * Returns true upper bound on error for timestamp.
  501. * \param *vblank_time Target location for returned vblank timestamp.
  502. * \param flags 0 = Defaults, no special treatment needed.
  503. * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
  504. * irq handler. Some drivers need to apply some workarounds
  505. * for gpu-specific vblank irq quirks if flag is set.
  506. *
  507. * \returns
  508. * Zero if timestamping isn't supported in current display mode or a
  509. * negative number on failure. A positive status code on success,
  510. * which describes how the vblank_time timestamp was computed.
  511. */
  512. int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
  513. int *max_error,
  514. struct timeval *vblank_time,
  515. unsigned flags);
  516. /* these have to be filled in */
  517. irqreturn_t(*irq_handler) (int irq, void *arg);
  518. void (*irq_preinstall) (struct drm_device *dev);
  519. int (*irq_postinstall) (struct drm_device *dev);
  520. void (*irq_uninstall) (struct drm_device *dev);
  521. /* Master routines */
  522. int (*master_create)(struct drm_device *dev, struct drm_master *master);
  523. void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
  524. /**
  525. * master_set is called whenever the minor master is set.
  526. * master_drop is called whenever the minor master is dropped.
  527. */
  528. int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
  529. bool from_open);
  530. void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
  531. bool from_release);
  532. int (*debugfs_init)(struct drm_minor *minor);
  533. void (*debugfs_cleanup)(struct drm_minor *minor);
  534. /**
  535. * Driver-specific constructor for drm_gem_objects, to set up
  536. * obj->driver_private.
  537. *
  538. * Returns 0 on success.
  539. */
  540. void (*gem_free_object) (struct drm_gem_object *obj);
  541. int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
  542. void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
  543. /* prime: */
  544. /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
  545. int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
  546. uint32_t handle, uint32_t flags, int *prime_fd);
  547. /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
  548. int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
  549. int prime_fd, uint32_t *handle);
  550. /* export GEM -> dmabuf */
  551. struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
  552. struct drm_gem_object *obj, int flags);
  553. /* import dmabuf -> GEM */
  554. struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
  555. struct dma_buf *dma_buf);
  556. /* low-level interface used by drm_gem_prime_{import,export} */
  557. int (*gem_prime_pin)(struct drm_gem_object *obj);
  558. void (*gem_prime_unpin)(struct drm_gem_object *obj);
  559. struct reservation_object * (*gem_prime_res_obj)(
  560. struct drm_gem_object *obj);
  561. struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
  562. struct drm_gem_object *(*gem_prime_import_sg_table)(
  563. struct drm_device *dev,
  564. struct dma_buf_attachment *attach,
  565. struct sg_table *sgt);
  566. void *(*gem_prime_vmap)(struct drm_gem_object *obj);
  567. void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
  568. int (*gem_prime_mmap)(struct drm_gem_object *obj,
  569. struct vm_area_struct *vma);
  570. /* vga arb irq handler */
  571. void (*vgaarb_irq)(struct drm_device *dev, bool state);
  572. /* dumb alloc support */
  573. int (*dumb_create)(struct drm_file *file_priv,
  574. struct drm_device *dev,
  575. struct drm_mode_create_dumb *args);
  576. int (*dumb_map_offset)(struct drm_file *file_priv,
  577. struct drm_device *dev, uint32_t handle,
  578. uint64_t *offset);
  579. int (*dumb_destroy)(struct drm_file *file_priv,
  580. struct drm_device *dev,
  581. uint32_t handle);
  582. /* Driver private ops for this object */
  583. const struct vm_operations_struct *gem_vm_ops;
  584. int major;
  585. int minor;
  586. int patchlevel;
  587. char *name;
  588. char *desc;
  589. char *date;
  590. u32 driver_features;
  591. int dev_priv_size;
  592. const struct drm_ioctl_desc *ioctls;
  593. int num_ioctls;
  594. const struct file_operations *fops;
  595. /* List of devices hanging off this driver with stealth attach. */
  596. struct list_head legacy_dev_list;
  597. };
  598. enum drm_minor_type {
  599. DRM_MINOR_LEGACY,
  600. DRM_MINOR_CONTROL,
  601. DRM_MINOR_RENDER,
  602. DRM_MINOR_CNT,
  603. };
  604. /**
  605. * Info file list entry. This structure represents a debugfs or proc file to
  606. * be created by the drm core
  607. */
  608. struct drm_info_list {
  609. const char *name; /** file name */
  610. int (*show)(struct seq_file*, void*); /** show callback */
  611. u32 driver_features; /**< Required driver features for this entry */
  612. void *data;
  613. };
  614. /**
  615. * debugfs node structure. This structure represents a debugfs file.
  616. */
  617. struct drm_info_node {
  618. struct list_head list;
  619. struct drm_minor *minor;
  620. const struct drm_info_list *info_ent;
  621. struct dentry *dent;
  622. };
  623. /**
  624. * DRM minor structure. This structure represents a drm minor number.
  625. */
  626. struct drm_minor {
  627. int index; /**< Minor device number */
  628. int type; /**< Control or render */
  629. struct device *kdev; /**< Linux device */
  630. struct drm_device *dev;
  631. struct dentry *debugfs_root;
  632. struct list_head debugfs_list;
  633. struct mutex debugfs_lock; /* Protects debugfs_list. */
  634. /* currently active master for this node. Protected by master_mutex */
  635. struct drm_master *master;
  636. };
  637. struct drm_pending_vblank_event {
  638. struct drm_pending_event base;
  639. unsigned int pipe;
  640. struct drm_event_vblank event;
  641. };
  642. struct drm_vblank_crtc {
  643. struct drm_device *dev; /* pointer to the drm_device */
  644. wait_queue_head_t queue; /**< VBLANK wait queue */
  645. struct timer_list disable_timer; /* delayed disable timer */
  646. /* vblank counter, protected by dev->vblank_time_lock for writes */
  647. u32 count;
  648. /* vblank timestamps, protected by dev->vblank_time_lock for writes */
  649. struct timeval time[DRM_VBLANKTIME_RBSIZE];
  650. atomic_t refcount; /* number of users of vblank interruptsper crtc */
  651. u32 last; /* protected by dev->vbl_lock, used */
  652. /* for wraparound handling */
  653. u32 last_wait; /* Last vblank seqno waited per CRTC */
  654. unsigned int inmodeset; /* Display driver is setting mode */
  655. unsigned int pipe; /* crtc index */
  656. int framedur_ns; /* frame/field duration in ns */
  657. int linedur_ns; /* line duration in ns */
  658. bool enabled; /* so we don't call enable more than
  659. once per disable */
  660. };
  661. /**
  662. * DRM device structure. This structure represent a complete card that
  663. * may contain multiple heads.
  664. */
  665. struct drm_device {
  666. struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
  667. int if_version; /**< Highest interface version set */
  668. /** \name Lifetime Management */
  669. /*@{ */
  670. struct kref ref; /**< Object ref-count */
  671. struct device *dev; /**< Device structure of bus-device */
  672. struct drm_driver *driver; /**< DRM driver managing the device */
  673. void *dev_private; /**< DRM driver private data */
  674. struct drm_minor *control; /**< Control node */
  675. struct drm_minor *primary; /**< Primary node */
  676. struct drm_minor *render; /**< Render node */
  677. atomic_t unplugged; /**< Flag whether dev is dead */
  678. struct inode *anon_inode; /**< inode for private address-space */
  679. char *unique; /**< unique name of the device */
  680. /*@} */
  681. /** \name Locks */
  682. /*@{ */
  683. struct mutex struct_mutex; /**< For others */
  684. struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
  685. /*@} */
  686. /** \name Usage Counters */
  687. /*@{ */
  688. int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
  689. spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
  690. int buf_use; /**< Buffers in use -- cannot alloc */
  691. atomic_t buf_alloc; /**< Buffer allocation in progress */
  692. /*@} */
  693. struct list_head filelist;
  694. /** \name Memory management */
  695. /*@{ */
  696. struct list_head maplist; /**< Linked list of regions */
  697. struct drm_open_hash map_hash; /**< User token hash table for maps */
  698. /** \name Context handle management */
  699. /*@{ */
  700. struct list_head ctxlist; /**< Linked list of context handles */
  701. struct mutex ctxlist_mutex; /**< For ctxlist */
  702. struct idr ctx_idr;
  703. struct list_head vmalist; /**< List of vmas (for debugging) */
  704. /*@} */
  705. /** \name DMA support */
  706. /*@{ */
  707. struct drm_device_dma *dma; /**< Optional pointer for DMA support */
  708. /*@} */
  709. /** \name Context support */
  710. /*@{ */
  711. __volatile__ long context_flag; /**< Context swapping flag */
  712. int last_context; /**< Last current context */
  713. /*@} */
  714. /** \name VBLANK IRQ support */
  715. /*@{ */
  716. bool irq_enabled;
  717. int irq;
  718. /*
  719. * At load time, disabling the vblank interrupt won't be allowed since
  720. * old clients may not call the modeset ioctl and therefore misbehave.
  721. * Once the modeset ioctl *has* been called though, we can safely
  722. * disable them when unused.
  723. */
  724. bool vblank_disable_allowed;
  725. /*
  726. * If true, vblank interrupt will be disabled immediately when the
  727. * refcount drops to zero, as opposed to via the vblank disable
  728. * timer.
  729. * This can be set to true it the hardware has a working vblank
  730. * counter and the driver uses drm_vblank_on() and drm_vblank_off()
  731. * appropriately.
  732. */
  733. bool vblank_disable_immediate;
  734. /* array of size num_crtcs */
  735. struct drm_vblank_crtc *vblank;
  736. spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
  737. spinlock_t vbl_lock;
  738. u32 max_vblank_count; /**< size of vblank counter register */
  739. /**
  740. * List of events
  741. */
  742. struct list_head vblank_event_list;
  743. spinlock_t event_lock;
  744. /*@} */
  745. struct drm_agp_head *agp; /**< AGP data */
  746. struct pci_dev *pdev; /**< PCI device structure */
  747. #ifdef __alpha__
  748. struct pci_controller *hose;
  749. #endif
  750. struct platform_device *platformdev; /**< Platform device struture */
  751. struct virtio_device *virtdev;
  752. struct drm_sg_mem *sg; /**< Scatter gather memory */
  753. unsigned int num_crtcs; /**< Number of CRTCs on this device */
  754. struct {
  755. int context;
  756. struct drm_hw_lock *lock;
  757. } sigdata;
  758. struct drm_local_map *agp_buffer_map;
  759. unsigned int agp_buffer_token;
  760. struct drm_mode_config mode_config; /**< Current mode config */
  761. /** \name GEM information */
  762. /*@{ */
  763. struct mutex object_name_lock;
  764. struct idr object_name_idr;
  765. struct drm_vma_offset_manager *vma_offset_manager;
  766. /*@} */
  767. int switch_power_state;
  768. };
  769. #define DRM_SWITCH_POWER_ON 0
  770. #define DRM_SWITCH_POWER_OFF 1
  771. #define DRM_SWITCH_POWER_CHANGING 2
  772. #define DRM_SWITCH_POWER_DYNAMIC_OFF 3
  773. static __inline__ int drm_core_check_feature(struct drm_device *dev,
  774. int feature)
  775. {
  776. return ((dev->driver->driver_features & feature) ? 1 : 0);
  777. }
  778. static inline void drm_device_set_unplugged(struct drm_device *dev)
  779. {
  780. smp_wmb();
  781. atomic_set(&dev->unplugged, 1);
  782. }
  783. static inline int drm_device_is_unplugged(struct drm_device *dev)
  784. {
  785. int ret = atomic_read(&dev->unplugged);
  786. smp_rmb();
  787. return ret;
  788. }
  789. static inline bool drm_is_render_client(const struct drm_file *file_priv)
  790. {
  791. return file_priv->minor->type == DRM_MINOR_RENDER;
  792. }
  793. static inline bool drm_is_control_client(const struct drm_file *file_priv)
  794. {
  795. return file_priv->minor->type == DRM_MINOR_CONTROL;
  796. }
  797. static inline bool drm_is_primary_client(const struct drm_file *file_priv)
  798. {
  799. return file_priv->minor->type == DRM_MINOR_LEGACY;
  800. }
  801. /******************************************************************/
  802. /** \name Internal function definitions */
  803. /*@{*/
  804. /* Driver support (drm_drv.h) */
  805. extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
  806. extern long drm_ioctl(struct file *filp,
  807. unsigned int cmd, unsigned long arg);
  808. extern long drm_compat_ioctl(struct file *filp,
  809. unsigned int cmd, unsigned long arg);
  810. extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
  811. /* Device support (drm_fops.h) */
  812. extern int drm_open(struct inode *inode, struct file *filp);
  813. extern ssize_t drm_read(struct file *filp, char __user *buffer,
  814. size_t count, loff_t *offset);
  815. extern int drm_release(struct inode *inode, struct file *filp);
  816. extern int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv);
  817. /* Mapping support (drm_vm.h) */
  818. extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
  819. /* Misc. IOCTL support (drm_ioctl.c) */
  820. int drm_noop(struct drm_device *dev, void *data,
  821. struct drm_file *file_priv);
  822. int drm_invalid_op(struct drm_device *dev, void *data,
  823. struct drm_file *file_priv);
  824. /* Cache management (drm_cache.c) */
  825. void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
  826. void drm_clflush_sg(struct sg_table *st);
  827. void drm_clflush_virt_range(void *addr, unsigned long length);
  828. /*
  829. * These are exported to drivers so that they can implement fencing using
  830. * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  831. */
  832. /* IRQ support (drm_irq.h) */
  833. extern int drm_irq_install(struct drm_device *dev, int irq);
  834. extern int drm_irq_uninstall(struct drm_device *dev);
  835. extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
  836. extern int drm_wait_vblank(struct drm_device *dev, void *data,
  837. struct drm_file *filp);
  838. extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
  839. extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
  840. extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  841. struct timeval *vblanktime);
  842. extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
  843. struct timeval *vblanktime);
  844. extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
  845. struct drm_pending_vblank_event *e);
  846. extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
  847. struct drm_pending_vblank_event *e);
  848. extern void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe,
  849. struct drm_pending_vblank_event *e);
  850. extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
  851. struct drm_pending_vblank_event *e);
  852. extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
  853. extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
  854. extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
  855. extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
  856. extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
  857. extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
  858. extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
  859. extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
  860. extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
  861. extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
  862. extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
  863. extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
  864. extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
  865. extern void drm_vblank_cleanup(struct drm_device *dev);
  866. extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
  867. extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
  868. unsigned int pipe, int *max_error,
  869. struct timeval *vblank_time,
  870. unsigned flags,
  871. const struct drm_display_mode *mode);
  872. extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
  873. const struct drm_display_mode *mode);
  874. /**
  875. * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
  876. * @crtc: which CRTC's vblank waitqueue to retrieve
  877. *
  878. * This function returns a pointer to the vblank waitqueue for the CRTC.
  879. * Drivers can use this to implement vblank waits using wait_event() & co.
  880. */
  881. static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
  882. {
  883. return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
  884. }
  885. /* Modesetting support */
  886. extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
  887. extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
  888. /* Stub support (drm_stub.h) */
  889. extern struct drm_master *drm_master_get(struct drm_master *master);
  890. extern void drm_master_put(struct drm_master **master);
  891. extern void drm_put_dev(struct drm_device *dev);
  892. extern void drm_unplug_dev(struct drm_device *dev);
  893. extern unsigned int drm_debug;
  894. extern bool drm_atomic;
  895. /* Debugfs support */
  896. #if defined(CONFIG_DEBUG_FS)
  897. extern int drm_debugfs_create_files(const struct drm_info_list *files,
  898. int count, struct dentry *root,
  899. struct drm_minor *minor);
  900. extern int drm_debugfs_remove_files(const struct drm_info_list *files,
  901. int count, struct drm_minor *minor);
  902. #else
  903. static inline int drm_debugfs_create_files(const struct drm_info_list *files,
  904. int count, struct dentry *root,
  905. struct drm_minor *minor)
  906. {
  907. return 0;
  908. }
  909. static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
  910. int count, struct drm_minor *minor)
  911. {
  912. return 0;
  913. }
  914. #endif
  915. extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
  916. struct drm_gem_object *obj,
  917. int flags);
  918. extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  919. struct drm_file *file_priv, uint32_t handle, uint32_t flags,
  920. int *prime_fd);
  921. extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
  922. struct dma_buf *dma_buf);
  923. extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
  924. struct drm_file *file_priv, int prime_fd, uint32_t *handle);
  925. extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
  926. extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
  927. dma_addr_t *addrs, int max_pages);
  928. extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
  929. extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
  930. extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
  931. size_t align);
  932. extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
  933. /* sysfs support (drm_sysfs.c) */
  934. extern void drm_sysfs_hotplug_event(struct drm_device *dev);
  935. struct drm_device *drm_dev_alloc(struct drm_driver *driver,
  936. struct device *parent);
  937. void drm_dev_ref(struct drm_device *dev);
  938. void drm_dev_unref(struct drm_device *dev);
  939. int drm_dev_register(struct drm_device *dev, unsigned long flags);
  940. void drm_dev_unregister(struct drm_device *dev);
  941. int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...);
  942. struct drm_minor *drm_minor_acquire(unsigned int minor_id);
  943. void drm_minor_release(struct drm_minor *minor);
  944. /*@}*/
  945. /* PCI section */
  946. static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
  947. {
  948. if (dev->driver->device_is_agp != NULL) {
  949. int err = (*dev->driver->device_is_agp) (dev);
  950. if (err != 2) {
  951. return err;
  952. }
  953. }
  954. return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
  955. }
  956. void drm_pci_agp_destroy(struct drm_device *dev);
  957. extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
  958. extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
  959. #ifdef CONFIG_PCI
  960. extern int drm_get_pci_dev(struct pci_dev *pdev,
  961. const struct pci_device_id *ent,
  962. struct drm_driver *driver);
  963. extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
  964. #else
  965. static inline int drm_get_pci_dev(struct pci_dev *pdev,
  966. const struct pci_device_id *ent,
  967. struct drm_driver *driver)
  968. {
  969. return -ENOSYS;
  970. }
  971. static inline int drm_pci_set_busid(struct drm_device *dev,
  972. struct drm_master *master)
  973. {
  974. return -ENOSYS;
  975. }
  976. #endif
  977. #define DRM_PCIE_SPEED_25 1
  978. #define DRM_PCIE_SPEED_50 2
  979. #define DRM_PCIE_SPEED_80 4
  980. extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
  981. /* platform section */
  982. extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
  983. extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
  984. /* returns true if currently okay to sleep */
  985. static __inline__ bool drm_can_sleep(void)
  986. {
  987. if (in_atomic() || in_dbg_master() || irqs_disabled())
  988. return false;
  989. return true;
  990. }
  991. #endif