Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C456C61DA4 for ; Fri, 10 Feb 2023 00:33:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75A3410EC0F; Fri, 10 Feb 2023 00:33:12 +0000 (UTC) Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED48410EC1B for ; Fri, 10 Feb 2023 00:33:10 +0000 (UTC) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 31A0KnXW028229; Fri, 10 Feb 2023 08:20:49 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 10 Feb 2023 08:33:03 +0800 Content-Type: multipart/alternative; boundary="------------Q45V7jN0Ub9lA0PLsdjLGgDK" Message-ID: Date: Fri, 10 Feb 2023 08:33:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v3] drm/ast: Fix start address computation To: Thomas Zimmermann , Jocelyn Falempe , , , References: <20230209094417.21630-1-jfalempe@redhat.com> <76785a76-281d-f847-5904-d8df361aa0b4@suse.de> Content-Language: en-US From: Jammy Huang In-Reply-To: <76785a76-281d-f847-5904-d8df361aa0b4@suse.de> X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 31A0KnXW028229 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --------------Q45V7jN0Ub9lA0PLsdjLGgDK Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit On 2023/2/9 下午 05:55, Thomas Zimmermann wrote: > > > Am 09.02.23 um 10:44 schrieb Jocelyn Falempe: >> During the driver conversion to shmem, the start address for the >> scanout buffer was set to the base PCI address. >> In most cases it works because only the lower 24bits are used, and >> due to alignment it was almost always 0. >> But on some unlucky hardware, it's not the case, and some unitilized > > 'uninitialized' > >> memory is displayed on the BMC. >> With shmem, the primary plane is always at offset 0 in GPU memory. >> >>   * v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann) >>   * v3: move the change to plane_init() and also fix the cursor plane. >>         (Jammy Huang) >> >> Tested on a sr645 affected by this bug. >> >> Fixes: f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM") >> Signed-off-by: Jocelyn Falempe > > Reviewed-by: Thomas Zimmermann Reviewed-by: Jammy Huang > >> --- >>   drivers/gpu/drm/ast/ast_mode.c | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/ast/ast_mode.c >> b/drivers/gpu/drm/ast/ast_mode.c >> index c7443317c747..66a4a41c3fe9 100644 >> --- a/drivers/gpu/drm/ast/ast_mode.c >> +++ b/drivers/gpu/drm/ast/ast_mode.c >> @@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct >> ast_private *ast) >>       struct ast_plane *ast_primary_plane = &ast->primary_plane; >>       struct drm_plane *primary_plane = &ast_primary_plane->base; >>       void __iomem *vaddr = ast->vram; >> -    u64 offset = ast->vram_base; >> +    u64 offset = 0; /* with shmem, the primary plane is always at >> offset 0 */ >>       unsigned long cursor_size = roundup(AST_HWC_SIZE + >> AST_HWC_SIGNATURE_SIZE, PAGE_SIZE); >>       unsigned long size = ast->vram_fb_available - cursor_size; >>       int ret; >> @@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct >> ast_private *ast) >>           return -ENOMEM; >>         vaddr = ast->vram + ast->vram_fb_available - size; >> -    offset = ast->vram_base + ast->vram_fb_available - size; >> +    offset = ast->vram_fb_available - size; >>         ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size, >>                    0x01, &ast_cursor_plane_funcs, > -- Best Regards Jammy --------------Q45V7jN0Ub9lA0PLsdjLGgDK Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit


On 2023/2/9 下午 05:55, Thomas Zimmermann wrote:


Am 09.02.23 um 10:44 schrieb Jocelyn Falempe:
During the driver conversion to shmem, the start address for the
scanout buffer was set to the base PCI address.
In most cases it works because only the lower 24bits are used, and
due to alignment it was almost always 0.
But on some unlucky hardware, it's not the case, and some unitilized

'uninitialized'

memory is displayed on the BMC.
With shmem, the primary plane is always at offset 0 in GPU memory.

  * v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann)
  * v3: move the change to plane_init() and also fix the cursor plane.
        (Jammy Huang)

Tested on a sr645 affected by this bug.

Fixes: f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Reviewed-by: Jammy Huang <jammy_huang@aspeedtech.com>


---
  drivers/gpu/drm/ast/ast_mode.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index c7443317c747..66a4a41c3fe9 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct ast_private *ast)
      struct ast_plane *ast_primary_plane = &ast->primary_plane;
      struct drm_plane *primary_plane = &ast_primary_plane->base;
      void __iomem *vaddr = ast->vram;
-    u64 offset = ast->vram_base;
+    u64 offset = 0; /* with shmem, the primary plane is always at offset 0 */
      unsigned long cursor_size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
      unsigned long size = ast->vram_fb_available - cursor_size;
      int ret;
@@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
          return -ENOMEM;
        vaddr = ast->vram + ast->vram_fb_available - size;
-    offset = ast->vram_base + ast->vram_fb_available - size;
+    offset = ast->vram_fb_available - size;
        ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size,
                   0x01, &ast_cursor_plane_funcs,

-- 
Best Regards
Jammy
--------------Q45V7jN0Ub9lA0PLsdjLGgDK--