| Joel Stanley | 514bd26 | 2016-12-21 12:04:08 +1030 | [diff] [blame^] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | 
|  | 2 | From: Russell Currey <ruscur@russell.cc> | 
|  | 3 | Date: Thu, 15 Dec 2016 16:12:41 +1100 | 
|  | 4 | Subject: [PATCH 12/13] drivers/gpu/drm/ast: Fix infinite loop if read fails | 
|  | 5 |  | 
|  | 6 | ast_get_dram_info() configures a window in order to access BMC memory. | 
|  | 7 | A BMC register can be configured to disallow this, and if so, causes | 
|  | 8 | an infinite loop in the ast driver which renders the system unusable. | 
|  | 9 |  | 
|  | 10 | Fix this by erroring out if an error is detected.  On powerpc systems with | 
|  | 11 | EEH, this leads to the device being fenced and the system continuing to | 
|  | 12 | operate. | 
|  | 13 |  | 
|  | 14 | Cc: <stable@vger.kernel.org> # 3.10+ | 
|  | 15 | Signed-off-by: Russell Currey <ruscur@russell.cc> | 
|  | 16 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 
|  | 17 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 
|  | 18 | --- | 
|  | 19 | drivers/gpu/drm/ast/ast_main.c | 7 +++++-- | 
|  | 20 | 1 file changed, 5 insertions(+), 2 deletions(-) | 
|  | 21 |  | 
|  | 22 | diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c | 
|  | 23 | index e0b4586a26fd..9b8f0b975ca6 100644 | 
|  | 24 | --- a/drivers/gpu/drm/ast/ast_main.c | 
|  | 25 | +++ b/drivers/gpu/drm/ast/ast_main.c | 
|  | 26 | @@ -223,7 +223,8 @@ static int ast_get_dram_info(struct drm_device *dev) | 
|  | 27 | ast_write32(ast, 0x10000, 0xfc600309); | 
|  | 28 |  | 
|  | 29 | do { | 
|  | 30 | -		; | 
|  | 31 | +		if (pci_channel_offline(dev->pdev)) | 
|  | 32 | +			return -EIO; | 
|  | 33 | } while (ast_read32(ast, 0x10000) != 0x01); | 
|  | 34 | data = ast_read32(ast, 0x10004); | 
|  | 35 |  | 
|  | 36 | @@ -429,7 +430,9 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) | 
|  | 37 | ast_detect_chip(dev, &need_post); | 
|  | 38 |  | 
|  | 39 | if (ast->chip != AST1180) { | 
|  | 40 | -		ast_get_dram_info(dev); | 
|  | 41 | +		ret = ast_get_dram_info(dev); | 
|  | 42 | +		if (ret) | 
|  | 43 | +			goto out_free; | 
|  | 44 | ast->vram_size = ast_get_vram_info(dev); | 
|  | 45 | DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); | 
|  | 46 | } | 
|  | 47 | -- | 
|  | 48 | 2.11.0 | 
|  | 49 |  |