ACK: [SRU][Trusty][PATCH 1/1] drm/ast: Fixed system hanged if disable P2A
Stefan Bader
stefan.bader at canonical.com
Thu Aug 30 08:36:19 UTC 2018
On 27.08.2018 16:15, Juerg Haefliger wrote:
> From: "Y.C. Chen" <yc_chen at aspeedtech.com>
>
> BugLink: https://bugs.launchpad.net/bugs/1788817
>
> The original ast driver will access some BMC configuration through P2A bridge
> that can be disabled since AST2300 and after.
> It will cause system hanged if P2A bridge is disabled.
> Here is the update to fix it.
>
> Signed-off-by: Y.C. Chen <yc_chen at aspeedtech.com>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
>
> (backported from commit 6c971c09f38704513c426ba6515f22fb3d6c87d5)
> [juergh: Adjusted context.]
> Signed-off-by: Juerg Haefliger <juergh at canonical.com>
Acked-by: Stefan Bader <stefan.bader at canonical.com>
> ---
> drivers/gpu/drm/ast/ast_drv.h | 1 +
> drivers/gpu/drm/ast/ast_main.c | 134 +++++++++++++++++----------------
> drivers/gpu/drm/ast/ast_post.c | 10 ++-
> 3 files changed, 77 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
> index 3fc122306f1f..96d1e21e0a6a 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -102,6 +102,7 @@ struct ast_private {
> * we have. */
> struct ttm_bo_kmap_obj cache_kmap;
> int next_cursor;
> + bool DisableP2A;
> };
>
> int ast_driver_load(struct drm_device *dev, unsigned long flags);
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index dc4da6ac131d..7748abfd8afa 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -66,6 +66,7 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast,
> static int ast_detect_chip(struct drm_device *dev)
> {
> struct ast_private *ast = dev->dev_private;
> + uint32_t data;
> ast_open_key(ast);
>
> if (dev->pdev->device == PCI_CHIP_AST1180) {
> @@ -76,7 +77,6 @@ static int ast_detect_chip(struct drm_device *dev)
> ast->chip = AST2300;
> DRM_INFO("AST 2300 detected\n");
> } else if (dev->pdev->revision >= 0x10) {
> - uint32_t data;
> ast_write32(ast, 0xf004, 0x1e6e0000);
> ast_write32(ast, 0xf000, 0x1);
>
> @@ -105,6 +105,13 @@ static int ast_detect_chip(struct drm_device *dev)
> DRM_INFO("AST 2000 detected\n");
> }
> }
> +
> + /* Check P2A Access */
> + ast->DisableP2A = true;
> + data = ast_read32(ast, 0xf004);
> + if (data != 0xFFFFFFFF)
> + ast->DisableP2A = false;
> +
> return 0;
> }
>
> @@ -114,79 +121,78 @@ static int ast_get_dram_info(struct drm_device *dev)
> uint32_t data, data2;
> uint32_t denum, num, div, ref_pll;
>
> - ast_write32(ast, 0xf004, 0x1e6e0000);
> - ast_write32(ast, 0xf000, 0x1);
> -
> + if (ast->DisableP2A) {
> + ast->dram_bus_width = 16;
> + ast->dram_type = AST_DRAM_1Gx16;
> + ast->mclk = 396;
> + } else {
> + ast_write32(ast, 0xf004, 0x1e6e0000);
> + ast_write32(ast, 0xf000, 0x1);
> + data = ast_read32(ast, 0x10004);
>
> - ast_write32(ast, 0x10000, 0xfc600309);
> + if (data & 0x40)
> + ast->dram_bus_width = 16;
> + else
> + ast->dram_bus_width = 32;
>
> - do {
> - ;
> - } while (ast_read32(ast, 0x10000) != 0x01);
> - data = ast_read32(ast, 0x10004);
> + if (ast->chip == AST2300) {
> + switch (data & 0x03) {
> + case 0:
> + ast->dram_type = AST_DRAM_512Mx16;
> + break;
> + default:
> + case 1:
> + ast->dram_type = AST_DRAM_1Gx16;
> + break;
> + case 2:
> + ast->dram_type = AST_DRAM_2Gx16;
> + break;
> + case 3:
> + ast->dram_type = AST_DRAM_4Gx16;
> + break;
> + }
> + } else {
> + switch (data & 0x0c) {
> + case 0:
> + case 4:
> + ast->dram_type = AST_DRAM_512Mx16;
> + break;
> + case 8:
> + if (data & 0x40)
> + ast->dram_type = AST_DRAM_1Gx16;
> + else
> + ast->dram_type = AST_DRAM_512Mx32;
> + break;
> + case 0xc:
> + ast->dram_type = AST_DRAM_1Gx32;
> + break;
> + }
> + }
>
> - if (data & 0x40)
> - ast->dram_bus_width = 16;
> - else
> - ast->dram_bus_width = 32;
> + data = ast_read32(ast, 0x10120);
> + data2 = ast_read32(ast, 0x10170);
> + if (data2 & 0x2000)
> + ref_pll = 14318;
> + else
> + ref_pll = 12000;
>
> - if (ast->chip == AST2300) {
> - switch (data & 0x03) {
> - case 0:
> - ast->dram_type = AST_DRAM_512Mx16;
> - break;
> - default:
> - case 1:
> - ast->dram_type = AST_DRAM_1Gx16;
> - break;
> - case 2:
> - ast->dram_type = AST_DRAM_2Gx16;
> - break;
> + denum = data & 0x1f;
> + num = (data & 0x3fe0) >> 5;
> + data = (data & 0xc000) >> 14;
> + switch (data) {
> case 3:
> - ast->dram_type = AST_DRAM_4Gx16;
> + div = 0x4;
> break;
> - }
> - } else {
> - switch (data & 0x0c) {
> - case 0:
> - case 4:
> - ast->dram_type = AST_DRAM_512Mx16;
> - break;
> - case 8:
> - if (data & 0x40)
> - ast->dram_type = AST_DRAM_1Gx16;
> - else
> - ast->dram_type = AST_DRAM_512Mx32;
> + case 2:
> + case 1:
> + div = 0x2;
> break;
> - case 0xc:
> - ast->dram_type = AST_DRAM_1Gx32;
> + default:
> + div = 0x1;
> break;
> }
> + ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
> }
> -
> - data = ast_read32(ast, 0x10120);
> - data2 = ast_read32(ast, 0x10170);
> - if (data2 & 0x2000)
> - ref_pll = 14318;
> - else
> - ref_pll = 12000;
> -
> - denum = data & 0x1f;
> - num = (data & 0x3fe0) >> 5;
> - data = (data & 0xc000) >> 14;
> - switch (data) {
> - case 3:
> - div = 0x4;
> - break;
> - case 2:
> - case 1:
> - div = 0x2;
> - break;
> - default:
> - div = 0x1;
> - break;
> - }
> - ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
> return 0;
> }
>
> diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
> index 977cfb35837a..511e1ba78fb1 100644
> --- a/drivers/gpu/drm/ast/ast_post.c
> +++ b/drivers/gpu/drm/ast/ast_post.c
> @@ -365,10 +365,12 @@ void ast_post_gpu(struct drm_device *dev)
> ast_open_key(ast);
> ast_set_def_ext_reg(dev);
>
> - if (ast->chip == AST2300)
> - ast_init_dram_2300(dev);
> - else
> - ast_init_dram_reg(dev);
> + if (ast->DisableP2A == false) {
> + if (ast->chip == AST2300)
> + ast_init_dram_2300(dev);
> + else
> + ast_init_dram_reg(dev);
> + }
> }
>
> /* AST 2300 DRAM settings */
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20180830/fcbbc404/attachment.sig>
More information about the kernel-team
mailing list