Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3713228pxf; Mon, 29 Mar 2021 09:22:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrDowCz3qVunOGT0pJ+yb3g6zxTXL65QwEhav+bM6oWj0zh/teV3u8rurK329UAzjJt7PH X-Received: by 2002:a17:906:845b:: with SMTP id e27mr28646347ejy.487.1617034929293; Mon, 29 Mar 2021 09:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617034929; cv=none; d=google.com; s=arc-20160816; b=zpAsQQbl/WQLTVX0WqFTS9BHLbgcwrbIoH/OefkvRwSVbu6gh4wCYrTuz76N6pSOol vRiHjbh8OQ+82AplHi8+4WuxYpp/87bT9XG2g9EYhajPW5sUX+RA0QETAbrJdqefhfNB jG8QSatYjVGxT4nYCK9/O6G4LPNWKuoTV6lt4fIQrwN/MkXsSpfYXrNqgG1aalCFVsbb fK437FSyxIYTg838Io/OD4j40yQlLpMiZZx4xTyZvOCbBQnItUEogITaBAVb+i7p+d9Q 9XyIinghPxJbIL2MpN/DUku/ZRUEkw3ROH31k1rOUopJB6dnX6xsIprEcYn9tmrt9GGM dMeQ== 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=x60BSljcZQHABA/Mzbq2gyBwZWvWWbwQHIcCWVcid2I=; b=Sc1DPs5d8Bvw2REFsSKMnJgeg2ZfIPERy24zFrfrK+2NwP4CKa48MOKl0ygYJVPHqe fYFVYN6ZjdwkgbpUy5drqhzXEOsPe1GTEfH0oJt0giOozCebAoc7egAtyJnJOz3mJDmC X+6xqDa41k2Pn5ewg5E2Lww1ueuV99HWT57FEvaazDYXHMlPEnQY5f8Wa/Uth+OLuQnf Kq+VP5Z1ShNEoZEpIPHB3nI1pfbUgRmZ4Yzrt+GcdlzXa1lZ3pXzU7SG49WU3uOByYl0 wrSnETOafrwK9DqhN+r6NNRTg1UUK/YDSSk6+PH0hbjqFUhtsXkGMWWMrlfdJBleESKf XzbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rkSS3PoK; 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 yk13si12903362ejb.127.2021.03.29.09.21.39; Mon, 29 Mar 2021 09:22:09 -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=rkSS3PoK; 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 S229955AbhC2QSi (ORCPT + 99 others); Mon, 29 Mar 2021 12:18:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:36964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbhC2QST (ORCPT ); Mon, 29 Mar 2021 12:18:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A0D8561964 for ; Mon, 29 Mar 2021 16:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617034698; bh=g+KluKB8J7DldbUMXc360cZ2gLPYH64Rs8T0Q973c4I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rkSS3PoK+z4fEREe+CoYCingZyivZDsBHNbwPlFWBfPdMrt4Wt+zyS0PB/B2OASft G79ZHSSLVeV608NosAI5ZvXt+Ii+uXVp48O7e7S6USRvhyHpSgg5E2UCOxtO8r71Ij zzNChtAVev9Kel8Ho5KPcqAQHKJAnrxW70r27OpKxP/BQ80/UPJNkivj1/oy1mDCmu uedhsqvFsWBPC2N9dGPVvJ5sNALsTiBAeezUCb0vgnt3Fw1AtWg0Ipya7mDRW4VGU9 YbZimZtgj+IKi6BPVysKGCJ+f9TKR+prb7xUfxxaO0EpAHAF/xmXEQbEa52fsQlZ6c /GOwQRix4h1Zw== Received: by mail-ej1-f52.google.com with SMTP id jy13so20399872ejc.2 for ; Mon, 29 Mar 2021 09:18:18 -0700 (PDT) X-Gm-Message-State: AOAM530l6cFBPSSfMCikYARySaCN9uw+yrLDU3FblqXMEBHSj2wh4JWp mx+Dog2fLJZ7fHPyzh0DJxPla6zJZCbbi82E0w== X-Received: by 2002:a17:906:7c4:: with SMTP id m4mr29562982ejc.63.1617034697158; Mon, 29 Mar 2021 09:18:17 -0700 (PDT) MIME-Version: 1.0 References: <20210313094331.26374-1-chunkuang.hu@kernel.org> In-Reply-To: <20210313094331.26374-1-chunkuang.hu@kernel.org> From: Chun-Kuang Hu Date: Tue, 30 Mar 2021 00:18:05 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/mediatek: crtc: Make config-updating atomic To: Chun-Kuang Hu Cc: Philipp Zabel , David Airlie , Daniel Vetter , linux-kernel , DRI Development , "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied to mediatek-drm-next [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/= log/?h=3Dmediatek-drm-next Regards, Chun-Kuang. Chun-Kuang Hu =E6=96=BC 2021=E5=B9=B43=E6=9C=8813= =E6=97=A5 =E9=80=B1=E5=85=AD =E4=B8=8B=E5=8D=885:43=E5=AF=AB=E9=81=93=EF=BC= =9A > > While updating config, the irq would occur and get the partial > config, so use variable config_updating to make updating atomic. > > Signed-off-by: Chun-Kuang Hu > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index 8b0de90156c6..870f66210848 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -61,6 +61,7 @@ struct mtk_drm_crtc { > > /* lock for display hardware access */ > struct mutex hw_lock; > + bool config_updating; > }; > > struct mtk_crtc_state { > @@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_dr= m_crtc *mtk_crtc) > static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) > { > drm_crtc_handle_vblank(&mtk_crtc->base); > - if (mtk_crtc->pending_needs_vblank) { > + if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank)= { > mtk_drm_crtc_finish_page_flip(mtk_crtc); > mtk_crtc->pending_needs_vblank =3D false; > } > @@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc= , > } > } > > -static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) > +static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc, > + bool needs_vblank) > { > #if IS_REACHABLE(CONFIG_MTK_CMDQ) > struct cmdq_pkt *cmdq_handle; > @@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_cr= tc *mtk_crtc) > int i; > > mutex_lock(&mtk_crtc->hw_lock); > + mtk_crtc->config_updating =3D true; > + if (needs_vblank) > + mtk_crtc->pending_needs_vblank =3D true; > + > for (i =3D 0; i < mtk_crtc->layer_nr; i++) { > struct drm_plane *plane =3D &mtk_crtc->planes[i]; > struct mtk_plane_state *plane_state; > @@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crt= c *mtk_crtc) > cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handl= e); > } > #endif > + mtk_crtc->config_updating =3D false; > mutex_unlock(&mtk_crtc->hw_lock); > } > > @@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc,= struct drm_plane *plane, > return; > > plane_helper_funcs->atomic_update(plane, new_state); > - mtk_drm_crtc_hw_config(mtk_crtc); > + mtk_drm_crtc_update_config(mtk_crtc, false); > } > > static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, > @@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_cr= tc *crtc, > } > mtk_crtc->pending_planes =3D true; > > - mtk_drm_crtc_hw_config(mtk_crtc); > + mtk_drm_crtc_update_config(mtk_crtc, false); > /* Wait for planes to be disabled */ > drm_crtc_wait_one_vblank(crtc); > > @@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_cr= tc *crtc, > struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); > int i; > > - if (mtk_crtc->event) > - mtk_crtc->pending_needs_vblank =3D true; > if (crtc->state->color_mgmt_changed) > for (i =3D 0; i < mtk_crtc->ddp_comp_nr; i++) { > mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->st= ate); > mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->stat= e); > } > - mtk_drm_crtc_hw_config(mtk_crtc); > + mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event); > } > > static const struct drm_crtc_funcs mtk_crtc_funcs =3D { > -- > 2.17.1 >