2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
24 * Authors: Dave Airlie
31 /* TODO: Here are things that needs to be done :
32 * - surface allocator & initializer : (bit like scratch reg) should
33 * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
35 * - WB : write back stuff (do it bit like scratch reg things)
36 * - Vblank : look at Jesse's rework and what we should do
37 * - r600/r700: gart & cp
38 * - cs : clean cs ioctl use bitmap & things like that.
39 * - power management stuff
40 * - Barrier in gart code
41 * - Unmappabled vram ?
42 * - TESTING, TESTING, TESTING
45 /* Initialization path:
46 * We expect that acceleration initialization might fail for various
47 * reasons even thought we work hard to make it works on most
48 * configurations. In order to still have a working userspace in such
49 * situation the init path must succeed up to the memory controller
50 * initialization point. Failure before this point are considered as
51 * fatal error. Here is the init callchain :
52 * radeon_device_init perform common structure, mutex initialization
53 * asic_init setup the GPU memory layout and perform all
54 * one time initialization (failure in this
55 * function are considered fatal)
56 * asic_startup setup the GPU acceleration, in order to
57 * follow guideline the first thing this
58 * function should do is setting the GPU
59 * memory controller (only MC setup failure
60 * are considered as fatal)
63 #include <linux/atomic.h>
64 #include <linux/wait.h>
65 #include <linux/list.h>
66 #include <linux/kref.h>
68 #include <ttm/ttm_bo_api.h>
69 #include <ttm/ttm_bo_driver.h>
70 #include <ttm/ttm_placement.h>
71 #include <ttm/ttm_module.h>
72 #include <ttm/ttm_execbuf_util.h>
74 #include "radeon_family.h"
75 #include "radeon_mode.h"
76 #include "radeon_reg.h"
81 extern int radeon_no_wb
;
82 extern int radeon_modeset
;
83 extern int radeon_dynclks
;
84 extern int radeon_r4xx_atom
;
85 extern int radeon_agpmode
;
86 extern int radeon_vram_limit
;
87 extern int radeon_gart_size
;
88 extern int radeon_benchmarking
;
89 extern int radeon_testing
;
90 extern int radeon_connector_table
;
92 extern int radeon_audio
;
93 extern int radeon_disp_priority
;
94 extern int radeon_hw_i2c
;
95 extern int radeon_pcie_gen2
;
96 extern int radeon_msi
;
97 extern int radeon_lockup_timeout
;
98 extern int radeon_fastfb
;
99 extern int radeon_dpm
;
100 extern int radeon_aspm
;
103 * Copy from radeon_drv.h so we don't have to include both and have conflicting
106 #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
107 #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2)
108 /* RADEON_IB_POOL_SIZE must be a power of 2 */
109 #define RADEON_IB_POOL_SIZE 16
110 #define RADEON_DEBUGFS_MAX_COMPONENTS 32
111 #define RADEONFB_CONN_LIMIT 4
112 #define RADEON_BIOS_NUM_SCRATCH 8
114 /* max number of rings */
115 #define RADEON_NUM_RINGS 6
117 /* fence seq are set to this number when signaled */
118 #define RADEON_FENCE_SIGNALED_SEQ 0LL
120 /* internal ring indices */
121 /* r1xx+ has gfx CP ring */
122 #define RADEON_RING_TYPE_GFX_INDEX 0
124 /* cayman has 2 compute CP rings */
125 #define CAYMAN_RING_TYPE_CP1_INDEX 1
126 #define CAYMAN_RING_TYPE_CP2_INDEX 2
128 /* R600+ has an async dma ring */
129 #define R600_RING_TYPE_DMA_INDEX 3
130 /* cayman add a second async dma ring */
131 #define CAYMAN_RING_TYPE_DMA1_INDEX 4
134 #define R600_RING_TYPE_UVD_INDEX 5
136 /* hardcode those limit for now */
137 #define RADEON_VA_IB_OFFSET (1 << 20)
138 #define RADEON_VA_RESERVED_SIZE (8 << 20)
139 #define RADEON_IB_VM_MAX_SIZE (64 << 10)
142 #define RADEON_RESET_GFX (1 << 0)
143 #define RADEON_RESET_COMPUTE (1 << 1)
144 #define RADEON_RESET_DMA (1 << 2)
145 #define RADEON_RESET_CP (1 << 3)
146 #define RADEON_RESET_GRBM (1 << 4)
147 #define RADEON_RESET_DMA1 (1 << 5)
148 #define RADEON_RESET_RLC (1 << 6)
149 #define RADEON_RESET_SEM (1 << 7)
150 #define RADEON_RESET_IH (1 << 8)
151 #define RADEON_RESET_VMC (1 << 9)
152 #define RADEON_RESET_MC (1 << 10)
153 #define RADEON_RESET_DISPLAY (1 << 11)
156 #define RADEON_CG_BLOCK_GFX (1 << 0)
157 #define RADEON_CG_BLOCK_MC (1 << 1)
158 #define RADEON_CG_BLOCK_SDMA (1 << 2)
159 #define RADEON_CG_BLOCK_UVD (1 << 3)
160 #define RADEON_CG_BLOCK_VCE (1 << 4)
161 #define RADEON_CG_BLOCK_HDP (1 << 5)
163 /* max cursor sizes (in pixels) */
164 #define CURSOR_WIDTH 64
165 #define CURSOR_HEIGHT 64
167 #define CIK_CURSOR_WIDTH 128
168 #define CIK_CURSOR_HEIGHT 128
171 * Errata workarounds.
173 enum radeon_pll_errata
{
174 CHIP_ERRATA_R300_CG
= 0x00000001,
175 CHIP_ERRATA_PLL_DUMMYREADS
= 0x00000002,
176 CHIP_ERRATA_PLL_DELAY
= 0x00000004
180 struct radeon_device
;
186 bool radeon_get_bios(struct radeon_device
*rdev
);
191 struct radeon_dummy_page
{
195 int radeon_dummy_page_init(struct radeon_device
*rdev
);
196 void radeon_dummy_page_fini(struct radeon_device
*rdev
);
202 struct radeon_clock
{
203 struct radeon_pll p1pll
;
204 struct radeon_pll p2pll
;
205 struct radeon_pll dcpll
;
206 struct radeon_pll spll
;
207 struct radeon_pll mpll
;
209 uint32_t default_mclk
;
210 uint32_t default_sclk
;
211 uint32_t default_dispclk
;
212 uint32_t current_dispclk
;
214 uint32_t max_pixel_clock
;
220 int radeon_pm_init(struct radeon_device
*rdev
);
221 void radeon_pm_fini(struct radeon_device
*rdev
);
222 void radeon_pm_compute_clocks(struct radeon_device
*rdev
);
223 void radeon_pm_suspend(struct radeon_device
*rdev
);
224 void radeon_pm_resume(struct radeon_device
*rdev
);
225 void radeon_combios_get_power_modes(struct radeon_device
*rdev
);
226 void radeon_atombios_get_power_modes(struct radeon_device
*rdev
);
227 int radeon_atom_get_clock_dividers(struct radeon_device
*rdev
,
231 struct atom_clock_dividers
*dividers
);
232 int radeon_atom_get_memory_pll_dividers(struct radeon_device
*rdev
,
235 struct atom_mpll_param
*mpll_param
);
236 void radeon_atom_set_voltage(struct radeon_device
*rdev
, u16 voltage_level
, u8 voltage_type
);
237 int radeon_atom_get_voltage_gpio_settings(struct radeon_device
*rdev
,
238 u16 voltage_level
, u8 voltage_type
,
239 u32
*gpio_value
, u32
*gpio_mask
);
240 void radeon_atom_set_engine_dram_timings(struct radeon_device
*rdev
,
241 u32 eng_clock
, u32 mem_clock
);
242 int radeon_atom_get_voltage_step(struct radeon_device
*rdev
,
243 u8 voltage_type
, u16
*voltage_step
);
244 int radeon_atom_get_max_vddc(struct radeon_device
*rdev
, u8 voltage_type
,
245 u16 voltage_id
, u16
*voltage
);
246 int radeon_atom_get_leakage_vddc_based_on_leakage_idx(struct radeon_device
*rdev
,
249 int radeon_atom_get_leakage_id_from_vbios(struct radeon_device
*rdev
,
251 int radeon_atom_get_leakage_vddc_based_on_leakage_params(struct radeon_device
*rdev
,
252 u16
*vddc
, u16
*vddci
,
253 u16 virtual_voltage_id
,
254 u16 vbios_voltage_id
);
255 int radeon_atom_round_to_true_voltage(struct radeon_device
*rdev
,
259 int radeon_atom_get_min_voltage(struct radeon_device
*rdev
,
260 u8 voltage_type
, u16
*min_voltage
);
261 int radeon_atom_get_max_voltage(struct radeon_device
*rdev
,
262 u8 voltage_type
, u16
*max_voltage
);
263 int radeon_atom_get_voltage_table(struct radeon_device
*rdev
,
264 u8 voltage_type
, u8 voltage_mode
,
265 struct atom_voltage_table
*voltage_table
);
266 bool radeon_atom_is_voltage_gpio(struct radeon_device
*rdev
,
267 u8 voltage_type
, u8 voltage_mode
);
268 void radeon_atom_update_memory_dll(struct radeon_device
*rdev
,
270 void radeon_atom_set_ac_timing(struct radeon_device
*rdev
,
272 int radeon_atom_init_mc_reg_table(struct radeon_device
*rdev
,
274 struct atom_mc_reg_table
*reg_table
);
275 int radeon_atom_get_memory_info(struct radeon_device
*rdev
,
276 u8 module_index
, struct atom_memory_info
*mem_info
);
277 int radeon_atom_get_mclk_range_table(struct radeon_device
*rdev
,
278 bool gddr5
, u8 module_index
,
279 struct atom_memory_clock_range_table
*mclk_range_table
);
280 int radeon_atom_get_max_vddc(struct radeon_device
*rdev
, u8 voltage_type
,
281 u16 voltage_id
, u16
*voltage
);
282 void rs690_pm_info(struct radeon_device
*rdev
);
283 extern void evergreen_tiling_fields(unsigned tiling_flags
, unsigned *bankw
,
284 unsigned *bankh
, unsigned *mtaspect
,
285 unsigned *tile_split
);
290 struct radeon_fence_driver
{
291 uint32_t scratch_reg
;
293 volatile uint32_t *cpu_addr
;
294 /* sync_seq is protected by ring emission lock */
295 uint64_t sync_seq
[RADEON_NUM_RINGS
];
297 unsigned long last_activity
;
301 struct radeon_fence
{
302 struct radeon_device
*rdev
;
304 /* protected by radeon_fence.lock */
310 int radeon_fence_driver_start_ring(struct radeon_device
*rdev
, int ring
);
311 int radeon_fence_driver_init(struct radeon_device
*rdev
);
312 void radeon_fence_driver_fini(struct radeon_device
*rdev
);
313 void radeon_fence_driver_force_completion(struct radeon_device
*rdev
);
314 int radeon_fence_emit(struct radeon_device
*rdev
, struct radeon_fence
**fence
, int ring
);
315 void radeon_fence_process(struct radeon_device
*rdev
, int ring
);
316 bool radeon_fence_signaled(struct radeon_fence
*fence
);
317 int radeon_fence_wait(struct radeon_fence
*fence
, bool interruptible
);
318 int radeon_fence_wait_next_locked(struct radeon_device
*rdev
, int ring
);
319 int radeon_fence_wait_empty_locked(struct radeon_device
*rdev
, int ring
);
320 int radeon_fence_wait_any(struct radeon_device
*rdev
,
321 struct radeon_fence
**fences
,
323 struct radeon_fence
*radeon_fence_ref(struct radeon_fence
*fence
);
324 void radeon_fence_unref(struct radeon_fence
**fence
);
325 unsigned radeon_fence_count_emitted(struct radeon_device
*rdev
, int ring
);
326 bool radeon_fence_need_sync(struct radeon_fence
*fence
, int ring
);
327 void radeon_fence_note_sync(struct radeon_fence
*fence
, int ring
);
328 static inline struct radeon_fence
*radeon_fence_later(struct radeon_fence
*a
,
329 struct radeon_fence
*b
)
339 BUG_ON(a
->ring
!= b
->ring
);
341 if (a
->seq
> b
->seq
) {
348 static inline bool radeon_fence_is_earlier(struct radeon_fence
*a
,
349 struct radeon_fence
*b
)
359 BUG_ON(a
->ring
!= b
->ring
);
361 return a
->seq
< b
->seq
;
367 struct radeon_surface_reg
{
368 struct radeon_bo
*bo
;
371 #define RADEON_GEM_MAX_SURFACES 8
377 struct ttm_bo_global_ref bo_global_ref
;
378 struct drm_global_reference mem_global_ref
;
379 struct ttm_bo_device bdev
;
380 bool mem_global_referenced
;
384 /* bo virtual address in a specific vm */
385 struct radeon_bo_va
{
386 /* protected by bo being reserved */
387 struct list_head bo_list
;
394 /* protected by vm mutex */
395 struct list_head vm_list
;
397 /* constant after initialization */
398 struct radeon_vm
*vm
;
399 struct radeon_bo
*bo
;
403 /* Protected by gem.mutex */
404 struct list_head list
;
405 /* Protected by tbo.reserved */
407 struct ttm_placement placement
;
408 struct ttm_buffer_object tbo
;
409 struct ttm_bo_kmap_obj kmap
;
415 /* list of all virtual address to which this bo
419 /* Constant after initialization */
420 struct radeon_device
*rdev
;
421 struct drm_gem_object gem_base
;
423 struct ttm_bo_kmap_obj dma_buf_vmap
;
426 #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
428 struct radeon_bo_list
{
429 struct ttm_validate_buffer tv
;
430 struct radeon_bo
*bo
;
438 int radeon_gem_debugfs_init(struct radeon_device
*rdev
);
440 /* sub-allocation manager, it has to be protected by another lock.
441 * By conception this is an helper for other part of the driver
442 * like the indirect buffer or semaphore, which both have their
445 * Principe is simple, we keep a list of sub allocation in offset
446 * order (first entry has offset == 0, last entry has the highest
449 * When allocating new object we first check if there is room at
450 * the end total_size - (last_object_offset + last_object_size) >=
451 * alloc_size. If so we allocate new object there.
453 * When there is not enough room at the end, we start waiting for
454 * each sub object until we reach object_offset+object_size >=
455 * alloc_size, this object then become the sub object we return.
457 * Alignment can't be bigger than page size.
459 * Hole are not considered for allocation to keep things simple.
460 * Assumption is that there won't be hole (all object on same
463 struct radeon_sa_manager
{
464 wait_queue_head_t wq
;
465 struct radeon_bo
*bo
;
466 struct list_head
*hole
;
467 struct list_head flist
[RADEON_NUM_RINGS
];
468 struct list_head olist
;
478 /* sub-allocation buffer */
479 struct radeon_sa_bo
{
480 struct list_head olist
;
481 struct list_head flist
;
482 struct radeon_sa_manager
*manager
;
485 struct radeon_fence
*fence
;
493 struct list_head objects
;
496 int radeon_gem_init(struct radeon_device
*rdev
);
497 void radeon_gem_fini(struct radeon_device
*rdev
);
498 int radeon_gem_object_create(struct radeon_device
*rdev
, int size
,
499 int alignment
, int initial_domain
,
500 bool discardable
, bool kernel
,
501 struct drm_gem_object
**obj
);
503 int radeon_mode_dumb_create(struct drm_file
*file_priv
,
504 struct drm_device
*dev
,
505 struct drm_mode_create_dumb
*args
);
506 int radeon_mode_dumb_mmap(struct drm_file
*filp
,
507 struct drm_device
*dev
,
508 uint32_t handle
, uint64_t *offset_p
);
509 int radeon_mode_dumb_destroy(struct drm_file
*file_priv
,
510 struct drm_device
*dev
,
516 /* everything here is constant */
517 struct radeon_semaphore
{
518 struct radeon_sa_bo
*sa_bo
;
523 int radeon_semaphore_create(struct radeon_device
*rdev
,
524 struct radeon_semaphore
**semaphore
);
525 void radeon_semaphore_emit_signal(struct radeon_device
*rdev
, int ring
,
526 struct radeon_semaphore
*semaphore
);
527 void radeon_semaphore_emit_wait(struct radeon_device
*rdev
, int ring
,
528 struct radeon_semaphore
*semaphore
);
529 int radeon_semaphore_sync_rings(struct radeon_device
*rdev
,
530 struct radeon_semaphore
*semaphore
,
531 int signaler
, int waiter
);
532 void radeon_semaphore_free(struct radeon_device
*rdev
,
533 struct radeon_semaphore
**semaphore
,
534 struct radeon_fence
*fence
);
537 * GART structures, functions & helpers
541 #define RADEON_GPU_PAGE_SIZE 4096
542 #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
543 #define RADEON_GPU_PAGE_SHIFT 12
544 #define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
547 dma_addr_t table_addr
;
548 struct radeon_bo
*robj
;
550 unsigned num_gpu_pages
;
551 unsigned num_cpu_pages
;
554 dma_addr_t
*pages_addr
;
558 int radeon_gart_table_ram_alloc(struct radeon_device
*rdev
);
559 void radeon_gart_table_ram_free(struct radeon_device
*rdev
);
560 int radeon_gart_table_vram_alloc(struct radeon_device
*rdev
);
561 void radeon_gart_table_vram_free(struct radeon_device
*rdev
);
562 int radeon_gart_table_vram_pin(struct radeon_device
*rdev
);
563 void radeon_gart_table_vram_unpin(struct radeon_device
*rdev
);
564 int radeon_gart_init(struct radeon_device
*rdev
);
565 void radeon_gart_fini(struct radeon_device
*rdev
);
566 void radeon_gart_unbind(struct radeon_device
*rdev
, unsigned offset
,
568 int radeon_gart_bind(struct radeon_device
*rdev
, unsigned offset
,
569 int pages
, struct page
**pagelist
,
570 dma_addr_t
*dma_addr
);
571 void radeon_gart_restore(struct radeon_device
*rdev
);
575 * GPU MC structures, functions & helpers
578 resource_size_t aper_size
;
579 resource_size_t aper_base
;
580 resource_size_t agp_base
;
581 /* for some chips with <= 32MB we need to lie
582 * about vram size near mc fb location */
584 u64 visible_vram_size
;
594 bool igp_sideport_enabled
;
599 bool radeon_combios_sideport_present(struct radeon_device
*rdev
);
600 bool radeon_atombios_sideport_present(struct radeon_device
*rdev
);
603 * GPU scratch registers structures, functions & helpers
605 struct radeon_scratch
{
612 int radeon_scratch_get(struct radeon_device
*rdev
, uint32_t *reg
);
613 void radeon_scratch_free(struct radeon_device
*rdev
, uint32_t reg
);
616 * GPU doorbell structures, functions & helpers
618 struct radeon_doorbell
{
622 resource_size_t base
;
623 resource_size_t size
;
627 int radeon_doorbell_get(struct radeon_device
*rdev
, u32
*page
);
628 void radeon_doorbell_free(struct radeon_device
*rdev
, u32 doorbell
);
634 struct radeon_unpin_work
{
635 struct work_struct work
;
636 struct radeon_device
*rdev
;
638 struct radeon_fence
*fence
;
639 struct drm_pending_vblank_event
*event
;
640 struct radeon_bo
*old_rbo
;
644 struct r500_irq_stat_regs
{
649 struct r600_irq_stat_regs
{
659 struct evergreen_irq_stat_regs
{
680 struct cik_irq_stat_regs
{
690 union radeon_irq_stat_regs
{
691 struct r500_irq_stat_regs r500
;
692 struct r600_irq_stat_regs r600
;
693 struct evergreen_irq_stat_regs evergreen
;
694 struct cik_irq_stat_regs cik
;
697 #define RADEON_MAX_HPD_PINS 6
698 #define RADEON_MAX_CRTCS 6
699 #define RADEON_MAX_AFMT_BLOCKS 6
704 atomic_t ring_int
[RADEON_NUM_RINGS
];
705 bool crtc_vblank_int
[RADEON_MAX_CRTCS
];
706 atomic_t pflip
[RADEON_MAX_CRTCS
];
707 wait_queue_head_t vblank_queue
;
708 bool hpd
[RADEON_MAX_HPD_PINS
];
709 bool afmt
[RADEON_MAX_AFMT_BLOCKS
];
710 union radeon_irq_stat_regs stat_regs
;
714 int radeon_irq_kms_init(struct radeon_device
*rdev
);
715 void radeon_irq_kms_fini(struct radeon_device
*rdev
);
716 void radeon_irq_kms_sw_irq_get(struct radeon_device
*rdev
, int ring
);
717 void radeon_irq_kms_sw_irq_put(struct radeon_device
*rdev
, int ring
);
718 void radeon_irq_kms_pflip_irq_get(struct radeon_device
*rdev
, int crtc
);
719 void radeon_irq_kms_pflip_irq_put(struct radeon_device
*rdev
, int crtc
);
720 void radeon_irq_kms_enable_afmt(struct radeon_device
*rdev
, int block
);
721 void radeon_irq_kms_disable_afmt(struct radeon_device
*rdev
, int block
);
722 void radeon_irq_kms_enable_hpd(struct radeon_device
*rdev
, unsigned hpd_mask
);
723 void radeon_irq_kms_disable_hpd(struct radeon_device
*rdev
, unsigned hpd_mask
);
730 struct radeon_sa_bo
*sa_bo
;
735 struct radeon_fence
*fence
;
736 struct radeon_vm
*vm
;
738 struct radeon_fence
*sync_to
[RADEON_NUM_RINGS
];
739 struct radeon_semaphore
*semaphore
;
743 struct radeon_bo
*ring_obj
;
744 volatile uint32_t *ring
;
748 unsigned rptr_save_reg
;
749 u64 next_rptr_gpu_addr
;
750 volatile u32
*next_rptr_cpu_addr
;
755 unsigned ring_free_dw
;
757 unsigned long last_activity
;
767 u64 last_semaphore_signal_addr
;
768 u64 last_semaphore_wait_addr
;
773 struct radeon_bo
*mqd_obj
;
774 u32 doorbell_page_num
;
780 struct radeon_bo
*hpd_eop_obj
;
781 u64 hpd_eop_gpu_addr
;
791 /* maximum number of VMIDs */
792 #define RADEON_NUM_VM 16
794 /* defines number of bits in page table versus page directory,
795 * a page is 4KB so we have 12 bits offset, 9 bits in the page
796 * table and the remaining 19 bits are in the page directory */
797 #define RADEON_VM_BLOCK_SIZE 9
799 /* number of entries in page table */
800 #define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
802 /* PTBs (Page Table Blocks) need to be aligned to 32K */
803 #define RADEON_VM_PTB_ALIGN_SIZE 32768
804 #define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1)
805 #define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK)
808 struct list_head list
;
812 /* contains the page directory */
813 struct radeon_sa_bo
*page_directory
;
814 uint64_t pd_gpu_addr
;
816 /* array of page tables, one for each page directory entry */
817 struct radeon_sa_bo
**page_tables
;
820 /* last fence for cs using this vm */
821 struct radeon_fence
*fence
;
822 /* last flush or NULL if we still need to flush */
823 struct radeon_fence
*last_flush
;
826 struct radeon_vm_manager
{
828 struct list_head lru_vm
;
829 struct radeon_fence
*active
[RADEON_NUM_VM
];
830 struct radeon_sa_manager sa_manager
;
832 /* number of VMIDs */
834 /* vram base address for page table entry */
835 u64 vram_base_offset
;
841 * file private structure
843 struct radeon_fpriv
{
851 struct radeon_bo
*ring_obj
;
852 volatile uint32_t *ring
;
864 #include "clearstate_defs.h"
867 /* for power gating */
868 struct radeon_bo
*save_restore_obj
;
869 uint64_t save_restore_gpu_addr
;
870 volatile uint32_t *sr_ptr
;
873 /* for clear state */
874 struct radeon_bo
*clear_state_obj
;
875 uint64_t clear_state_gpu_addr
;
876 volatile uint32_t *cs_ptr
;
877 const struct cs_section_def
*cs_data
;
878 u32 clear_state_size
;
880 struct radeon_bo
*cp_table_obj
;
881 uint64_t cp_table_gpu_addr
;
882 volatile uint32_t *cp_table_ptr
;
886 int radeon_ib_get(struct radeon_device
*rdev
, int ring
,
887 struct radeon_ib
*ib
, struct radeon_vm
*vm
,
889 void radeon_ib_free(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
890 void radeon_ib_sync_to(struct radeon_ib
*ib
, struct radeon_fence
*fence
);
891 int radeon_ib_schedule(struct radeon_device
*rdev
, struct radeon_ib
*ib
,
892 struct radeon_ib
*const_ib
);
893 int radeon_ib_pool_init(struct radeon_device
*rdev
);
894 void radeon_ib_pool_fini(struct radeon_device
*rdev
);
895 int radeon_ib_ring_tests(struct radeon_device
*rdev
);
896 /* Ring access between begin & end cannot sleep */
897 bool radeon_ring_supports_scratch_reg(struct radeon_device
*rdev
,
898 struct radeon_ring
*ring
);
899 void radeon_ring_free_size(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
900 int radeon_ring_alloc(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ndw
);
901 int radeon_ring_lock(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ndw
);
902 void radeon_ring_commit(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
903 void radeon_ring_unlock_commit(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
904 void radeon_ring_undo(struct radeon_ring
*ring
);
905 void radeon_ring_unlock_undo(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
906 int radeon_ring_test(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
907 void radeon_ring_force_activity(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
908 void radeon_ring_lockup_update(struct radeon_ring
*ring
);
909 bool radeon_ring_test_lockup(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
910 unsigned radeon_ring_backup(struct radeon_device
*rdev
, struct radeon_ring
*ring
,
912 int radeon_ring_restore(struct radeon_device
*rdev
, struct radeon_ring
*ring
,
913 unsigned size
, uint32_t *data
);
914 int radeon_ring_init(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ring_size
,
915 unsigned rptr_offs
, unsigned rptr_reg
, unsigned wptr_reg
,
916 u32 ptr_reg_shift
, u32 ptr_reg_mask
, u32 nop
);
917 void radeon_ring_fini(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
921 void r600_dma_stop(struct radeon_device
*rdev
);
922 int r600_dma_resume(struct radeon_device
*rdev
);
923 void r600_dma_fini(struct radeon_device
*rdev
);
925 void cayman_dma_stop(struct radeon_device
*rdev
);
926 int cayman_dma_resume(struct radeon_device
*rdev
);
927 void cayman_dma_fini(struct radeon_device
*rdev
);
932 struct radeon_cs_reloc
{
933 struct drm_gem_object
*gobj
;
934 struct radeon_bo
*robj
;
935 struct radeon_bo_list lobj
;
940 struct radeon_cs_chunk
{
946 void __user
*user_ptr
;
947 int last_copied_page
;
951 struct radeon_cs_parser
{
953 struct radeon_device
*rdev
;
954 struct drm_file
*filp
;
957 struct radeon_cs_chunk
*chunks
;
958 uint64_t *chunks_array
;
963 struct radeon_cs_reloc
*relocs
;
964 struct radeon_cs_reloc
**relocs_ptr
;
965 struct list_head validated
;
966 unsigned dma_reloc_idx
;
967 /* indices of various chunks */
969 int chunk_relocs_idx
;
971 int chunk_const_ib_idx
;
973 struct radeon_ib const_ib
;
980 struct ww_acquire_ctx ticket
;
983 extern int radeon_cs_finish_pages(struct radeon_cs_parser
*p
);
984 extern u32
radeon_get_ib_value(struct radeon_cs_parser
*p
, int idx
);
986 struct radeon_cs_packet
{
995 typedef int (*radeon_packet0_check_t
)(struct radeon_cs_parser
*p
,
996 struct radeon_cs_packet
*pkt
,
997 unsigned idx
, unsigned reg
);
998 typedef int (*radeon_packet3_check_t
)(struct radeon_cs_parser
*p
,
999 struct radeon_cs_packet
*pkt
);
1005 int radeon_agp_init(struct radeon_device
*rdev
);
1006 void radeon_agp_resume(struct radeon_device
*rdev
);
1007 void radeon_agp_suspend(struct radeon_device
*rdev
);
1008 void radeon_agp_fini(struct radeon_device
*rdev
);
1015 struct radeon_bo
*wb_obj
;
1016 volatile uint32_t *wb
;
1022 #define RADEON_WB_SCRATCH_OFFSET 0
1023 #define RADEON_WB_RING0_NEXT_RPTR 256
1024 #define RADEON_WB_CP_RPTR_OFFSET 1024
1025 #define RADEON_WB_CP1_RPTR_OFFSET 1280
1026 #define RADEON_WB_CP2_RPTR_OFFSET 1536
1027 #define R600_WB_DMA_RPTR_OFFSET 1792
1028 #define R600_WB_IH_WPTR_OFFSET 2048
1029 #define CAYMAN_WB_DMA1_RPTR_OFFSET 2304
1030 #define R600_WB_UVD_RPTR_OFFSET 2560
1031 #define R600_WB_EVENT_OFFSET 3072
1032 #define CIK_WB_CP1_WPTR_OFFSET 3328
1033 #define CIK_WB_CP2_WPTR_OFFSET 3584
1036 * struct radeon_pm - power management datas
1037 * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
1038 * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
1039 * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
1040 * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
1041 * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
1042 * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
1043 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
1044 * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
1045 * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
1046 * @sclk: GPU clock Mhz (core bandwidth depends of this clock)
1047 * @needed_bandwidth: current bandwidth needs
1049 * It keeps track of various data needed to take powermanagement decision.
1050 * Bandwidth need is used to determine minimun clock of the GPU and memory.
1051 * Equation between gpu/memory clock and available bandwidth is hw dependent
1052 * (type of memory, bus size, efficiency, ...)
1055 enum radeon_pm_method
{
1061 enum radeon_dynpm_state
{
1062 DYNPM_STATE_DISABLED
,
1063 DYNPM_STATE_MINIMUM
,
1066 DYNPM_STATE_SUSPENDED
,
1068 enum radeon_dynpm_action
{
1070 DYNPM_ACTION_MINIMUM
,
1071 DYNPM_ACTION_DOWNCLOCK
,
1072 DYNPM_ACTION_UPCLOCK
,
1073 DYNPM_ACTION_DEFAULT
1076 enum radeon_voltage_type
{
1083 enum radeon_pm_state_type
{
1084 /* not used for dpm */
1085 POWER_STATE_TYPE_DEFAULT
,
1086 POWER_STATE_TYPE_POWERSAVE
,
1087 /* user selectable states */
1088 POWER_STATE_TYPE_BATTERY
,
1089 POWER_STATE_TYPE_BALANCED
,
1090 POWER_STATE_TYPE_PERFORMANCE
,
1091 /* internal states */
1092 POWER_STATE_TYPE_INTERNAL_UVD
,
1093 POWER_STATE_TYPE_INTERNAL_UVD_SD
,
1094 POWER_STATE_TYPE_INTERNAL_UVD_HD
,
1095 POWER_STATE_TYPE_INTERNAL_UVD_HD2
,
1096 POWER_STATE_TYPE_INTERNAL_UVD_MVC
,
1097 POWER_STATE_TYPE_INTERNAL_BOOT
,
1098 POWER_STATE_TYPE_INTERNAL_THERMAL
,
1099 POWER_STATE_TYPE_INTERNAL_ACPI
,
1100 POWER_STATE_TYPE_INTERNAL_ULV
,
1101 POWER_STATE_TYPE_INTERNAL_3DPERF
,
1104 enum radeon_pm_profile_type
{
1112 #define PM_PROFILE_DEFAULT_IDX 0
1113 #define PM_PROFILE_LOW_SH_IDX 1
1114 #define PM_PROFILE_MID_SH_IDX 2
1115 #define PM_PROFILE_HIGH_SH_IDX 3
1116 #define PM_PROFILE_LOW_MH_IDX 4
1117 #define PM_PROFILE_MID_MH_IDX 5
1118 #define PM_PROFILE_HIGH_MH_IDX 6
1119 #define PM_PROFILE_MAX 7
1121 struct radeon_pm_profile
{
1122 int dpms_off_ps_idx
;
1124 int dpms_off_cm_idx
;
1128 enum radeon_int_thermal_type
{
1130 THERMAL_TYPE_EXTERNAL
,
1131 THERMAL_TYPE_EXTERNAL_GPIO
,
1134 THERMAL_TYPE_ADT7473_WITH_INTERNAL
,
1135 THERMAL_TYPE_EVERGREEN
,
1139 THERMAL_TYPE_EMC2103_WITH_INTERNAL
,
1144 struct radeon_voltage
{
1145 enum radeon_voltage_type type
;
1147 struct radeon_gpio_rec gpio
;
1148 u32 delay
; /* delay in usec from voltage drop to sclk change */
1149 bool active_high
; /* voltage drop is active when bit is high */
1151 u8 vddc_id
; /* index into vddc voltage table */
1152 u8 vddci_id
; /* index into vddci voltage table */
1156 /* evergreen+ vddci */
1160 /* clock mode flags */
1161 #define RADEON_PM_MODE_NO_DISPLAY (1 << 0)
1163 struct radeon_pm_clock_info
{
1169 struct radeon_voltage voltage
;
1170 /* standardized clock flags */
1175 #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
1177 struct radeon_power_state
{
1178 enum radeon_pm_state_type type
;
1179 struct radeon_pm_clock_info
*clock_info
;
1180 /* number of valid clock modes in this power state */
1181 int num_clock_modes
;
1182 struct radeon_pm_clock_info
*default_clock_mode
;
1183 /* standardized state flags */
1185 u32 misc
; /* vbios specific flags */
1186 u32 misc2
; /* vbios specific flags */
1187 int pcie_lanes
; /* pcie lanes */
1191 * Some modes are overclocked by very low value, accept them
1193 #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
1195 enum radeon_dpm_auto_throttle_src
{
1196 RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL
,
1197 RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL
1200 enum radeon_dpm_event_src
{
1201 RADEON_DPM_EVENT_SRC_ANALOG
= 0,
1202 RADEON_DPM_EVENT_SRC_EXTERNAL
= 1,
1203 RADEON_DPM_EVENT_SRC_DIGITAL
= 2,
1204 RADEON_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL
= 3,
1205 RADEON_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL
= 4
1209 u32 caps
; /* vbios flags */
1210 u32
class; /* vbios flags */
1211 u32 class2
; /* vbios flags */
1222 struct radeon_dpm_thermal
{
1223 /* thermal interrupt work */
1224 struct work_struct work
;
1225 /* low temperature threshold */
1227 /* high temperature threshold */
1229 /* was interrupt low to high or high to low */
1233 enum radeon_clk_action
1239 struct radeon_blacklist_clocks
1243 enum radeon_clk_action action
;
1246 struct radeon_clock_and_voltage_limits
{
1253 struct radeon_clock_array
{
1258 struct radeon_clock_voltage_dependency_entry
{
1263 struct radeon_clock_voltage_dependency_table
{
1265 struct radeon_clock_voltage_dependency_entry
*entries
;
1268 union radeon_cac_leakage_entry
{
1280 struct radeon_cac_leakage_table
{
1282 union radeon_cac_leakage_entry
*entries
;
1285 struct radeon_phase_shedding_limits_entry
{
1291 struct radeon_phase_shedding_limits_table
{
1293 struct radeon_phase_shedding_limits_entry
*entries
;
1296 struct radeon_uvd_clock_voltage_dependency_entry
{
1302 struct radeon_uvd_clock_voltage_dependency_table
{
1304 struct radeon_uvd_clock_voltage_dependency_entry
*entries
;
1307 struct radeon_vce_clock_voltage_dependency_entry
{
1313 struct radeon_vce_clock_voltage_dependency_table
{
1315 struct radeon_vce_clock_voltage_dependency_entry
*entries
;
1318 struct radeon_ppm_table
{
1320 u16 cpu_core_number
;
1322 u32 small_ac_platform_tdp
;
1324 u32 small_ac_platform_tdc
;
1331 struct radeon_cac_tdp_table
{
1333 u16 configurable_tdp
;
1335 u16 battery_power_limit
;
1336 u16 small_power_limit
;
1337 u16 low_cac_leakage
;
1338 u16 high_cac_leakage
;
1339 u16 maximum_power_delivery_limit
;
1342 struct radeon_dpm_dynamic_state
{
1343 struct radeon_clock_voltage_dependency_table vddc_dependency_on_sclk
;
1344 struct radeon_clock_voltage_dependency_table vddci_dependency_on_mclk
;
1345 struct radeon_clock_voltage_dependency_table vddc_dependency_on_mclk
;
1346 struct radeon_clock_voltage_dependency_table mvdd_dependency_on_mclk
;
1347 struct radeon_clock_voltage_dependency_table vddc_dependency_on_dispclk
;
1348 struct radeon_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table
;
1349 struct radeon_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table
;
1350 struct radeon_clock_voltage_dependency_table samu_clock_voltage_dependency_table
;
1351 struct radeon_clock_voltage_dependency_table acp_clock_voltage_dependency_table
;
1352 struct radeon_clock_array valid_sclk_values
;
1353 struct radeon_clock_array valid_mclk_values
;
1354 struct radeon_clock_and_voltage_limits max_clock_voltage_on_dc
;
1355 struct radeon_clock_and_voltage_limits max_clock_voltage_on_ac
;
1356 u32 mclk_sclk_ratio
;
1357 u32 sclk_mclk_delta
;
1358 u16 vddc_vddci_delta
;
1359 u16 min_vddc_for_pcie_gen2
;
1360 struct radeon_cac_leakage_table cac_leakage_table
;
1361 struct radeon_phase_shedding_limits_table phase_shedding_limits_table
;
1362 struct radeon_ppm_table
*ppm_table
;
1363 struct radeon_cac_tdp_table
*cac_tdp_table
;
1366 struct radeon_dpm_fan
{
1376 bool ucode_fan_control
;
1379 enum radeon_pcie_gen
{
1380 RADEON_PCIE_GEN1
= 0,
1381 RADEON_PCIE_GEN2
= 1,
1382 RADEON_PCIE_GEN3
= 2,
1383 RADEON_PCIE_GEN_INVALID
= 0xffff
1386 enum radeon_dpm_forced_level
{
1387 RADEON_DPM_FORCED_LEVEL_AUTO
= 0,
1388 RADEON_DPM_FORCED_LEVEL_LOW
= 1,
1389 RADEON_DPM_FORCED_LEVEL_HIGH
= 2,
1393 struct radeon_ps
*ps
;
1394 /* number of valid power states */
1396 /* current power state that is active */
1397 struct radeon_ps
*current_ps
;
1398 /* requested power state */
1399 struct radeon_ps
*requested_ps
;
1400 /* boot up power state */
1401 struct radeon_ps
*boot_ps
;
1402 /* default uvd power state */
1403 struct radeon_ps
*uvd_ps
;
1404 enum radeon_pm_state_type state
;
1405 enum radeon_pm_state_type user_state
;
1407 u32 voltage_response_time
;
1408 u32 backbias_response_time
;
1410 u32 new_active_crtcs
;
1411 int new_active_crtc_count
;
1412 u32 current_active_crtcs
;
1413 int current_active_crtc_count
;
1414 struct radeon_dpm_dynamic_state dyn_state
;
1415 struct radeon_dpm_fan fan
;
1418 u32 near_tdp_limit_adjusted
;
1419 u32 sq_ramping_threshold
;
1423 u16 load_line_slope
;
1426 /* special states active */
1427 bool thermal_active
;
1429 /* thermal handling */
1430 struct radeon_dpm_thermal thermal
;
1432 enum radeon_dpm_forced_level forced_level
;
1433 /* track UVD streams */
1438 void radeon_dpm_enable_uvd(struct radeon_device
*rdev
, bool enable
);
1442 /* write locked while reprogramming mclk */
1443 struct rw_semaphore mclk_lock
;
1445 int active_crtc_count
;
1448 fixed20_12 max_bandwidth
;
1449 fixed20_12 igp_sideport_mclk
;
1450 fixed20_12 igp_system_mclk
;
1451 fixed20_12 igp_ht_link_clk
;
1452 fixed20_12 igp_ht_link_width
;
1453 fixed20_12 k8_bandwidth
;
1454 fixed20_12 sideport_bandwidth
;
1455 fixed20_12 ht_bandwidth
;
1456 fixed20_12 core_bandwidth
;
1459 fixed20_12 needed_bandwidth
;
1460 struct radeon_power_state
*power_state
;
1461 /* number of valid power states */
1462 int num_power_states
;
1463 int current_power_state_index
;
1464 int current_clock_mode_index
;
1465 int requested_power_state_index
;
1466 int requested_clock_mode_index
;
1467 int default_power_state_index
;
1476 struct radeon_i2c_chan
*i2c_bus
;
1477 /* selected pm method */
1478 enum radeon_pm_method pm_method
;
1479 /* dynpm power management */
1480 struct delayed_work dynpm_idle_work
;
1481 enum radeon_dynpm_state dynpm_state
;
1482 enum radeon_dynpm_action dynpm_planned_action
;
1483 unsigned long dynpm_action_timeout
;
1484 bool dynpm_can_upclock
;
1485 bool dynpm_can_downclock
;
1486 /* profile-based power management */
1487 enum radeon_pm_profile_type profile
;
1489 struct radeon_pm_profile profiles
[PM_PROFILE_MAX
];
1490 /* internal thermal controller on rv6xx+ */
1491 enum radeon_int_thermal_type int_thermal_type
;
1492 struct device
*int_hwmon_dev
;
1495 struct radeon_dpm dpm
;
1498 int radeon_pm_get_type_index(struct radeon_device
*rdev
,
1499 enum radeon_pm_state_type ps_type
,
1504 #define RADEON_MAX_UVD_HANDLES 10
1505 #define RADEON_UVD_STACK_SIZE (1024*1024)
1506 #define RADEON_UVD_HEAP_SIZE (1024*1024)
1509 struct radeon_bo
*vcpu_bo
;
1513 atomic_t handles
[RADEON_MAX_UVD_HANDLES
];
1514 struct drm_file
*filp
[RADEON_MAX_UVD_HANDLES
];
1515 unsigned img_size
[RADEON_MAX_UVD_HANDLES
];
1516 struct delayed_work idle_work
;
1519 int radeon_uvd_init(struct radeon_device
*rdev
);
1520 void radeon_uvd_fini(struct radeon_device
*rdev
);
1521 int radeon_uvd_suspend(struct radeon_device
*rdev
);
1522 int radeon_uvd_resume(struct radeon_device
*rdev
);
1523 int radeon_uvd_get_create_msg(struct radeon_device
*rdev
, int ring
,
1524 uint32_t handle
, struct radeon_fence
**fence
);
1525 int radeon_uvd_get_destroy_msg(struct radeon_device
*rdev
, int ring
,
1526 uint32_t handle
, struct radeon_fence
**fence
);
1527 void radeon_uvd_force_into_uvd_segment(struct radeon_bo
*rbo
);
1528 void radeon_uvd_free_handles(struct radeon_device
*rdev
,
1529 struct drm_file
*filp
);
1530 int radeon_uvd_cs_parse(struct radeon_cs_parser
*parser
);
1531 void radeon_uvd_note_usage(struct radeon_device
*rdev
);
1532 int radeon_uvd_calc_upll_dividers(struct radeon_device
*rdev
,
1533 unsigned vclk
, unsigned dclk
,
1534 unsigned vco_min
, unsigned vco_max
,
1535 unsigned fb_factor
, unsigned fb_mask
,
1536 unsigned pd_min
, unsigned pd_max
,
1538 unsigned *optimal_fb_div
,
1539 unsigned *optimal_vclk_div
,
1540 unsigned *optimal_dclk_div
);
1541 int radeon_uvd_send_upll_ctlreq(struct radeon_device
*rdev
,
1542 unsigned cg_upll_func_cntl
);
1547 int bits_per_sample
;
1555 void radeon_benchmark(struct radeon_device
*rdev
, int test_number
);
1561 void radeon_test_moves(struct radeon_device
*rdev
);
1562 void radeon_test_ring_sync(struct radeon_device
*rdev
,
1563 struct radeon_ring
*cpA
,
1564 struct radeon_ring
*cpB
);
1565 void radeon_test_syncing(struct radeon_device
*rdev
);
1571 struct radeon_debugfs
{
1572 struct drm_info_list
*files
;
1576 int radeon_debugfs_add_files(struct radeon_device
*rdev
,
1577 struct drm_info_list
*files
,
1579 int radeon_debugfs_fence_init(struct radeon_device
*rdev
);
1583 * ASIC specific functions.
1585 struct radeon_asic
{
1586 int (*init
)(struct radeon_device
*rdev
);
1587 void (*fini
)(struct radeon_device
*rdev
);
1588 int (*resume
)(struct radeon_device
*rdev
);
1589 int (*suspend
)(struct radeon_device
*rdev
);
1590 void (*vga_set_state
)(struct radeon_device
*rdev
, bool state
);
1591 int (*asic_reset
)(struct radeon_device
*rdev
);
1592 /* ioctl hw specific callback. Some hw might want to perform special
1593 * operation on specific ioctl. For instance on wait idle some hw
1594 * might want to perform and HDP flush through MMIO as it seems that
1595 * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
1598 void (*ioctl_wait_idle
)(struct radeon_device
*rdev
, struct radeon_bo
*bo
);
1599 /* check if 3D engine is idle */
1600 bool (*gui_idle
)(struct radeon_device
*rdev
);
1601 /* wait for mc_idle */
1602 int (*mc_wait_for_idle
)(struct radeon_device
*rdev
);
1603 /* get the reference clock */
1604 u32 (*get_xclk
)(struct radeon_device
*rdev
);
1605 /* get the gpu clock counter */
1606 uint64_t (*get_gpu_clock_counter
)(struct radeon_device
*rdev
);
1609 void (*tlb_flush
)(struct radeon_device
*rdev
);
1610 int (*set_page
)(struct radeon_device
*rdev
, int i
, uint64_t addr
);
1613 int (*init
)(struct radeon_device
*rdev
);
1614 void (*fini
)(struct radeon_device
*rdev
);
1617 void (*set_page
)(struct radeon_device
*rdev
,
1618 struct radeon_ib
*ib
,
1620 uint64_t addr
, unsigned count
,
1621 uint32_t incr
, uint32_t flags
);
1623 /* ring specific callbacks */
1625 void (*ib_execute
)(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
1626 int (*ib_parse
)(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
1627 void (*emit_fence
)(struct radeon_device
*rdev
, struct radeon_fence
*fence
);
1628 void (*emit_semaphore
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
,
1629 struct radeon_semaphore
*semaphore
, bool emit_wait
);
1630 int (*cs_parse
)(struct radeon_cs_parser
*p
);
1631 void (*ring_start
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1632 int (*ring_test
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1633 int (*ib_test
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1634 bool (*is_lockup
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1635 void (*vm_flush
)(struct radeon_device
*rdev
, int ridx
, struct radeon_vm
*vm
);
1637 u32 (*get_rptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1638 u32 (*get_wptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1639 void (*set_wptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1640 } ring
[RADEON_NUM_RINGS
];
1643 int (*set
)(struct radeon_device
*rdev
);
1644 int (*process
)(struct radeon_device
*rdev
);
1648 /* display watermarks */
1649 void (*bandwidth_update
)(struct radeon_device
*rdev
);
1650 /* get frame count */
1651 u32 (*get_vblank_counter
)(struct radeon_device
*rdev
, int crtc
);
1652 /* wait for vblank */
1653 void (*wait_for_vblank
)(struct radeon_device
*rdev
, int crtc
);
1654 /* set backlight level */
1655 void (*set_backlight_level
)(struct radeon_encoder
*radeon_encoder
, u8 level
);
1656 /* get backlight level */
1657 u8 (*get_backlight_level
)(struct radeon_encoder
*radeon_encoder
);
1658 /* audio callbacks */
1659 void (*hdmi_enable
)(struct drm_encoder
*encoder
, bool enable
);
1660 void (*hdmi_setmode
)(struct drm_encoder
*encoder
, struct drm_display_mode
*mode
);
1662 /* copy functions for bo handling */
1664 int (*blit
)(struct radeon_device
*rdev
,
1665 uint64_t src_offset
,
1666 uint64_t dst_offset
,
1667 unsigned num_gpu_pages
,
1668 struct radeon_fence
**fence
);
1669 u32 blit_ring_index
;
1670 int (*dma
)(struct radeon_device
*rdev
,
1671 uint64_t src_offset
,
1672 uint64_t dst_offset
,
1673 unsigned num_gpu_pages
,
1674 struct radeon_fence
**fence
);
1676 /* method used for bo copy */
1677 int (*copy
)(struct radeon_device
*rdev
,
1678 uint64_t src_offset
,
1679 uint64_t dst_offset
,
1680 unsigned num_gpu_pages
,
1681 struct radeon_fence
**fence
);
1682 /* ring used for bo copies */
1683 u32 copy_ring_index
;
1687 int (*set_reg
)(struct radeon_device
*rdev
, int reg
,
1688 uint32_t tiling_flags
, uint32_t pitch
,
1689 uint32_t offset
, uint32_t obj_size
);
1690 void (*clear_reg
)(struct radeon_device
*rdev
, int reg
);
1692 /* hotplug detect */
1694 void (*init
)(struct radeon_device
*rdev
);
1695 void (*fini
)(struct radeon_device
*rdev
);
1696 bool (*sense
)(struct radeon_device
*rdev
, enum radeon_hpd_id hpd
);
1697 void (*set_polarity
)(struct radeon_device
*rdev
, enum radeon_hpd_id hpd
);
1699 /* static power management */
1701 void (*misc
)(struct radeon_device
*rdev
);
1702 void (*prepare
)(struct radeon_device
*rdev
);
1703 void (*finish
)(struct radeon_device
*rdev
);
1704 void (*init_profile
)(struct radeon_device
*rdev
);
1705 void (*get_dynpm_state
)(struct radeon_device
*rdev
);
1706 uint32_t (*get_engine_clock
)(struct radeon_device
*rdev
);
1707 void (*set_engine_clock
)(struct radeon_device
*rdev
, uint32_t eng_clock
);
1708 uint32_t (*get_memory_clock
)(struct radeon_device
*rdev
);
1709 void (*set_memory_clock
)(struct radeon_device
*rdev
, uint32_t mem_clock
);
1710 int (*get_pcie_lanes
)(struct radeon_device
*rdev
);
1711 void (*set_pcie_lanes
)(struct radeon_device
*rdev
, int lanes
);
1712 void (*set_clock_gating
)(struct radeon_device
*rdev
, int enable
);
1713 int (*set_uvd_clocks
)(struct radeon_device
*rdev
, u32 vclk
, u32 dclk
);
1714 int (*get_temperature
)(struct radeon_device
*rdev
);
1716 /* dynamic power management */
1718 int (*init
)(struct radeon_device
*rdev
);
1719 void (*setup_asic
)(struct radeon_device
*rdev
);
1720 int (*enable
)(struct radeon_device
*rdev
);
1721 void (*disable
)(struct radeon_device
*rdev
);
1722 int (*pre_set_power_state
)(struct radeon_device
*rdev
);
1723 int (*set_power_state
)(struct radeon_device
*rdev
);
1724 void (*post_set_power_state
)(struct radeon_device
*rdev
);
1725 void (*display_configuration_changed
)(struct radeon_device
*rdev
);
1726 void (*fini
)(struct radeon_device
*rdev
);
1727 u32 (*get_sclk
)(struct radeon_device
*rdev
, bool low
);
1728 u32 (*get_mclk
)(struct radeon_device
*rdev
, bool low
);
1729 void (*print_power_state
)(struct radeon_device
*rdev
, struct radeon_ps
*ps
);
1730 void (*debugfs_print_current_performance_level
)(struct radeon_device
*rdev
, struct seq_file
*m
);
1731 int (*force_performance_level
)(struct radeon_device
*rdev
, enum radeon_dpm_forced_level level
);
1732 bool (*vblank_too_short
)(struct radeon_device
*rdev
);
1736 void (*pre_page_flip
)(struct radeon_device
*rdev
, int crtc
);
1737 u32 (*page_flip
)(struct radeon_device
*rdev
, int crtc
, u64 crtc_base
);
1738 void (*post_page_flip
)(struct radeon_device
*rdev
, int crtc
);
1746 const unsigned *reg_safe_bm
;
1747 unsigned reg_safe_bm_size
;
1752 const unsigned *reg_safe_bm
;
1753 unsigned reg_safe_bm_size
;
1760 unsigned max_tile_pipes
;
1762 unsigned max_backends
;
1764 unsigned max_threads
;
1765 unsigned max_stack_entries
;
1766 unsigned max_hw_contexts
;
1767 unsigned max_gs_threads
;
1768 unsigned sx_max_export_size
;
1769 unsigned sx_max_export_pos_size
;
1770 unsigned sx_max_export_smx_size
;
1771 unsigned sq_num_cf_insts
;
1772 unsigned tiling_nbanks
;
1773 unsigned tiling_npipes
;
1774 unsigned tiling_group_size
;
1775 unsigned tile_config
;
1776 unsigned backend_map
;
1781 unsigned max_tile_pipes
;
1783 unsigned max_backends
;
1785 unsigned max_threads
;
1786 unsigned max_stack_entries
;
1787 unsigned max_hw_contexts
;
1788 unsigned max_gs_threads
;
1789 unsigned sx_max_export_size
;
1790 unsigned sx_max_export_pos_size
;
1791 unsigned sx_max_export_smx_size
;
1792 unsigned sq_num_cf_insts
;
1793 unsigned sx_num_of_sets
;
1794 unsigned sc_prim_fifo_size
;
1795 unsigned sc_hiz_tile_fifo_size
;
1796 unsigned sc_earlyz_tile_fifo_fize
;
1797 unsigned tiling_nbanks
;
1798 unsigned tiling_npipes
;
1799 unsigned tiling_group_size
;
1800 unsigned tile_config
;
1801 unsigned backend_map
;
1804 struct evergreen_asic
{
1807 unsigned max_tile_pipes
;
1809 unsigned max_backends
;
1811 unsigned max_threads
;
1812 unsigned max_stack_entries
;
1813 unsigned max_hw_contexts
;
1814 unsigned max_gs_threads
;
1815 unsigned sx_max_export_size
;
1816 unsigned sx_max_export_pos_size
;
1817 unsigned sx_max_export_smx_size
;
1818 unsigned sq_num_cf_insts
;
1819 unsigned sx_num_of_sets
;
1820 unsigned sc_prim_fifo_size
;
1821 unsigned sc_hiz_tile_fifo_size
;
1822 unsigned sc_earlyz_tile_fifo_size
;
1823 unsigned tiling_nbanks
;
1824 unsigned tiling_npipes
;
1825 unsigned tiling_group_size
;
1826 unsigned tile_config
;
1827 unsigned backend_map
;
1830 struct cayman_asic
{
1831 unsigned max_shader_engines
;
1832 unsigned max_pipes_per_simd
;
1833 unsigned max_tile_pipes
;
1834 unsigned max_simds_per_se
;
1835 unsigned max_backends_per_se
;
1836 unsigned max_texture_channel_caches
;
1838 unsigned max_threads
;
1839 unsigned max_gs_threads
;
1840 unsigned max_stack_entries
;
1841 unsigned sx_num_of_sets
;
1842 unsigned sx_max_export_size
;
1843 unsigned sx_max_export_pos_size
;
1844 unsigned sx_max_export_smx_size
;
1845 unsigned max_hw_contexts
;
1846 unsigned sq_num_cf_insts
;
1847 unsigned sc_prim_fifo_size
;
1848 unsigned sc_hiz_tile_fifo_size
;
1849 unsigned sc_earlyz_tile_fifo_size
;
1851 unsigned num_shader_engines
;
1852 unsigned num_shader_pipes_per_simd
;
1853 unsigned num_tile_pipes
;
1854 unsigned num_simds_per_se
;
1855 unsigned num_backends_per_se
;
1856 unsigned backend_disable_mask_per_asic
;
1857 unsigned backend_map
;
1858 unsigned num_texture_channel_caches
;
1859 unsigned mem_max_burst_length_bytes
;
1860 unsigned mem_row_size_in_kb
;
1861 unsigned shader_engine_tile_size
;
1863 unsigned multi_gpu_tile_size
;
1865 unsigned tile_config
;
1869 unsigned max_shader_engines
;
1870 unsigned max_tile_pipes
;
1871 unsigned max_cu_per_sh
;
1872 unsigned max_sh_per_se
;
1873 unsigned max_backends_per_se
;
1874 unsigned max_texture_channel_caches
;
1876 unsigned max_gs_threads
;
1877 unsigned max_hw_contexts
;
1878 unsigned sc_prim_fifo_size_frontend
;
1879 unsigned sc_prim_fifo_size_backend
;
1880 unsigned sc_hiz_tile_fifo_size
;
1881 unsigned sc_earlyz_tile_fifo_size
;
1883 unsigned num_tile_pipes
;
1884 unsigned num_backends_per_se
;
1885 unsigned backend_disable_mask_per_asic
;
1886 unsigned backend_map
;
1887 unsigned num_texture_channel_caches
;
1888 unsigned mem_max_burst_length_bytes
;
1889 unsigned mem_row_size_in_kb
;
1890 unsigned shader_engine_tile_size
;
1892 unsigned multi_gpu_tile_size
;
1894 unsigned tile_config
;
1895 uint32_t tile_mode_array
[32];
1899 unsigned max_shader_engines
;
1900 unsigned max_tile_pipes
;
1901 unsigned max_cu_per_sh
;
1902 unsigned max_sh_per_se
;
1903 unsigned max_backends_per_se
;
1904 unsigned max_texture_channel_caches
;
1906 unsigned max_gs_threads
;
1907 unsigned max_hw_contexts
;
1908 unsigned sc_prim_fifo_size_frontend
;
1909 unsigned sc_prim_fifo_size_backend
;
1910 unsigned sc_hiz_tile_fifo_size
;
1911 unsigned sc_earlyz_tile_fifo_size
;
1913 unsigned num_tile_pipes
;
1914 unsigned num_backends_per_se
;
1915 unsigned backend_disable_mask_per_asic
;
1916 unsigned backend_map
;
1917 unsigned num_texture_channel_caches
;
1918 unsigned mem_max_burst_length_bytes
;
1919 unsigned mem_row_size_in_kb
;
1920 unsigned shader_engine_tile_size
;
1922 unsigned multi_gpu_tile_size
;
1924 unsigned tile_config
;
1925 uint32_t tile_mode_array
[32];
1928 union radeon_asic_config
{
1929 struct r300_asic r300
;
1930 struct r100_asic r100
;
1931 struct r600_asic r600
;
1932 struct rv770_asic rv770
;
1933 struct evergreen_asic evergreen
;
1934 struct cayman_asic cayman
;
1936 struct cik_asic cik
;
1940 * asic initizalization from radeon_asic.c
1942 void radeon_agp_disable(struct radeon_device
*rdev
);
1943 int radeon_asic_init(struct radeon_device
*rdev
);
1949 int radeon_gem_info_ioctl(struct drm_device
*dev
, void *data
,
1950 struct drm_file
*filp
);
1951 int radeon_gem_create_ioctl(struct drm_device
*dev
, void *data
,
1952 struct drm_file
*filp
);
1953 int radeon_gem_pin_ioctl(struct drm_device
*dev
, void *data
,
1954 struct drm_file
*file_priv
);
1955 int radeon_gem_unpin_ioctl(struct drm_device
*dev
, void *data
,
1956 struct drm_file
*file_priv
);
1957 int radeon_gem_pwrite_ioctl(struct drm_device
*dev
, void *data
,
1958 struct drm_file
*file_priv
);
1959 int radeon_gem_pread_ioctl(struct drm_device
*dev
, void *data
,
1960 struct drm_file
*file_priv
);
1961 int radeon_gem_set_domain_ioctl(struct drm_device
*dev
, void *data
,
1962 struct drm_file
*filp
);
1963 int radeon_gem_mmap_ioctl(struct drm_device
*dev
, void *data
,
1964 struct drm_file
*filp
);
1965 int radeon_gem_busy_ioctl(struct drm_device
*dev
, void *data
,
1966 struct drm_file
*filp
);
1967 int radeon_gem_wait_idle_ioctl(struct drm_device
*dev
, void *data
,
1968 struct drm_file
*filp
);
1969 int radeon_gem_va_ioctl(struct drm_device
*dev
, void *data
,
1970 struct drm_file
*filp
);
1971 int radeon_cs_ioctl(struct drm_device
*dev
, void *data
, struct drm_file
*filp
);
1972 int radeon_gem_set_tiling_ioctl(struct drm_device
*dev
, void *data
,
1973 struct drm_file
*filp
);
1974 int radeon_gem_get_tiling_ioctl(struct drm_device
*dev
, void *data
,
1975 struct drm_file
*filp
);
1977 /* VRAM scratch page for HDP bug, default vram page */
1978 struct r600_vram_scratch
{
1979 struct radeon_bo
*robj
;
1980 volatile uint32_t *ptr
;
1987 struct radeon_atif_notification_cfg
{
1992 struct radeon_atif_notifications
{
1993 bool display_switch
;
1994 bool expansion_mode_change
;
1996 bool forced_power_state
;
1997 bool system_power_state
;
1998 bool display_conf_change
;
2000 bool brightness_change
;
2001 bool dgpu_display_event
;
2004 struct radeon_atif_functions
{
2006 bool sbios_requests
;
2007 bool select_active_disp
;
2009 bool get_tv_standard
;
2010 bool set_tv_standard
;
2011 bool get_panel_expansion_mode
;
2012 bool set_panel_expansion_mode
;
2013 bool temperature_change
;
2014 bool graphics_device_types
;
2017 struct radeon_atif
{
2018 struct radeon_atif_notifications notifications
;
2019 struct radeon_atif_functions functions
;
2020 struct radeon_atif_notification_cfg notification_cfg
;
2021 struct radeon_encoder
*encoder_for_bl
;
2024 struct radeon_atcs_functions
{
2028 bool pcie_bus_width
;
2031 struct radeon_atcs
{
2032 struct radeon_atcs_functions functions
;
2036 * Core structure, functions and helpers.
2038 typedef uint32_t (*radeon_rreg_t
)(struct radeon_device
*, uint32_t);
2039 typedef void (*radeon_wreg_t
)(struct radeon_device
*, uint32_t, uint32_t);
2041 struct radeon_device
{
2043 struct drm_device
*ddev
;
2044 struct pci_dev
*pdev
;
2045 struct rw_semaphore exclusive_lock
;
2047 union radeon_asic_config config
;
2048 enum radeon_family family
;
2049 unsigned long flags
;
2051 enum radeon_pll_errata pll_errata
;
2058 uint16_t bios_header_start
;
2059 struct radeon_bo
*stollen_vga_memory
;
2061 resource_size_t rmmio_base
;
2062 resource_size_t rmmio_size
;
2063 /* protects concurrent MM_INDEX/DATA based register access */
2064 spinlock_t mmio_idx_lock
;
2065 void __iomem
*rmmio
;
2066 radeon_rreg_t mc_rreg
;
2067 radeon_wreg_t mc_wreg
;
2068 radeon_rreg_t pll_rreg
;
2069 radeon_wreg_t pll_wreg
;
2070 uint32_t pcie_reg_mask
;
2071 radeon_rreg_t pciep_rreg
;
2072 radeon_wreg_t pciep_wreg
;
2074 void __iomem
*rio_mem
;
2075 resource_size_t rio_mem_size
;
2076 struct radeon_clock clock
;
2077 struct radeon_mc mc
;
2078 struct radeon_gart gart
;
2079 struct radeon_mode_info mode_info
;
2080 struct radeon_scratch scratch
;
2081 struct radeon_doorbell doorbell
;
2082 struct radeon_mman mman
;
2083 struct radeon_fence_driver fence_drv
[RADEON_NUM_RINGS
];
2084 wait_queue_head_t fence_queue
;
2085 struct mutex ring_lock
;
2086 struct radeon_ring ring
[RADEON_NUM_RINGS
];
2088 struct radeon_sa_manager ring_tmp_bo
;
2089 struct radeon_irq irq
;
2090 struct radeon_asic
*asic
;
2091 struct radeon_gem gem
;
2092 struct radeon_pm pm
;
2093 struct radeon_uvd uvd
;
2094 uint32_t bios_scratch
[RADEON_BIOS_NUM_SCRATCH
];
2095 struct radeon_wb wb
;
2096 struct radeon_dummy_page dummy_page
;
2101 bool fastfb_working
; /* IGP feature*/
2102 struct radeon_surface_reg surface_regs
[RADEON_GEM_MAX_SURFACES
];
2103 const struct firmware
*me_fw
; /* all family ME firmware */
2104 const struct firmware
*pfp_fw
; /* r6/700 PFP firmware */
2105 const struct firmware
*rlc_fw
; /* r6/700 RLC firmware */
2106 const struct firmware
*mc_fw
; /* NI MC firmware */
2107 const struct firmware
*ce_fw
; /* SI CE firmware */
2108 const struct firmware
*mec_fw
; /* CIK MEC firmware */
2109 const struct firmware
*sdma_fw
; /* CIK SDMA firmware */
2110 const struct firmware
*smc_fw
; /* SMC firmware */
2111 const struct firmware
*uvd_fw
; /* UVD firmware */
2112 struct r600_vram_scratch vram_scratch
;
2113 int msi_enabled
; /* msi enabled */
2114 struct r600_ih ih
; /* r6/700 interrupt ring */
2115 struct radeon_rlc rlc
;
2116 struct radeon_mec mec
;
2117 struct work_struct hotplug_work
;
2118 struct work_struct audio_work
;
2119 struct work_struct reset_work
;
2120 int num_crtc
; /* number of crtcs */
2121 struct mutex dc_hw_i2c_mutex
; /* display controller hw i2c mutex */
2124 struct r600_audio audio_status
; /* audio stuff */
2125 struct notifier_block acpi_nb
;
2126 /* only one userspace can use Hyperz features or CMASK at a time */
2127 struct drm_file
*hyperz_filp
;
2128 struct drm_file
*cmask_filp
;
2130 struct radeon_i2c_chan
*i2c_bus
[RADEON_MAX_I2C_BUS
];
2132 struct radeon_debugfs debugfs
[RADEON_DEBUGFS_MAX_COMPONENTS
];
2133 unsigned debugfs_count
;
2134 /* virtual memory */
2135 struct radeon_vm_manager vm_manager
;
2136 struct mutex gpu_clock_mutex
;
2137 /* ACPI interface */
2138 struct radeon_atif atif
;
2139 struct radeon_atcs atcs
;
2140 /* srbm instance registers */
2141 struct mutex srbm_mutex
;
2144 int radeon_device_init(struct radeon_device
*rdev
,
2145 struct drm_device
*ddev
,
2146 struct pci_dev
*pdev
,
2148 void radeon_device_fini(struct radeon_device
*rdev
);
2149 int radeon_gpu_wait_for_idle(struct radeon_device
*rdev
);
2151 uint32_t r100_mm_rreg(struct radeon_device
*rdev
, uint32_t reg
,
2152 bool always_indirect
);
2153 void r100_mm_wreg(struct radeon_device
*rdev
, uint32_t reg
, uint32_t v
,
2154 bool always_indirect
);
2155 u32
r100_io_rreg(struct radeon_device
*rdev
, u32 reg
);
2156 void r100_io_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
);
2158 u32
cik_mm_rdoorbell(struct radeon_device
*rdev
, u32 offset
);
2159 void cik_mm_wdoorbell(struct radeon_device
*rdev
, u32 offset
, u32 v
);
2164 #define to_radeon_fence(p) ((struct radeon_fence *)(p))
2167 * Registers read & write functions.
2169 #define RREG8(reg) readb((rdev->rmmio) + (reg))
2170 #define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
2171 #define RREG16(reg) readw((rdev->rmmio) + (reg))
2172 #define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
2173 #define RREG32(reg) r100_mm_rreg(rdev, (reg), false)
2174 #define RREG32_IDX(reg) r100_mm_rreg(rdev, (reg), true)
2175 #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg), false))
2176 #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
2177 #define WREG32_IDX(reg, v) r100_mm_wreg(rdev, (reg), (v), true)
2178 #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
2179 #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
2180 #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
2181 #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
2182 #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
2183 #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
2184 #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
2185 #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
2186 #define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg))
2187 #define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
2188 #define RREG32_SMC(reg) tn_smc_rreg(rdev, (reg))
2189 #define WREG32_SMC(reg, v) tn_smc_wreg(rdev, (reg), (v))
2190 #define RREG32_RCU(reg) r600_rcu_rreg(rdev, (reg))
2191 #define WREG32_RCU(reg, v) r600_rcu_wreg(rdev, (reg), (v))
2192 #define RREG32_CG(reg) eg_cg_rreg(rdev, (reg))
2193 #define WREG32_CG(reg, v) eg_cg_wreg(rdev, (reg), (v))
2194 #define RREG32_PIF_PHY0(reg) eg_pif_phy0_rreg(rdev, (reg))
2195 #define WREG32_PIF_PHY0(reg, v) eg_pif_phy0_wreg(rdev, (reg), (v))
2196 #define RREG32_PIF_PHY1(reg) eg_pif_phy1_rreg(rdev, (reg))
2197 #define WREG32_PIF_PHY1(reg, v) eg_pif_phy1_wreg(rdev, (reg), (v))
2198 #define RREG32_UVD_CTX(reg) r600_uvd_ctx_rreg(rdev, (reg))
2199 #define WREG32_UVD_CTX(reg, v) r600_uvd_ctx_wreg(rdev, (reg), (v))
2200 #define RREG32_DIDT(reg) cik_didt_rreg(rdev, (reg))
2201 #define WREG32_DIDT(reg, v) cik_didt_wreg(rdev, (reg), (v))
2202 #define WREG32_P(reg, val, mask) \
2204 uint32_t tmp_ = RREG32(reg); \
2206 tmp_ |= ((val) & ~(mask)); \
2207 WREG32(reg, tmp_); \
2209 #define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
2210 #define WREG32_OR(reg, or) WREG32_P(reg, or, ~(or))
2211 #define WREG32_PLL_P(reg, val, mask) \
2213 uint32_t tmp_ = RREG32_PLL(reg); \
2215 tmp_ |= ((val) & ~(mask)); \
2216 WREG32_PLL(reg, tmp_); \
2218 #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg), false))
2219 #define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
2220 #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
2222 #define RDOORBELL32(offset) cik_mm_rdoorbell(rdev, (offset))
2223 #define WDOORBELL32(offset, v) cik_mm_wdoorbell(rdev, (offset), (v))
2226 * Indirect registers accessor
2228 static inline uint32_t rv370_pcie_rreg(struct radeon_device
*rdev
, uint32_t reg
)
2232 WREG32(RADEON_PCIE_INDEX
, ((reg
) & rdev
->pcie_reg_mask
));
2233 r
= RREG32(RADEON_PCIE_DATA
);
2237 static inline void rv370_pcie_wreg(struct radeon_device
*rdev
, uint32_t reg
, uint32_t v
)
2239 WREG32(RADEON_PCIE_INDEX
, ((reg
) & rdev
->pcie_reg_mask
));
2240 WREG32(RADEON_PCIE_DATA
, (v
));
2243 static inline u32
tn_smc_rreg(struct radeon_device
*rdev
, u32 reg
)
2247 WREG32(TN_SMC_IND_INDEX_0
, (reg
));
2248 r
= RREG32(TN_SMC_IND_DATA_0
);
2252 static inline void tn_smc_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2254 WREG32(TN_SMC_IND_INDEX_0
, (reg
));
2255 WREG32(TN_SMC_IND_DATA_0
, (v
));
2258 static inline u32
r600_rcu_rreg(struct radeon_device
*rdev
, u32 reg
)
2262 WREG32(R600_RCU_INDEX
, ((reg
) & 0x1fff));
2263 r
= RREG32(R600_RCU_DATA
);
2267 static inline void r600_rcu_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2269 WREG32(R600_RCU_INDEX
, ((reg
) & 0x1fff));
2270 WREG32(R600_RCU_DATA
, (v
));
2273 static inline u32
eg_cg_rreg(struct radeon_device
*rdev
, u32 reg
)
2277 WREG32(EVERGREEN_CG_IND_ADDR
, ((reg
) & 0xffff));
2278 r
= RREG32(EVERGREEN_CG_IND_DATA
);
2282 static inline void eg_cg_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2284 WREG32(EVERGREEN_CG_IND_ADDR
, ((reg
) & 0xffff));
2285 WREG32(EVERGREEN_CG_IND_DATA
, (v
));
2288 static inline u32
eg_pif_phy0_rreg(struct radeon_device
*rdev
, u32 reg
)
2292 WREG32(EVERGREEN_PIF_PHY0_INDEX
, ((reg
) & 0xffff));
2293 r
= RREG32(EVERGREEN_PIF_PHY0_DATA
);
2297 static inline void eg_pif_phy0_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2299 WREG32(EVERGREEN_PIF_PHY0_INDEX
, ((reg
) & 0xffff));
2300 WREG32(EVERGREEN_PIF_PHY0_DATA
, (v
));
2303 static inline u32
eg_pif_phy1_rreg(struct radeon_device
*rdev
, u32 reg
)
2307 WREG32(EVERGREEN_PIF_PHY1_INDEX
, ((reg
) & 0xffff));
2308 r
= RREG32(EVERGREEN_PIF_PHY1_DATA
);
2312 static inline void eg_pif_phy1_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2314 WREG32(EVERGREEN_PIF_PHY1_INDEX
, ((reg
) & 0xffff));
2315 WREG32(EVERGREEN_PIF_PHY1_DATA
, (v
));
2318 static inline u32
r600_uvd_ctx_rreg(struct radeon_device
*rdev
, u32 reg
)
2322 WREG32(R600_UVD_CTX_INDEX
, ((reg
) & 0x1ff));
2323 r
= RREG32(R600_UVD_CTX_DATA
);
2327 static inline void r600_uvd_ctx_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2329 WREG32(R600_UVD_CTX_INDEX
, ((reg
) & 0x1ff));
2330 WREG32(R600_UVD_CTX_DATA
, (v
));
2334 static inline u32
cik_didt_rreg(struct radeon_device
*rdev
, u32 reg
)
2338 WREG32(CIK_DIDT_IND_INDEX
, (reg
));
2339 r
= RREG32(CIK_DIDT_IND_DATA
);
2343 static inline void cik_didt_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
2345 WREG32(CIK_DIDT_IND_INDEX
, (reg
));
2346 WREG32(CIK_DIDT_IND_DATA
, (v
));
2349 void r100_pll_errata_after_index(struct radeon_device
*rdev
);
2355 #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
2356 (rdev->pdev->device == 0x5969))
2357 #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
2358 (rdev->family == CHIP_RV200) || \
2359 (rdev->family == CHIP_RS100) || \
2360 (rdev->family == CHIP_RS200) || \
2361 (rdev->family == CHIP_RV250) || \
2362 (rdev->family == CHIP_RV280) || \
2363 (rdev->family == CHIP_RS300))
2364 #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
2365 (rdev->family == CHIP_RV350) || \
2366 (rdev->family == CHIP_R350) || \
2367 (rdev->family == CHIP_RV380) || \
2368 (rdev->family == CHIP_R420) || \
2369 (rdev->family == CHIP_R423) || \
2370 (rdev->family == CHIP_RV410) || \
2371 (rdev->family == CHIP_RS400) || \
2372 (rdev->family == CHIP_RS480))
2373 #define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
2374 (rdev->ddev->pdev->device == 0x9443) || \
2375 (rdev->ddev->pdev->device == 0x944B) || \
2376 (rdev->ddev->pdev->device == 0x9506) || \
2377 (rdev->ddev->pdev->device == 0x9509) || \
2378 (rdev->ddev->pdev->device == 0x950F) || \
2379 (rdev->ddev->pdev->device == 0x689C) || \
2380 (rdev->ddev->pdev->device == 0x689D))
2381 #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
2382 #define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
2383 (rdev->family == CHIP_RS690) || \
2384 (rdev->family == CHIP_RS740) || \
2385 (rdev->family >= CHIP_R600))
2386 #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
2387 #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
2388 #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
2389 #define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
2390 (rdev->flags & RADEON_IS_IGP))
2391 #define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
2392 #define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
2393 #define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
2394 (rdev->flags & RADEON_IS_IGP))
2395 #define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND))
2396 #define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN))
2397 #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE))
2399 #define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \
2400 (rdev->ddev->pdev->device == 0x6850) || \
2401 (rdev->ddev->pdev->device == 0x6858) || \
2402 (rdev->ddev->pdev->device == 0x6859) || \
2403 (rdev->ddev->pdev->device == 0x6840) || \
2404 (rdev->ddev->pdev->device == 0x6841) || \
2405 (rdev->ddev->pdev->device == 0x6842) || \
2406 (rdev->ddev->pdev->device == 0x6843))
2411 #define RBIOS8(i) (rdev->bios[i])
2412 #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
2413 #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
2415 int radeon_combios_init(struct radeon_device
*rdev
);
2416 void radeon_combios_fini(struct radeon_device
*rdev
);
2417 int radeon_atombios_init(struct radeon_device
*rdev
);
2418 void radeon_atombios_fini(struct radeon_device
*rdev
);
2424 #if DRM_DEBUG_CODE == 0
2425 static inline void radeon_ring_write(struct radeon_ring
*ring
, uint32_t v
)
2427 ring
->ring
[ring
->wptr
++] = v
;
2428 ring
->wptr
&= ring
->ptr_mask
;
2430 ring
->ring_free_dw
--;
2433 /* With debugging this is just too big to inline */
2434 void radeon_ring_write(struct radeon_ring
*ring
, uint32_t v
);
2440 #define radeon_init(rdev) (rdev)->asic->init((rdev))
2441 #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
2442 #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
2443 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
2444 #define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
2445 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
2446 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
2447 #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
2448 #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
2449 #define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
2450 #define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
2451 #define radeon_asic_vm_set_page(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
2452 #define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)].ring_start((rdev), (cp))
2453 #define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)].ring_test((rdev), (cp))
2454 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
2455 #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
2456 #define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
2457 #define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
2458 #define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm))
2459 #define radeon_ring_get_rptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_rptr((rdev), (r))
2460 #define radeon_ring_get_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_wptr((rdev), (r))
2461 #define radeon_ring_set_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].set_wptr((rdev), (r))
2462 #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
2463 #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
2464 #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
2465 #define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
2466 #define radeon_get_backlight_level(rdev, e) (rdev)->asic->display.get_backlight_level((e))
2467 #define radeon_hdmi_enable(rdev, e, b) (rdev)->asic->display.hdmi_enable((e), (b))
2468 #define radeon_hdmi_setmode(rdev, e, m) (rdev)->asic->display.hdmi_setmode((e), (m))
2469 #define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
2470 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
2471 #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f))
2472 #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (f))
2473 #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (f))
2474 #define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
2475 #define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
2476 #define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
2477 #define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
2478 #define radeon_set_engine_clock(rdev, e) (rdev)->asic->pm.set_engine_clock((rdev), (e))
2479 #define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
2480 #define radeon_set_memory_clock(rdev, e) (rdev)->asic->pm.set_memory_clock((rdev), (e))
2481 #define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
2482 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
2483 #define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
2484 #define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
2485 #define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
2486 #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
2487 #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
2488 #define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
2489 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
2490 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
2491 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
2492 #define radeon_hpd_set_polarity(rdev, h) (rdev)->asic->hpd.set_polarity((rdev), (h))
2493 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
2494 #define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
2495 #define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
2496 #define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
2497 #define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
2498 #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
2499 #define radeon_pre_page_flip(rdev, crtc) (rdev)->asic->pflip.pre_page_flip((rdev), (crtc))
2500 #define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
2501 #define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc))
2502 #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
2503 #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
2504 #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
2505 #define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
2506 #define radeon_dpm_init(rdev) rdev->asic->dpm.init((rdev))
2507 #define radeon_dpm_setup_asic(rdev) rdev->asic->dpm.setup_asic((rdev))
2508 #define radeon_dpm_enable(rdev) rdev->asic->dpm.enable((rdev))
2509 #define radeon_dpm_disable(rdev) rdev->asic->dpm.disable((rdev))
2510 #define radeon_dpm_pre_set_power_state(rdev) rdev->asic->dpm.pre_set_power_state((rdev))
2511 #define radeon_dpm_set_power_state(rdev) rdev->asic->dpm.set_power_state((rdev))
2512 #define radeon_dpm_post_set_power_state(rdev) rdev->asic->dpm.post_set_power_state((rdev))
2513 #define radeon_dpm_display_configuration_changed(rdev) rdev->asic->dpm.display_configuration_changed((rdev))
2514 #define radeon_dpm_fini(rdev) rdev->asic->dpm.fini((rdev))
2515 #define radeon_dpm_get_sclk(rdev, l) rdev->asic->dpm.get_sclk((rdev), (l))
2516 #define radeon_dpm_get_mclk(rdev, l) rdev->asic->dpm.get_mclk((rdev), (l))
2517 #define radeon_dpm_print_power_state(rdev, ps) rdev->asic->dpm.print_power_state((rdev), (ps))
2518 #define radeon_dpm_debugfs_print_current_performance_level(rdev, m) rdev->asic->dpm.debugfs_print_current_performance_level((rdev), (m))
2519 #define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l))
2520 #define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev))
2522 /* Common functions */
2524 extern int radeon_gpu_reset(struct radeon_device
*rdev
);
2525 extern void r600_set_bios_scratch_engine_hung(struct radeon_device
*rdev
, bool hung
);
2526 extern void radeon_agp_disable(struct radeon_device
*rdev
);
2527 extern int radeon_modeset_init(struct radeon_device
*rdev
);
2528 extern void radeon_modeset_fini(struct radeon_device
*rdev
);
2529 extern bool radeon_card_posted(struct radeon_device
*rdev
);
2530 extern void radeon_update_bandwidth_info(struct radeon_device
*rdev
);
2531 extern void radeon_update_display_priority(struct radeon_device
*rdev
);
2532 extern bool radeon_boot_test_post_card(struct radeon_device
*rdev
);
2533 extern void radeon_scratch_init(struct radeon_device
*rdev
);
2534 extern void radeon_wb_fini(struct radeon_device
*rdev
);
2535 extern int radeon_wb_init(struct radeon_device
*rdev
);
2536 extern void radeon_wb_disable(struct radeon_device
*rdev
);
2537 extern void radeon_surface_init(struct radeon_device
*rdev
);
2538 extern int radeon_cs_parser_init(struct radeon_cs_parser
*p
, void *data
);
2539 extern void radeon_legacy_set_clock_gating(struct radeon_device
*rdev
, int enable
);
2540 extern void radeon_atom_set_clock_gating(struct radeon_device
*rdev
, int enable
);
2541 extern void radeon_ttm_placement_from_domain(struct radeon_bo
*rbo
, u32 domain
);
2542 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object
*bo
);
2543 extern void radeon_vram_location(struct radeon_device
*rdev
, struct radeon_mc
*mc
, u64 base
);
2544 extern void radeon_gtt_location(struct radeon_device
*rdev
, struct radeon_mc
*mc
);
2545 extern int radeon_resume_kms(struct drm_device
*dev
);
2546 extern int radeon_suspend_kms(struct drm_device
*dev
, pm_message_t state
);
2547 extern void radeon_ttm_set_active_vram_size(struct radeon_device
*rdev
, u64 size
);
2548 extern void radeon_program_register_sequence(struct radeon_device
*rdev
,
2549 const u32
*registers
,
2550 const u32 array_size
);
2555 int radeon_vm_manager_init(struct radeon_device
*rdev
);
2556 void radeon_vm_manager_fini(struct radeon_device
*rdev
);
2557 void radeon_vm_init(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2558 void radeon_vm_fini(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2559 int radeon_vm_alloc_pt(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2560 void radeon_vm_add_to_lru(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2561 struct radeon_fence
*radeon_vm_grab_id(struct radeon_device
*rdev
,
2562 struct radeon_vm
*vm
, int ring
);
2563 void radeon_vm_fence(struct radeon_device
*rdev
,
2564 struct radeon_vm
*vm
,
2565 struct radeon_fence
*fence
);
2566 uint64_t radeon_vm_map_gart(struct radeon_device
*rdev
, uint64_t addr
);
2567 int radeon_vm_bo_update_pte(struct radeon_device
*rdev
,
2568 struct radeon_vm
*vm
,
2569 struct radeon_bo
*bo
,
2570 struct ttm_mem_reg
*mem
);
2571 void radeon_vm_bo_invalidate(struct radeon_device
*rdev
,
2572 struct radeon_bo
*bo
);
2573 struct radeon_bo_va
*radeon_vm_bo_find(struct radeon_vm
*vm
,
2574 struct radeon_bo
*bo
);
2575 struct radeon_bo_va
*radeon_vm_bo_add(struct radeon_device
*rdev
,
2576 struct radeon_vm
*vm
,
2577 struct radeon_bo
*bo
);
2578 int radeon_vm_bo_set_addr(struct radeon_device
*rdev
,
2579 struct radeon_bo_va
*bo_va
,
2582 int radeon_vm_bo_rmv(struct radeon_device
*rdev
,
2583 struct radeon_bo_va
*bo_va
);
2586 void r600_audio_update_hdmi(struct work_struct
*work
);
2589 * R600 vram scratch functions
2591 int r600_vram_scratch_init(struct radeon_device
*rdev
);
2592 void r600_vram_scratch_fini(struct radeon_device
*rdev
);
2595 * r600 cs checking helper
2597 unsigned r600_mip_minify(unsigned size
, unsigned level
);
2598 bool r600_fmt_is_valid_color(u32 format
);
2599 bool r600_fmt_is_valid_texture(u32 format
, enum radeon_family family
);
2600 int r600_fmt_get_blocksize(u32 format
);
2601 int r600_fmt_get_nblocksx(u32 format
, u32 w
);
2602 int r600_fmt_get_nblocksy(u32 format
, u32 h
);
2605 * r600 functions used by radeon_encoder.c
2607 struct radeon_hdmi_acr
{
2621 extern struct radeon_hdmi_acr
r600_hdmi_acr(uint32_t clock
);
2623 extern u32
r6xx_remap_render_backend(struct radeon_device
*rdev
,
2624 u32 tiling_pipe_num
,
2626 u32 total_max_rb_num
,
2627 u32 enabled_rb_mask
);
2630 * evergreen functions used by radeon_encoder.c
2633 extern int ni_init_microcode(struct radeon_device
*rdev
);
2634 extern int ni_mc_load_microcode(struct radeon_device
*rdev
);
2637 #if defined(CONFIG_ACPI)
2638 extern int radeon_acpi_init(struct radeon_device
*rdev
);
2639 extern void radeon_acpi_fini(struct radeon_device
*rdev
);
2640 extern bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device
*rdev
);
2641 extern int radeon_acpi_pcie_performance_request(struct radeon_device
*rdev
,
2642 u8 perf_req
, bool advertise
);
2643 extern int radeon_acpi_pcie_notify_device_ready(struct radeon_device
*rdev
);
2645 static inline int radeon_acpi_init(struct radeon_device
*rdev
) { return 0; }
2646 static inline void radeon_acpi_fini(struct radeon_device
*rdev
) { }
2649 int radeon_cs_packet_parse(struct radeon_cs_parser
*p
,
2650 struct radeon_cs_packet
*pkt
,
2652 bool radeon_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser
*p
);
2653 void radeon_cs_dump_packet(struct radeon_cs_parser
*p
,
2654 struct radeon_cs_packet
*pkt
);
2655 int radeon_cs_packet_next_reloc(struct radeon_cs_parser
*p
,
2656 struct radeon_cs_reloc
**cs_reloc
,
2658 int r600_cs_common_vline_parse(struct radeon_cs_parser
*p
,
2659 uint32_t *vline_start_end
,
2660 uint32_t *vline_status
);
2662 #include "radeon_object.h"