Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp894759pxv; Thu, 22 Jul 2021 15:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaeLfb0SLFNq7y5Koe+GvE4sY4XM4dcKhi8/l7in7Gv460iwIYvj0X+m5zUi9xExiqMpPl X-Received: by 2002:a05:6e02:a:: with SMTP id h10mr1379037ilr.285.1626992562230; Thu, 22 Jul 2021 15:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626992562; cv=none; d=google.com; s=arc-20160816; b=PmIAOq0ka7osrv8Wzm9bgQNHcDX9Ma/88UJ36hc2tKoq6cxbqOO5W0+1pffUUkFOFU NfLHzCQJGBp4kzGrv2U45AS5VA9W3MUjcHie/2N8tXBYUAzcul2fdlAsYVe13PVy9/NR LN83vPZgGPmRWD05aAvy4mskG7hapexhn0jwcQgnUsx4xML9sTJ11yJ42LO6hyD2+h4e K8V6Js5UC/6Ct+i4bHbUNvavWx6Yo235JAiedkXpuCy//KA1ykNOeHV7t24uQ25HJ7jV wTFBOhYwMnOhqnOOZNT5wj2rarh41/UxYuDqfNvEvZwC7OecXtbfbvIFXcnahFzn/TM2 fjrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IG+A0C6qgBuTz51gSQirUJEzTvUPv/98qGkDkdYb9oo=; b=I6lnqVlTPvvQ2YjMMgN8meaLmgyOUq197/GrhtRkNot4H1v5g0t1q2Z/NdfjO3AXjk 3YbvqfGEJaPc4yfdrgXXqXE+2fHj8kCGaZ0165EPB6r5oOR9tb0L9EPQDtoHuDdFo/cR Pl75kfTk3Use2BjexkC1lbm3kVb/ot+VMEWpAQMwWJxNnsvleIcyeQtPRZ+B9Sw17eOO d08BFonHACzhmcWwKcdDM5fml1sUlZSNFBpz8oEImUQYx0pYXDi35WGmYLNJQGxCDFqR kHw8dox3fByBjcUkRplbK4ai+k7uaHNnAF/5e6aDURF1r9/unhXcuJ8I02gPyTS6l3iF TFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aeQCl850; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si30776331ilp.101.2021.07.22.15.22.30; Thu, 22 Jul 2021 15:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aeQCl850; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbhGVVj4 (ORCPT + 99 others); Thu, 22 Jul 2021 17:39:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbhGVVj4 (ORCPT ); Thu, 22 Jul 2021 17:39:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F1BE60EBC for ; Thu, 22 Jul 2021 22:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626992430; bh=UBbRW2dJdthNRV7ahn+zuo6vi/63CEXtWz9EMVemDGc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aeQCl8506WTehxEgSoqz2X579VZCIjQPDPuIi8+C6YZUAquNaVThYmdnOEvTk+EBE ovvcOZeHKdrWrqY48qn1jcrG2CE+lwPEO6W47Owj10NZAJaVOqt06Kzh0IoAvAoOll fgMcM681st3dfzTAFaRfFfM2SLgK32ESHrE938jm3xIptc7cR/R9vsNv3Gwv9CX3zX ax4uKbUtF1AeHz2EwYpJVvI3FlLNMD0SNAiyvbI03BVeXBM0m0cauCL0tupia6rZsv BSuzu0dZDR6zzWw+6snuTKV5bXXfw8iRvh6wKfqel09pj89euMBYxpybwuFfxIZOw7 pAYPpGDUCNv1A== Received: by mail-ej1-f48.google.com with SMTP id hq13so827439ejc.7 for ; Thu, 22 Jul 2021 15:20:30 -0700 (PDT) X-Gm-Message-State: AOAM533Y1bG0rzAE5ei+OEs/H7G1PjtFvt1aUxw2jDo1AE/7JZoMwFzO nVsJ4YNztq4kBdH1Tk0/edu/WrAj0I+361af+Q== X-Received: by 2002:a17:906:27da:: with SMTP id k26mr1895403ejc.267.1626992429164; Thu, 22 Jul 2021 15:20:29 -0700 (PDT) MIME-Version: 1.0 References: <20210722014743.8377-1-jason-jh.lin@mediatek.com> In-Reply-To: <20210722014743.8377-1-jason-jh.lin@mediatek.com> From: Chun-Kuang Hu Date: Fri, 23 Jul 2021 06:20:17 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4] drm/mediatek: Fix cursor plane didn't update To: "jason-jh.lin" Cc: Chun-Kuang Hu , Matthias Brugger , Maxime Ripard , Philipp Zabel , David Airlie , Daniel Vetter , ville.syrjala@linux.intel.com, Thomas Zimmermann , DRI Development , "moderated list:ARM/Mediatek SoC support" , Linux ARM , linux-kernel , Hsin-Yi Wang , seanpaul@chromium.org, Enric Balletbo i Serra , Nancy Lin , singo.chang@mediatek.com, David-YH.Chiu@mediatek.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jason: jason-jh.lin =E6=96=BC 2021=E5=B9=B47=E6=9C=882= 2=E6=97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8A=E5=8D=889:47=E5=AF=AB=E9=81=93=EF= =BC=9A > > The cursor plane should use the current plane state in atomic_async_updat= e > because it would not be the new plane state in the global atomic state > since _swap_state happened when those hook are run. > > Fix cursor plane issue by below modification: > 1. Remove plane_helper_funcs->atomic_update(plane, state) in > mtk_drm_crtc_async_update. > 2. Add mtk_drm_update_new_state in to mtk_plane_atomic_async_update to > update the cursor plane by current plane state hook and update > others plane by the new_state. Applied to mediatek-drm-fixes [1], thanks. [1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/= log/?h=3Dmediatek-drm-fixes Regards, Chun-Kuang. > > Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state po= inter") > Signed-off-by: jason-jh.lin > Tested-by: Enric Balletbo i Serra > --- > Change in v4: > - Fix compile warning: > ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:578:39: warning: unused > variable =E2=80=98plane_helper_funcs=E2=80=99 [-Wunused-variable > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 -- > drivers/gpu/drm/mediatek/mtk_drm_plane.c | 60 ++++++++++++++---------- > 2 files changed, 34 insertions(+), 29 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index 40df2c823187..515315505e3b 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -532,13 +532,10 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crt= c, struct drm_plane *plane, > struct drm_atomic_state *state) > { > struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); > - const struct drm_plane_helper_funcs *plane_helper_funcs =3D > - plane->helper_private; > > if (!mtk_crtc->enabled) > return; > > - plane_helper_funcs->atomic_update(plane, state); > mtk_drm_crtc_update_config(mtk_crtc, false); > } > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/m= ediatek/mtk_drm_plane.c > index b5582dcf564c..e6dcb34d3052 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > @@ -110,6 +110,35 @@ static int mtk_plane_atomic_async_check(struct drm_p= lane *plane, > true, true); > } > > +static void mtk_plane_update_new_state(struct drm_plane_state *new_state= , > + struct mtk_plane_state *mtk_plane_= state) > +{ > + struct drm_framebuffer *fb =3D new_state->fb; > + struct drm_gem_object *gem; > + struct mtk_drm_gem_obj *mtk_gem; > + unsigned int pitch, format; > + dma_addr_t addr; > + > + gem =3D fb->obj[0]; > + mtk_gem =3D to_mtk_gem_obj(gem); > + addr =3D mtk_gem->dma_addr; > + pitch =3D fb->pitches[0]; > + format =3D fb->format->format; > + > + addr +=3D (new_state->src.x1 >> 16) * fb->format->cpp[0]; > + addr +=3D (new_state->src.y1 >> 16) * pitch; > + > + mtk_plane_state->pending.enable =3D true; > + mtk_plane_state->pending.pitch =3D pitch; > + mtk_plane_state->pending.format =3D format; > + mtk_plane_state->pending.addr =3D addr; > + mtk_plane_state->pending.x =3D new_state->dst.x1; > + mtk_plane_state->pending.y =3D new_state->dst.y1; > + mtk_plane_state->pending.width =3D drm_rect_width(&new_state->dst= ); > + mtk_plane_state->pending.height =3D drm_rect_height(&new_state->d= st); > + mtk_plane_state->pending.rotation =3D new_state->rotation; > +} > + > static void mtk_plane_atomic_async_update(struct drm_plane *plane, > struct drm_atomic_state *state) > { > @@ -126,8 +155,10 @@ static void mtk_plane_atomic_async_update(struct drm= _plane *plane, > plane->state->src_h =3D new_state->src_h; > plane->state->src_w =3D new_state->src_w; > swap(plane->state->fb, new_state->fb); > - new_plane_state->pending.async_dirty =3D true; > > + mtk_plane_update_new_state(new_state, new_plane_state); > + wmb(); /* Make sure the above parameters are set before update */ > + new_plane_state->pending.async_dirty =3D true; > mtk_drm_crtc_async_update(new_state->crtc, plane, state); > } > > @@ -189,14 +220,8 @@ static void mtk_plane_atomic_update(struct drm_plane= *plane, > struct drm_plane_state *new_state =3D drm_atomic_get_new_plane_st= ate(state, > = plane); > struct mtk_plane_state *mtk_plane_state =3D to_mtk_plane_state(ne= w_state); > - struct drm_crtc *crtc =3D new_state->crtc; > - struct drm_framebuffer *fb =3D new_state->fb; > - struct drm_gem_object *gem; > - struct mtk_drm_gem_obj *mtk_gem; > - unsigned int pitch, format; > - dma_addr_t addr; > > - if (!crtc || WARN_ON(!fb)) > + if (!new_state->crtc || WARN_ON(!new_state->fb)) > return; > > if (!new_state->visible) { > @@ -204,24 +229,7 @@ static void mtk_plane_atomic_update(struct drm_plane= *plane, > return; > } > > - gem =3D fb->obj[0]; > - mtk_gem =3D to_mtk_gem_obj(gem); > - addr =3D mtk_gem->dma_addr; > - pitch =3D fb->pitches[0]; > - format =3D fb->format->format; > - > - addr +=3D (new_state->src.x1 >> 16) * fb->format->cpp[0]; > - addr +=3D (new_state->src.y1 >> 16) * pitch; > - > - mtk_plane_state->pending.enable =3D true; > - mtk_plane_state->pending.pitch =3D pitch; > - mtk_plane_state->pending.format =3D format; > - mtk_plane_state->pending.addr =3D addr; > - mtk_plane_state->pending.x =3D new_state->dst.x1; > - mtk_plane_state->pending.y =3D new_state->dst.y1; > - mtk_plane_state->pending.width =3D drm_rect_width(&new_state->dst= ); > - mtk_plane_state->pending.height =3D drm_rect_height(&new_state->d= st); > - mtk_plane_state->pending.rotation =3D new_state->rotation; > + mtk_plane_update_new_state(new_state, mtk_plane_state); > wmb(); /* Make sure the above parameters are set before update */ > mtk_plane_state->pending.dirty =3D true; > } > -- > 2.18.0 >