Skip to contentSkip to conversation

drm/etnaviv: Always init gpu->memory_base

PATCH In review Marek Vasut 3 participants 5 messages Aug 26, 2016 – Sep 4, 2016

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

PATCH 1/1 drm/etnaviv: Always init gpu->memory_base

The content of gpu->memory_base should point to start of RAM, not zero.

Cc Lucas Stach <[email protected]>
Cc Christian Gmeiner <[email protected]>
Cc Russell King <[email protected]>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +2 -0
index ff6aa5d..a168532 100644
@@ -588,6 +588,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 			gpu->memory_base = PHYS_OFFSET;
 		else
 			gpu->memory_base = dma_mask - SZ_2G + 1;
+	} else {
+		gpu->memory_base = PHYS_OFFSET;
 	}
 
 	ret = etnaviv_hw_reset(gpu);
Signature · 6 lines
2.9.3

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

Am Freitag, den 26.08.2016, 16:25 +0200 schrieb Marek Vasut:

Quoted 6 lines

The content of gpu->memory_base should point to start of RAM, not zero.

Cc Lucas Stach <[email protected]>
Cc Christian Gmeiner <[email protected]>
Cc Russell King <[email protected]>

NACK. This will cause memory corruption when used with a MC10 GPU. The checks are there for a reason. ;)

I'll have to think about a proper solution for MX6SX.

Quoted 9 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +0 -0
index ff6aa5d..a168532 100644

drivers/gpu/drm/etnaviv/etnaviv_gpu.c int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · line 595

Quoted 8 lines
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +2 -0
@@ -588,6 +588,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 			gpu->memory_base = PHYS_OFFSET;
 		else
 			gpu->memory_base = dma_mask - SZ_2G + 1;
+	} else {
+		gpu->memory_base = PHYS_OFFSET;
 	}
 
 	ret = etnaviv_hw_reset(gpu);

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

#2 lore raw
Quoted 8 lines · Lucas Stach

Am Freitag, den 26.08.2016, 16:25 +0200 schrieb Marek Vasut:

Quoted 6 lines

The content of gpu->memory_base should point to start of RAM, not zero.

Cc Lucas Stach <[email protected]>
Cc Christian Gmeiner <[email protected]>
Cc Russell King <[email protected]>
Quoted 4 lines

NACK. This will cause memory corruption when used with a MC10 GPU. The checks are there for a reason. ;)

I'll have to think about a proper solution for MX6SX.

Oh ok, thanks.

Quoted 19 lines
Quoted 17 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +2 -0
index ff6aa5d..a168532 100644
@@ -588,6 +588,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 			gpu->memory_base = PHYS_OFFSET;
 		else
 			gpu->memory_base = dma_mask - SZ_2G + 1;
+	} else {
+		gpu->memory_base = PHYS_OFFSET;
 	}
 
 	ret = etnaviv_hw_reset(gpu);
Signature · 6 lines
Best regards,
Marek Vasut
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Marek Vasut
Quoted 15 lines · Marek Vasut

The content of gpu->memory_base should point to start of RAM, not zero.

Cc Lucas Stach <[email protected]>
Cc Christian Gmeiner <[email protected]>
Cc Russell King <[email protected]>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +0 -0
index ff6aa5d..a168532 100644

drivers/gpu/drm/etnaviv/etnaviv_gpu.c int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · line 593

Quoted 6 lines
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +2 -0
@@ -588,6 +588,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 			gpu->memory_base = PHYS_OFFSET;
 		else
 			gpu->memory_base = dma_mask - SZ_2G + 1;
+	} else {
+		gpu->memory_base = PHYS_OFFSET;
 	}

The code is correct as-is. Etnaviv GPUs are not without their own weirdness.

For MC1.0 3D GPUs (eg, GC600 as found on Dove), there is an issue where _most_ GPU accesses go through a memory offsetting via the memory base, but accesses by the tiler do not: they bypass the memory base offsetting.

We have two options to work around that:

1. Maintain two GPU address spaces, and mark relocations according to their use. This is error prone: we would have to have the kernel verify the relocation type is valid for the load state address to avoid obvious security issues, and the maintanence of these different address spaces becomes more complex.

2. Force the address offset to zero so all GPU accesses map through the same method irrespective of which GPU block is performing the access.

We've chosen (2) because it is much simpler, and less error prone, plus it fits with the platforms that we're aware of at the moment. I did push for the relocations to have an additional member which can be used to flag the type of the relocation if necessary in the future without changing the interface structure layouts, so we do have that option if we really need to do it - but we'd all prefer to avoid it.

Also, iirc, the GPU tiler with MC1.0 is unable to access addresses

Quoted 1 line

= 2GiB no matter what - if you do have a 3D GPU with MC1.0, and

you have physical memory above 2GiB... there's no currently known solution... you lose.

Signature · 7 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Marek Vasut

The content of gpu->memory_base should point to start of RAM, not zero.

Cc Lucas Stach <[email protected]>
Cc Christian Gmeiner <[email protected]>
Cc Russell King <[email protected]>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 14 lines

drivers/gpu/drm/etnaviv/etnaviv_gpu.c int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · line 593

Quoted 11 lines
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +2 -0
index ff6aa5d..a168532 100644
@@ -588,6 +588,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 			gpu->memory_base = PHYS_OFFSET;
 		else
 			gpu->memory_base = dma_mask - SZ_2G + 1;
+	} else {
+		gpu->memory_base = PHYS_OFFSET;
 	}

The code is correct as-is. Etnaviv GPUs are not without their own weirdness.

I suspected as much. I think my GPU isn't MC2.0 if I read the minor_features0 bits right .

Quoted 17 lines

For MC1.0 3D GPUs (eg, GC600 as found on Dove), there is an issue where _most_ GPU accesses go through a memory offsetting via the memory base, but accesses by the tiler do not: they bypass the memory base offsetting.

We have two options to work around that:

1. Maintain two GPU address spaces, and mark relocations according to their use. This is error prone: we would have to have the kernel verify the relocation type is valid for the load state address to avoid obvious security issues, and the maintanence of these different address spaces becomes more complex.

2. Force the address offset to zero so all GPU accesses map through the same method irrespective of which GPU block is performing the access.

Quoted 7 lines

We've chosen (2) because it is much simpler, and less error prone, plus it fits with the platforms that we're aware of at the moment. I did push for the relocations to have an additional member which can be used to flag the type of the relocation if necessary in the future without changing the interface structure layouts, so we do have that option if we really need to do it - but we'd all prefer to avoid it.

I see, thanks for the detailed explanation.

Quoted 4 lines

Also, iirc, the GPU tiler with MC1.0 is unable to access addresses

Quoted 1 line

= 2GiB no matter what - if you do have a 3D GPU with MC1.0, and

you have physical memory above 2GiB... there's no currently known solution... you lose.

Yes, i.MX6SX has GC400T and the DRAM starts at 0x8000_0000 . Did I misunderstand something ?

Signature · 6 lines
Best regards,
Marek Vasut
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel