diff options
| author | Alex Deucher <alexander.deucher@amd.com> | 2012-03-20 17:18:20 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2012-03-21 02:55:54 -0400 |
| commit | 2ece2e8b7d02040a59bc2f3a7f192c0521e2b867 (patch) | |
| tree | f45b8e97947aa79037c6ce1b2a98ee0a60b7988e | |
| parent | 48c0c902e2e6ca07b8c7ae1da48a7bb59eb88de9 (diff) | |
drm/radeon/kms: add IB and fence dispatch functions for SI
Support both IBs (DE) and CONST IBs (CE).
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
| -rw-r--r-- | drivers/gpu/drm/radeon/si.c | 78 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/sid.h | 65 |
2 files changed, 143 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index a471a8090249..408119a810ce 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c | |||
| @@ -1863,6 +1863,84 @@ static void si_gpu_init(struct radeon_device *rdev) | |||
| 1863 | } | 1863 | } |
| 1864 | 1864 | ||
| 1865 | /* | 1865 | /* |
| 1866 | * GPU scratch registers helpers function. | ||
| 1867 | */ | ||
| 1868 | static void si_scratch_init(struct radeon_device *rdev) | ||
| 1869 | { | ||
| 1870 | int i; | ||
| 1871 | |||
| 1872 | rdev->scratch.num_reg = 7; | ||
| 1873 | rdev->scratch.reg_base = SCRATCH_REG0; | ||
| 1874 | for (i = 0; i < rdev->scratch.num_reg; i++) { | ||
| 1875 | rdev->scratch.free[i] = true; | ||
| 1876 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); | ||
| 1877 | } | ||
| 1878 | } | ||
| 1879 | |||
| 1880 | void si_fence_ring_emit(struct radeon_device *rdev, | ||
| 1881 | struct radeon_fence *fence) | ||
| 1882 | { | ||
| 1883 | struct radeon_ring *ring = &rdev->ring[fence->ring]; | ||
| 1884 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; | ||
| 1885 | |||
| 1886 | /* flush read cache over gart */ | ||
| 1887 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | ||
| 1888 | radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2); | ||
| 1889 | radeon_ring_write(ring, 0); | ||
| 1890 | radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); | ||
| 1891 | radeon_ring_write(ring, PACKET3_TCL1_ACTION_ENA | | ||
| 1892 | PACKET3_TC_ACTION_ENA | | ||
| 1893 | PACKET3_SH_KCACHE_ACTION_ENA | | ||
| 1894 | PACKET3_SH_ICACHE_ACTION_ENA); | ||
| 1895 | radeon_ring_write(ring, 0xFFFFFFFF); | ||
| 1896 | radeon_ring_write(ring, 0); | ||
| 1897 | radeon_ring_write(ring, 10); /* poll interval */ | ||
| 1898 | /* EVENT_WRITE_EOP - flush caches, send int */ | ||
| 1899 | radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); | ||
| 1900 | radeon_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5)); | ||
| 1901 | radeon_ring_write(ring, addr & 0xffffffff); | ||
| 1902 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | DATA_SEL(1) | INT_SEL(2)); | ||
| 1903 | radeon_ring_write(ring, fence->seq); | ||
| 1904 | radeon_ring_write(ring, 0); | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | /* | ||
| 1908 | * IB stuff | ||
| 1909 | */ | ||
| 1910 | void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) | ||
| 1911 | { | ||
| 1912 | struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; | ||
| 1913 | u32 header; | ||
| 1914 | |||
| 1915 | if (ib->is_const_ib) | ||
| 1916 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); | ||
| 1917 | else | ||
| 1918 | header = PACKET3(PACKET3_INDIRECT_BUFFER, 2); | ||
| 1919 | |||
| 1920 | radeon_ring_write(ring, header); | ||
| 1921 | radeon_ring_write(ring, | ||
| 1922 | #ifdef __BIG_ENDIAN | ||
| 1923 | (2 << 0) | | ||
| 1924 | #endif | ||
| 1925 | (ib->gpu_addr & 0xFFFFFFFC)); | ||
| 1926 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF); | ||
| 1927 | radeon_ring_write(ring, ib->length_dw | (ib->vm_id << 24)); | ||
| 1928 | |||
| 1929 | /* flush read cache over gart for this vmid */ | ||
| 1930 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); | ||
| 1931 | radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2); | ||
| 1932 | radeon_ring_write(ring, ib->vm_id); | ||
| 1933 | radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); | ||
| 1934 | radeon_ring_write(ring, PACKET3_TCL1_ACTION_ENA | | ||
| 1935 | PACKET3_TC_ACTION_ENA | | ||
| 1936 | PACKET3_SH_KCACHE_ACTION_ENA | | ||
| 1937 | PACKET3_SH_ICACHE_ACTION_ENA); | ||
| 1938 | radeon_ring_write(ring, 0xFFFFFFFF); | ||
| 1939 | radeon_ring_write(ring, 0); | ||
| 1940 | radeon_ring_write(ring, 10); /* poll interval */ | ||
| 1941 | } | ||
| 1942 | |||
| 1943 | /* | ||
| 1866 | * CP. | 1944 | * CP. |
| 1867 | */ | 1945 | */ |
| 1868 | static void si_cp_enable(struct radeon_device *rdev, bool enable) | 1946 | static void si_cp_enable(struct radeon_device *rdev, bool enable) |
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h index 7e08f0896ef6..904c4fd031f9 100644 --- a/drivers/gpu/drm/radeon/sid.h +++ b/drivers/gpu/drm/radeon/sid.h | |||
| @@ -294,6 +294,8 @@ | |||
| 294 | #define CP_PFP_HALT (1 << 26) | 294 | #define CP_PFP_HALT (1 << 26) |
| 295 | #define CP_ME_HALT (1 << 28) | 295 | #define CP_ME_HALT (1 << 28) |
| 296 | 296 | ||
| 297 | #define CP_COHER_CNTL2 0x85E8 | ||
| 298 | |||
| 297 | #define CP_RB2_RPTR 0x86f8 | 299 | #define CP_RB2_RPTR 0x86f8 |
| 298 | #define CP_RB1_RPTR 0x86fc | 300 | #define CP_RB1_RPTR 0x86fc |
| 299 | #define CP_RB0_RPTR 0x8700 | 301 | #define CP_RB0_RPTR 0x8700 |
| @@ -511,6 +513,45 @@ | |||
| 511 | 513 | ||
| 512 | #define CP_DEBUG 0xC1FC | 514 | #define CP_DEBUG 0xC1FC |
| 513 | 515 | ||
| 516 | #define VGT_EVENT_INITIATOR 0x28a90 | ||
| 517 | # define SAMPLE_STREAMOUTSTATS1 (1 << 0) | ||
| 518 | # define SAMPLE_STREAMOUTSTATS2 (2 << 0) | ||
| 519 | # define SAMPLE_STREAMOUTSTATS3 (3 << 0) | ||
| 520 | # define CACHE_FLUSH_TS (4 << 0) | ||
| 521 | # define CACHE_FLUSH (6 << 0) | ||
| 522 | # define CS_PARTIAL_FLUSH (7 << 0) | ||
| 523 | # define VGT_STREAMOUT_RESET (10 << 0) | ||
| 524 | # define END_OF_PIPE_INCR_DE (11 << 0) | ||
| 525 | # define END_OF_PIPE_IB_END (12 << 0) | ||
| 526 | # define RST_PIX_CNT (13 << 0) | ||
| 527 | # define VS_PARTIAL_FLUSH (15 << 0) | ||
| 528 | # define PS_PARTIAL_FLUSH (16 << 0) | ||
| 529 | # define CACHE_FLUSH_AND_INV_TS_EVENT (20 << 0) | ||
| 530 | # define ZPASS_DONE (21 << 0) | ||
| 531 | # define CACHE_FLUSH_AND_INV_EVENT (22 << 0) | ||
| 532 | # define PERFCOUNTER_START (23 << 0) | ||
| 533 | # define PERFCOUNTER_STOP (24 << 0) | ||
| 534 | # define PIPELINESTAT_START (25 << 0) | ||
| 535 | # define PIPELINESTAT_STOP (26 << 0) | ||
| 536 | # define PERFCOUNTER_SAMPLE (27 << 0) | ||
| 537 | # define SAMPLE_PIPELINESTAT (30 << 0) | ||
| 538 | # define SAMPLE_STREAMOUTSTATS (32 << 0) | ||
| 539 | # define RESET_VTX_CNT (33 << 0) | ||
| 540 | # define VGT_FLUSH (36 << 0) | ||
| 541 | # define BOTTOM_OF_PIPE_TS (40 << 0) | ||
| 542 | # define DB_CACHE_FLUSH_AND_INV (42 << 0) | ||
| 543 | # define FLUSH_AND_INV_DB_DATA_TS (43 << 0) | ||
| 544 | # define FLUSH_AND_INV_DB_META (44 << 0) | ||
| 545 | # define FLUSH_AND_INV_CB_DATA_TS (45 << 0) | ||
| 546 | # define FLUSH_AND_INV_CB_META (46 << 0) | ||
| 547 | # define CS_DONE (47 << 0) | ||
| 548 | # define PS_DONE (48 << 0) | ||
| 549 | # define FLUSH_AND_INV_CB_PIXEL_DATA (49 << 0) | ||
| 550 | # define THREAD_TRACE_START (51 << 0) | ||
| 551 | # define THREAD_TRACE_STOP (52 << 0) | ||
| 552 | # define THREAD_TRACE_FLUSH (54 << 0) | ||
| 553 | # define THREAD_TRACE_FINISH (55 << 0) | ||
| 554 | |||
| 514 | /* | 555 | /* |
| 515 | * PM4 | 556 | * PM4 |
| 516 | */ | 557 | */ |
| @@ -606,7 +647,31 @@ | |||
| 606 | #define PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16) | 647 | #define PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16) |
| 607 | #define PACKET3_COND_WRITE 0x45 | 648 | #define PACKET3_COND_WRITE 0x45 |
| 608 | #define PACKET3_EVENT_WRITE 0x46 | 649 | #define PACKET3_EVENT_WRITE 0x46 |
| 650 | #define EVENT_TYPE(x) ((x) << 0) | ||
| 651 | #define EVENT_INDEX(x) ((x) << 8) | ||
| 652 | /* 0 - any non-TS event | ||
| 653 | * 1 - ZPASS_DONE | ||
| 654 | * 2 - SAMPLE_PIPELINESTAT | ||
| 655 | * 3 - SAMPLE_STREAMOUTSTAT* | ||
| 656 | * 4 - *S_PARTIAL_FLUSH | ||
| 657 | * 5 - EOP events | ||
| 658 | * 6 - EOS events | ||
| 659 | * 7 - CACHE_FLUSH, CACHE_FLUSH_AND_INV_EVENT | ||
| 660 | */ | ||
| 661 | #define INV_L2 (1 << 20) | ||
| 662 | /* INV TC L2 cache when EVENT_INDEX = 7 */ | ||
| 609 | #define PACKET3_EVENT_WRITE_EOP 0x47 | 663 | #define PACKET3_EVENT_WRITE_EOP 0x47 |
| 664 | #define DATA_SEL(x) ((x) << 29) | ||
| 665 | /* 0 - discard | ||
| 666 | * 1 - send low 32bit data | ||
| 667 | * 2 - send 64bit data | ||
| 668 | * 3 - send 64bit counter value | ||
| 669 | */ | ||
| 670 | #define INT_SEL(x) ((x) << 24) | ||
| 671 | /* 0 - none | ||
| 672 | * 1 - interrupt only (DATA_SEL = 0) | ||
| 673 | * 2 - interrupt when data write is confirmed | ||
| 674 | */ | ||
| 610 | #define PACKET3_EVENT_WRITE_EOS 0x48 | 675 | #define PACKET3_EVENT_WRITE_EOS 0x48 |
| 611 | #define PACKET3_PREAMBLE_CNTL 0x4A | 676 | #define PACKET3_PREAMBLE_CNTL 0x4A |
| 612 | # define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE (2 << 28) | ||
