Skip to contentSkip to conversation

drm/amdkfd: Remove vla

PATCH Superseded Laura Abbott 3 participants 3 messages Apr 11, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdkfd: Remove vla

There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a constant value that covers all hardware.

[1] https://lkml.org/lkml/2018/3/7/621

---
v2: Switch to a larger size to account for other hardware

---
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +5 -3
index 035c351f47c5..c3a5a80e31ae 100644
@@ -139,10 +139,12 @@ static void interrupt_wq(struct work_struct *work)
 {
 	struct kfd_dev *dev = container_of(work, struct kfd_dev,
 						interrupt_work);
+	uint32_t ih_ring_entry[8];
 
-	uint32_t ih_ring_entry[DIV_ROUND_UP(
-				dev->device_info->ih_ring_entry_size,
-				sizeof(uint32_t))];
+	if (dev->device_info->ih_ring_entry_size > (8 * sizeof(uint32_t))) {
+		dev_err(kfd_chardev(), "Ring entry too small\n");
+		return;
+	}
 
 	while (dequeue_ih_ring_entry(dev, ih_ring_entry))
 		dev->device_info->event_interrupt_class->interrupt_wq(dev,
Signature · 1 line
2.14.3
#1 lore raw

Am 11.04.2018 um 03:02 schrieb Laura Abbott:

Quoted 6 lines

There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a constant value that covers all hardware.

[1] https://lkml.org/lkml/2018/3/7/621

It would be nicer to have a define for that somewhere.

Anyway the patch is Acked-by: Christian König <[email protected]> for now.

Regards,
Christian.

Quoted 16 lines

---
v2: Switch to a larger size to account for other hardware

---
  drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +1 -0
index 035c351f47c5..c3a5a80e31ae 100644
@@ -139,10 +139,12 @@ static void interrupt_wq(struct work_struct *work)
  {
  	struct kfd_dev *dev = container_of(work, struct kfd_dev,
  						interrupt_work);
+	uint32_t ih_ring_entry[8];
 

drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c static void interrupt_wq(struct work_struct *work) · line 150

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +4 -3
-	uint32_t ih_ring_entry[DIV_ROUND_UP(
-				dev->device_info->ih_ring_entry_size,
-				sizeof(uint32_t))];
+	if (dev->device_info->ih_ring_entry_size > (8 * sizeof(uint32_t))) {
+		dev_err(kfd_chardev(), "Ring entry too small\n");
+		return;
+	}
 
  	while (dequeue_ih_ring_entry(dev, ih_ring_entry))
  		dev->device_info->event_interrupt_class->interrupt_wq(dev,

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

maintainer
#2 lore raw
In reply to Laura Abbott
Quoted 17 lines · Laura Abbott

There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a constant value that covers all hardware.

[1] https://lkml.org/lkml/2018/3/7/621

---
v2: Switch to a larger size to account for other hardware

---
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +0 -0
index 035c351f47c5..c3a5a80e31ae 100644

drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c static void interrupt_wq(struct work_struct *work) · line 145

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +3 -3
@@ -139,10 +139,12 @@ static void interrupt_wq(struct work_struct *work)
 {
 	struct kfd_dev *dev = container_of(work, struct kfd_dev,
 						interrupt_work);
+	uint32_t ih_ring_entry[8];
 
-	uint32_t ih_ring_entry[DIV_ROUND_UP(
-				dev->device_info->ih_ring_entry_size,
-				sizeof(uint32_t))];
+	if (dev->device_info->ih_ring_entry_size > (8 * sizeof(uint32_t))) {
+		dev_err(kfd_chardev(), "Ring entry too small\n");

When the ring entry size really is too small, this will potentially flood the kernel log. Maybe a WARN_ONCE would be more helpful. With that fixed, this patch is Reviewed-by: Felix Kuehling <[email protected]>

Regards,
  Felix

drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c static void interrupt_wq(struct work_struct *work) · line 150

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +2 -0
+		return;
+	}
 
 	while (dequeue_ih_ring_entry(dev, ih_ring_entry))
 		dev->device_info->event_interrupt_class->interrupt_wq(dev,

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