Skip to contentSkip to conversation

drm/radeon: add define for flags used in R600+ GTT

PATCH In review Christian König 2 participants 8 messages May 27, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/radeon: add define for flags used in R600+ GTT

From: Christian König <[email protected]>

---
 drivers/gpu/drm/radeon/radeon.h | 4 ++++
 drivers/gpu/drm/radeon/rs600.c  | 9 +--------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/radeon.h +4 -0
index 325f3a5..7d3e353 100644
@@ -853,6 +853,10 @@ struct radeon_mec {
 #define R600_PTE_FRAG_64KB	(4 << 7)
 #define R600_PTE_FRAG_256KB	(6 << 7)
 
+/* flags used for GART page table entries on R600+ */
+#define R600_PTE_GART	( R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED \
+			| R600_PTE_READABLE | R600_PTE_WRITEABLE)
+
 struct radeon_vm_pt {
 	struct radeon_bo		*bo;
 	uint64_t			addr;
drivers/gpu/drm/radeon/rs600.c +1 -8
index 72d3616..d09620d 100644
@@ -632,12 +632,6 @@ static void rs600_gart_fini(struct radeon_device *rdev)
 	radeon_gart_table_vram_free(rdev);
 }
 
-#define R600_PTE_VALID     (1 << 0)
-#define R600_PTE_SYSTEM    (1 << 1)
-#define R600_PTE_SNOOPED   (1 << 2)
-#define R600_PTE_READABLE  (1 << 5)
-#define R600_PTE_WRITEABLE (1 << 6)
-
 int rs600_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
 {
 	void __iomem *ptr = (void *)rdev->gart.ptr;
@@ -646,8 +640,7 @@ int rs600_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
 		return -EINVAL;
 	}
 	addr = addr & 0xFFFFFFFFFFFFF000ULL;
-	addr |= R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED;
-	addr |= R600_PTE_READABLE | R600_PTE_WRITEABLE;
+	addr |= R600_PTE_GART;
 	writeq(addr, ptr + (i * 8));
 	return 0;
 }
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/3 drm/radeon: optimize SI VM handling

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

---
 drivers/gpu/drm/radeon/si_dma.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/si_dma.c +19 -1
index cf0fdad..9521669 100644
@@ -79,7 +79,25 @@ void si_dma_vm_set_page(struct radeon_device *rdev,
 
 	trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-	if (flags & R600_PTE_SYSTEM) {
+	if (flags == R600_PTE_GART) {
+		uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+		while (count) {
+			unsigned bytes = count * 8;
+			if (bytes > 0xFFFF8)
+				bytes = 0xFFFF8;
+
+			ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_COPY,
+							      1, 0, 0, bytes);
+			ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+			ib->ptr[ib->length_dw++] = src & 0xffffffff;
+			ib->ptr[ib->length_dw++] = upper_32_bits(pe) & 0xff;
+			ib->ptr[ib->length_dw++] = upper_32_bits(src) & 0xff;
+
+			pe += bytes;
+			src += bytes;
+			count -= bytes / 8;
+		}
+	} else if (flags & R600_PTE_SYSTEM) {
 		while (count) {
 			ndw = count * 2;
 			if (ndw > 0xFFFFE)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] drm/radeon: optimize SI VM handling

Quoted 5 lines · Christian König

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

Quoted 38 lines
---
 drivers/gpu/drm/radeon/si_dma.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/si_dma.c +19 -2
index cf0fdad..9521669 100644
@@ -79,7 +79,25 @@ void si_dma_vm_set_page(struct radeon_device *rdev,
 
        trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-       if (flags & R600_PTE_SYSTEM) {
+       if (flags == R600_PTE_GART) {
+               uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+               while (count) {
+                       unsigned bytes = count * 8;
+                       if (bytes > 0xFFFF8)
+                               bytes = 0xFFFF8;
+
+                       ib->ptr[ib->length_dw++] = DMA_PACKET(DMA_PACKET_COPY,
+                                                             1, 0, 0, bytes);
+                       ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = src & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(pe) & 0xff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(src) & 0xff;
+
+                       pe += bytes;
+                       src += bytes;
+                       count -= bytes / 8;
+               }
+       } else if (flags & R600_PTE_SYSTEM) {
                while (count) {
                        ndw = count * 2;
                        if (ndw > 0xFFFFE)
--

1.9.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

PATCH 3/3 drm/radeon: optimize CIK VM handling

In reply to Christian König

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

---
 drivers/gpu/drm/radeon/cik_sdma.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/cik_sdma.c +20 -1
index f7e46cf..5bd3fe8 100644
@@ -741,7 +741,26 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev,
 
 	trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-	if (flags & R600_PTE_SYSTEM) {
+	if (flags == R600_PTE_GART) {
+		uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+		while (count) {
+			unsigned bytes = count * 8;
+			if (bytes > 0x1FFFF8)
+				bytes = 0x1FFFF8;
+
+			ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
+			ib->ptr[ib->length_dw++] = bytes;
+			ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
+			ib->ptr[ib->length_dw++] = src & 0xffffffff;
+			ib->ptr[ib->length_dw++] = upper_32_bits(src);
+			ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+			ib->ptr[ib->length_dw++] = upper_32_bits(pe);
+
+			pe += bytes;
+			src += bytes;
+			count -= bytes / 8;
+		}
+	} else if (flags & R600_PTE_SYSTEM) {
 		while (count) {
 			ndw = count * 2;
 			if (ndw > 0xFFFFE)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] drm/radeon: optimize CIK VM handling

Quoted 16 lines · Christian König

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

---
 drivers/gpu/drm/radeon/cik_sdma.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/cik_sdma.c +0 -0
index f7e46cf..5bd3fe8 100644
@@ -741,7 +741,26 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev,
 
        trace_radeon_vm_set_page(pe, addr, count, incr, flags);

drivers/gpu/drm/radeon/cik_sdma.c void cik_sdma_vm_set_page(struct radeon_device *rdev, · line 751

Quoted 10 lines
drivers/gpu/drm/radeon/cik_sdma.c +8 -1
 
-       if (flags & R600_PTE_SYSTEM) {
+       if (flags == R600_PTE_GART) {
+               uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+               while (count) {
+                       unsigned bytes = count * 8;
+                       if (bytes > 0x1FFFF8)
+                               bytes = 0x1FFFF8;
+
+                       ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0);

Copy paste typo? This should be SDMA_OPCODE_COPY, SDMA_COPY_SUB_OPCODE_LINEAR.

With that fixed, this patch is:

Quoted 18 lines
drivers/gpu/drm/radeon/cik_sdma.c +12 -1
+                       ib->ptr[ib->length_dw++] = bytes;
+                       ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
+                       ib->ptr[ib->length_dw++] = src & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(src);
+                       ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(pe);
+
+                       pe += bytes;
+                       src += bytes;
+                       count -= bytes / 8;
+               }
+       } else if (flags & R600_PTE_SYSTEM) {
                while (count) {
                        ndw = count * 2;
                        if (ndw > 0xFFFFE)
--

1.9.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH 3/3] drm/radeon: optimize CIK VM handling

Am 27.05.2014 17:44, schrieb Alex Deucher:

Quoted 19 lines
Quoted 17 lines · Christian König

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

---
  drivers/gpu/drm/radeon/cik_sdma.c | 21 ++++++++++++++++++++-
  1 file changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/cik_sdma.c +0 -0
index f7e46cf..5bd3fe8 100644
@@ -741,7 +741,26 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev,
 
         trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
Quoted 11 lines

drivers/gpu/drm/radeon/cik_sdma.c void cik_sdma_vm_set_page(struct radeon_device *rdev, · line 751

Quoted 9 lines
drivers/gpu/drm/radeon/cik_sdma.c +8 -1
-       if (flags & R600_PTE_SYSTEM) {
+       if (flags == R600_PTE_GART) {
+               uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+               while (count) {
+                       unsigned bytes = count * 8;
+                       if (bytes > 0x1FFFF8)
+                               bytes = 0x1FFFF8;
+
+                       ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0);

Copy paste typo? This should be SDMA_OPCODE_COPY, SDMA_COPY_SUB_OPCODE_LINEAR.

Oh, yes indeed. Thanks for the info.

Going to resend this patch in a minute. Can you add them to your 3.16-wip branch?

Thanks,
Christian.

Quoted 27 lines

With that fixed, this patch is:

Quoted 22 lines
drivers/gpu/drm/radeon/cik_sdma.c +12 -1
+                       ib->ptr[ib->length_dw++] = bytes;
+                       ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
+                       ib->ptr[ib->length_dw++] = src & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(src);
+                       ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(pe);
+
+                       pe += bytes;
+                       src += bytes;
+                       count -= bytes / 8;
+               }
+       } else if (flags & R600_PTE_SYSTEM) {
                 while (count) {
                         ndw = count * 2;
                         if (ndw > 0xFFFFE)
--

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 3/3] drm/radeon: optimize CIK VM handling

Quoted 40 lines · Christian König

Am 27.05.2014 17:44, schrieb Alex Deucher:

Quoted 22 lines
Quoted 20 lines · Christian König

From: Christian König <[email protected]>

Fill VM page tables from the GART page table if applicable.

---
  drivers/gpu/drm/radeon/cik_sdma.c | 21 ++++++++++++++++++++-
  1 file changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/cik_sdma.c +0 -0
index f7e46cf..5bd3fe8 100644
@@ -741,7 +741,26 @@ void cik_sdma_vm_set_page(struct radeon_device
 *rdev,
 
         trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
Quoted 14 lines

drivers/gpu/drm/radeon/cik_sdma.c void cik_sdma_vm_set_page(struct radeon_device *rdev,

Quoted 10 lines
drivers/gpu/drm/radeon/cik_sdma.c +8 -1
-       if (flags & R600_PTE_SYSTEM) {
+       if (flags == R600_PTE_GART) {
+               uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
+               while (count) {
+                       unsigned bytes = count * 8;
+                       if (bytes > 0x1FFFF8)
+                               bytes = 0x1FFFF8;
+
+                       ib->ptr[ib->length_dw++] =
 SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0);

Copy paste typo? This should be SDMA_OPCODE_COPY, SDMA_COPY_SUB_OPCODE_LINEAR.

Quoted 4 lines

Oh, yes indeed. Thanks for the info.

Going to resend this patch in a minute. Can you add them to your 3.16-wip branch?

Will do.

Alex

Quoted 35 lines

Thanks,
Christian.

Quoted 28 lines

With that fixed, this patch is:

Quoted 23 lines
drivers/gpu/drm/radeon/cik_sdma.c +2 -0
+                       ib->ptr[ib->length_dw++] = bytes;
+                       ib->ptr[ib->length_dw++] = 0; /* src/dst endian

swap */

drivers/gpu/drm/radeon/cik_sdma.c +10 -1
+                       ib->ptr[ib->length_dw++] = src & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(src);
+                       ib->ptr[ib->length_dw++] = pe & 0xffffffff;
+                       ib->ptr[ib->length_dw++] = upper_32_bits(pe);
+
+                       pe += bytes;
+                       src += bytes;
+                       count -= bytes / 8;
+               }
+       } else if (flags & R600_PTE_SYSTEM) {
                 while (count) {
                         ndw = count * 2;
                         if (ndw > 0xFFFFE)
--

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/3
#7 lore raw
In reply to Christian König
Quoted 3 lines · Christian König

From: Christian König <[email protected]>

Quoted 50 lines
---
 drivers/gpu/drm/radeon/radeon.h | 4 ++++
 drivers/gpu/drm/radeon/rs600.c  | 9 +--------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/radeon.h +4 -0
index 325f3a5..7d3e353 100644
@@ -853,6 +853,10 @@ struct radeon_mec {
 #define R600_PTE_FRAG_64KB     (4 << 7)
 #define R600_PTE_FRAG_256KB    (6 << 7)
 
+/* flags used for GART page table entries on R600+ */
+#define R600_PTE_GART  ( R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED \
+                       | R600_PTE_READABLE | R600_PTE_WRITEABLE)
+
 struct radeon_vm_pt {
        struct radeon_bo                *bo;
        uint64_t                        addr;
drivers/gpu/drm/radeon/rs600.c +1 -9
index 72d3616..d09620d 100644
@@ -632,12 +632,6 @@ static void rs600_gart_fini(struct radeon_device *rdev)
        radeon_gart_table_vram_free(rdev);
 }
 
-#define R600_PTE_VALID     (1 << 0)
-#define R600_PTE_SYSTEM    (1 << 1)
-#define R600_PTE_SNOOPED   (1 << 2)
-#define R600_PTE_READABLE  (1 << 5)
-#define R600_PTE_WRITEABLE (1 << 6)
-
 int rs600_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
 {
        void __iomem *ptr = (void *)rdev->gart.ptr;
@@ -646,8 +640,7 @@ int rs600_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
                return -EINVAL;
        }
        addr = addr & 0xFFFFFFFFFFFFF000ULL;
-       addr |= R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED;
-       addr |= R600_PTE_READABLE | R600_PTE_WRITEABLE;
+       addr |= R600_PTE_GART;
        writeq(addr, ptr + (i * 8));
        return 0;
 }
--

1.9.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel