| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| From: Russell Currey <ruscur@russell.cc> |
| Date: Thu, 15 Dec 2016 16:12:41 +1100 |
| Subject: [PATCH 12/13] drivers/gpu/drm/ast: Fix infinite loop if read fails |
| |
| ast_get_dram_info() 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. |
| |
| Fix this by erroring out if an error is detected. On powerpc systems with |
| EEH, this leads to the device being fenced and the system continuing to |
| operate. |
| |
| Cc: <stable@vger.kernel.org> # 3.10+ |
| Signed-off-by: Russell Currey <ruscur@russell.cc> |
| Reviewed-by: Joel Stanley <joel@jms.id.au> |
| Signed-off-by: Joel Stanley <joel@jms.id.au> |
| --- |
| drivers/gpu/drm/ast/ast_main.c | 7 +++++-- |
| 1 file changed, 5 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c |
| index e0b4586a26fd..9b8f0b975ca6 100644 |
| --- a/drivers/gpu/drm/ast/ast_main.c |
| +++ b/drivers/gpu/drm/ast/ast_main.c |
| @@ -223,7 +223,8 @@ static int ast_get_dram_info(struct drm_device *dev) |
| ast_write32(ast, 0x10000, 0xfc600309); |
| |
| do { |
| - ; |
| + if (pci_channel_offline(dev->pdev)) |
| + return -EIO; |
| } while (ast_read32(ast, 0x10000) != 0x01); |
| data = ast_read32(ast, 0x10004); |
| |
| @@ -429,7 +430,9 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) |
| ast_detect_chip(dev, &need_post); |
| |
| if (ast->chip != AST1180) { |
| - ast_get_dram_info(dev); |
| + ret = ast_get_dram_info(dev); |
| + if (ret) |
| + goto out_free; |
| ast->vram_size = ast_get_vram_info(dev); |
| DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); |
| } |
| -- |
| 2.11.0 |
| |