Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4726209rwb; Tue, 8 Aug 2023 12:50:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH32LkmLyd2k38u+Alut/me95lcC/44MWDKslyNQ5OZpsAEh/EK262Vb6UBKGhYRy+qJE4E X-Received: by 2002:a05:6a00:9a4:b0:682:2e99:9de0 with SMTP id u36-20020a056a0009a400b006822e999de0mr531894pfg.23.1691524208009; Tue, 08 Aug 2023 12:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691524207; cv=none; d=google.com; s=arc-20160816; b=Qne8s+KR/yL2yDajEFqsOiYonXKE3NOBXPgc8tNvoRppuns/9IFvJK5nF1mzrwvN4x I637lTkk63u7FEFY/uTF3bHz+QrlcAngJi0RKDZ38ad8Jd78awiOl4vEuFL53k7QO/IX mScbgP8ZFnP1BDmid6Xv4Us2E2pxdlNZTV39nQgNkryAOjppPzDbApw/0XzJstka72mo WYsE0OA3vDWBGJ/m1MEvWgcetA0bMiisRBtf1/Irzp9H9cHeqBD/c87e5V3tj9Q2zgf8 GhvrQdboO/SqNalioo5C+hBtOucAjlWqpejA+DYgoiMP0Qbw6mC/AWgbMjNGIYnhf9be xMog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=kphVNSvcmtj/FZqAA55gOFPaJXv7shulyJy0S8Pnwf0=; fh=1CDwnT+azezbhcqJJYz9pqBDP+bXGcuRIBy14z+U4ak=; b=wG8tqf/93EugaN8vCm6sQLjFXrL0w4uDyY5k7P/ArxLsgPWfPE2WQoN8Xs17HUBE+3 cyfG4Ou87urCaXxva34BG6OD+oGP5vR9zPJ6+biMdadT+9Ty/RG2JC/pfGfwi6NxPkYL fyY88/83vfURWiA//X/9w27Em7KQolLLr+frXVtHtvORfth3NLNIhd8hIjv+13LTx1C+ CMxATQePt2R0XIOJpwcOaun9CGuLKrLh9N7OISwPCMjjeF8gcIy8YvMUuQEt4pDegzT6 BJDCv/qZDfCgkpSO0zdxXdDqkLZWdlHY0lW0+yAuifBg89TSxX9+VEcGPuKEatIWM+aU Ncfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PDXykDxx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0055339507f67si288699pgb.836.2023.08.08.12.49.56; Tue, 08 Aug 2023 12:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PDXykDxx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235489AbjHHTQZ (ORCPT + 99 others); Tue, 8 Aug 2023 15:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235464AbjHHTQL (ORCPT ); Tue, 8 Aug 2023 15:16:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B81E014FD5 for ; Tue, 8 Aug 2023 09:38:45 -0700 (PDT) Received: from [192.168.0.125] (unknown [82.76.24.202]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 916486607208; Tue, 8 Aug 2023 12:55:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691495719; bh=ZHAS+3Ex6HkMzLNH4hZADNVpGBBmv0IfwABrMBgoDZ4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PDXykDxxTHok/w0WllFQUUwwKDR3XLFKsBeEAS+S3hAVI8H3LdawLENcP0RP47T1m 5259KHy0EXGO3IoyKrq1WtWM1aje4aiTEOrO90WnHmdpZGKb5kvNIPRpMxLabYw586 2SvP9cQpK+a6grvCu+3LkOZDdqtFxfiPsIx1DVzpEsRzg4mENKitwtcg4I8uilyidV zwAJZqftTGdSjz5fUm+yy9dEz4dST5wNPX+XCJ8MUuxxa66bL+KfJ/ArqRynuWxw1S NawmjA/NDKGop1hYAaFN37LIwHHOGELTw4ALtwCw/G2SLC3ch32TWsxmGfPuOM9aDZ s43zfGuZ/NdVw== Message-ID: <02dc52cd-db64-af1c-0f07-5ef76b954c75@collabora.com> Date: Tue, 8 Aug 2023 14:55:15 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH RESEND v4 2/2] drm/mediatek: Fix iommu fault during crtc enabling Content-Language: en-US To: "Jason-JH.Lin" , Chun-Kuang Hu , AngeloGioacchino Del Regno , Alexandre Mergnat Cc: Jason-ch Chen , Johnson Wang , Singo Chang , Nancy Lin , Shawn Sung , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Project_Global_Chrome_Upstream_Group@mediatek.com References: <20230807015110.30579-1-jason-jh.lin@mediatek.com> <20230807015110.30579-3-jason-jh.lin@mediatek.com> From: Eugen Hristev In-Reply-To: <20230807015110.30579-3-jason-jh.lin@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On 8/7/23 04:51, Jason-JH.Lin wrote: > The plane_state of drm_atomic_state is not sync to the mtk_plane_state > stored in mtk_crtc during crtc enabling. > > So we need to update the mtk_plane_state stored in mtk_crtc by the > drm_atomic_state carried from mtk_drm_crtc_atomic_enable(). > > While updating mtk_plane_state, OVL layer should be disabled when the fb > in plane_state of drm_atomic_state is NULL. > > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.") > Signed-off-by: Jason-JH.Lin > --- > Change in RESEND v4: > Remove redundant plane_state assigning. > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 14 ++++++++++---- > drivers/gpu/drm/mediatek/mtk_drm_plane.c | 11 ++++++++--- > drivers/gpu/drm/mediatek/mtk_drm_plane.h | 2 ++ > 3 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > index d40142842f85..7db4d6551da7 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -328,7 +328,7 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) > } > #endif > > -static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) > +static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc, struct drm_atomic_state *state) > { > struct drm_crtc *crtc = &mtk_crtc->base; > struct drm_connector *connector; > @@ -405,11 +405,17 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) > /* Initially configure all planes */ > for (i = 0; i < mtk_crtc->layer_nr; i++) { > struct drm_plane *plane = &mtk_crtc->planes[i]; > - struct mtk_plane_state *plane_state; > + struct drm_plane_state *new_state; > + struct mtk_plane_state *plane_state = to_mtk_plane_state(plane->state); > struct mtk_ddp_comp *comp; > unsigned int local_layer; > > - plane_state = to_mtk_plane_state(plane->state); any reason why you moved the initialization of plane_state at the declaration phase ? > + /* sync the new plane state from drm_atomic_state */ > + if (state->planes[i].ptr) { > + new_state = drm_atomic_get_new_plane_state(state, state->planes[i].ptr); Can drm_atomic_get_new_plane_state fail ? and new_state becomes null ? I see mtk_plane_update_new_state assumes new_state being a correct state/pointer. Regards, > + mtk_plane_update_new_state(new_state, plane_state); > + } > + > comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); > if (comp) > mtk_ddp_comp_layer_config(comp, local_layer, > @@ -687,7 +693,7 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, > return; > } > > - ret = mtk_crtc_ddp_hw_init(mtk_crtc); > + ret = mtk_crtc_ddp_hw_init(mtk_crtc, state); > if (ret) { > pm_runtime_put(comp->dev); > return; > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > index b1a918ffe457..ef4460f98c07 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > @@ -134,8 +134,8 @@ static int mtk_plane_atomic_async_check(struct drm_plane *plane, > true, true); > } > > -static void mtk_plane_update_new_state(struct drm_plane_state *new_state, > - struct mtk_plane_state *mtk_plane_state) > +void mtk_plane_update_new_state(struct drm_plane_state *new_state, > + struct mtk_plane_state *mtk_plane_state) > { > struct drm_framebuffer *fb = new_state->fb; > struct drm_gem_object *gem; > @@ -146,6 +146,11 @@ static void mtk_plane_update_new_state(struct drm_plane_state *new_state, > dma_addr_t hdr_addr = 0; > unsigned int hdr_pitch = 0; > > + if (!fb) { > + mtk_plane_state->pending.enable = false; > + return; > + } > + > gem = fb->obj[0]; > mtk_gem = to_mtk_gem_obj(gem); > addr = mtk_gem->dma_addr; > @@ -180,7 +185,7 @@ static void mtk_plane_update_new_state(struct drm_plane_state *new_state, > fb->format->cpp[0] * (x_offset_in_blocks + 1); > } > > - mtk_plane_state->pending.enable = true; > + mtk_plane_state->pending.enable = new_state->visible; > mtk_plane_state->pending.pitch = pitch; > mtk_plane_state->pending.hdr_pitch = hdr_pitch; > mtk_plane_state->pending.format = format; > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.h b/drivers/gpu/drm/mediatek/mtk_drm_plane.h > index 99aff7da0831..0a7d70d13e43 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.h > @@ -46,6 +46,8 @@ to_mtk_plane_state(struct drm_plane_state *state) > return container_of(state, struct mtk_plane_state, base); > } > > +void mtk_plane_update_new_state(struct drm_plane_state *new_state, > + struct mtk_plane_state *mtk_plane_state); > int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, > unsigned long possible_crtcs, enum drm_plane_type type, > unsigned int supported_rotations, const u32 *formats,