Skip to contentSkip to conversation

drivers/gpu/drm/ast: Fix infinite loop if read fails

PATCH In review Defang Bo 2 participants 3 messages Dec 25, 2020

Subsystems (3)
lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 1/2 drivers/gpu/drm/ast: Fix infinite loop if read fails

[Why] Similar to commit <298360af3> ast_init_dram_reg() configures a window in order to access BMC memory. A BMC register can be configured to disallow this, and if so, causes
an infinite loop in the ast driver which renders the system unusable.

[How]
Fix this by erroring out if an error is detected.

---
 drivers/gpu/drm/ast/ast_post.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_post.c +7 -3
index 8902c2f..ef19c70 100644
@@ -287,7 +287,9 @@ static void ast_init_dram_reg(struct drm_device *dev)
 			ast_write32(ast, 0x10100, 0xa8);
 
 			do {
-				;
+				if (pci_channel_offline(dev->pdev))
+					return -EIO;
+					
 			} while (ast_read32(ast, 0x10100) != 0xa8);
 		} else {/* AST2100/1100 */
 			if (ast->chip == AST2100 || ast->chip == 2200)
@@ -299,12 +301,14 @@ static void ast_init_dram_reg(struct drm_device *dev)
 			ast_write32(ast, 0xf000, 0x1);
 			ast_write32(ast, 0x12000, 0x1688A8A8);
 			do {
-				;
+				if (pci_channel_offline(dev->pdev))
+                                        return -EIO;
 			} while (ast_read32(ast, 0x12000) != 0x01);
 
 			ast_write32(ast, 0x10000, 0xfc600309);
 			do {
-				;
+				if (pci_channel_offline(dev->pdev))
+                                        return -EIO;
 			} while (ast_read32(ast, 0x10000) != 0x01);
 		}
 
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 drivers/gpu/drm/ast: Fix infinite loop if read fails

[Why] Similar to commit <298360af3> ast_init_dram_reg() configures a window in order to access BMC memory. A BMC register can be configured to disallow this, and if so, causes
an infinite loop in the ast driver which renders the system unusable.
[How]
Fix this by erroring out if an error is detected.

---
 drivers/gpu/drm/ast/ast_post.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_post.c +2 -2
index ef19c70..86e4d23 100644
@@ -302,13 +302,13 @@ static void ast_init_dram_reg(struct drm_device *dev)
 			ast_write32(ast, 0x12000, 0x1688A8A8);
 			do {
 				if (pci_channel_offline(dev->pdev))
-                                        return -EIO;
+					return -EIO;
 			} while (ast_read32(ast, 0x12000) != 0x01);
 
 			ast_write32(ast, 0x10000, 0xfc600309);
 			do {
 				if (pci_channel_offline(dev->pdev))
-                                        return -EIO;
+					return -EIO;
 			} while (ast_read32(ast, 0x10000) != 0x01);
 		}
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 5 lines · Defang Bo

[Why] Similar to commit <298360af3> ast_init_dram_reg() configures a window in order to access BMC memory. A BMC register can be configured to disallow this, and if so, causes
an infinite loop in the ast driver which renders the system unusable.
[How]
Fix this by erroring out if an error is detected.

Hm, it appears that all this patch does is change spaces to tabs...

Quoted 26 lines
---
 drivers/gpu/drm/ast/ast_post.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_post.c +2 -2
index ef19c70..86e4d23 100644
@@ -302,13 +302,13 @@ static void ast_init_dram_reg(struct drm_device *dev)
 			ast_write32(ast, 0x12000, 0x1688A8A8);
 			do {
 				if (pci_channel_offline(dev->pdev))
-                                        return -EIO;
+					return -EIO;
 			} while (ast_read32(ast, 0x12000) != 0x01);
 
 			ast_write32(ast, 0x10000, 0xfc600309);
 			do {
 				if (pci_channel_offline(dev->pdev))
-                                        return -EIO;
+					return -EIO;
 			} while (ast_read32(ast, 0x10000) != 0x01);
 		}
 
Signature · 1 line
~Randy