From patchwork Thu Jul 27 16:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SmFzb24tSkggTGluICjmnpfnnb/npaUp?= X-Patchwork-Id: 13330396 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 51701C0015E for ; Thu, 27 Jul 2023 16:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CS3Hm4ozWdVn8VxCoaqtbrurbs/IDYCI2iODXuClW5M=; b=XEbkutiPFfK4p+LaIS7r5YlXn0 MEhy8FoyQ5VMiLBJ3QGmdqu+k/pkFMgkQoa4hCFXbe1OY1eX0aMLoygGGr+Uc9mfT/DGmAf4TeT8V 0UFXI2U0XMRozGDNmAqtEVCZa6nfPSRTUoCiWmQZkm9Zlm+ItvZngsC2a725kvEHRZDK/TW9isM0o w2kL/ONzPK1+2/8X+pqRektby/yBb+Aakxlgqtgqgq36P6UNR4G17WEqcYG1xuZC4ssOO0cfgWr1G JqLEtp5BUrCdCysLg5WSmanEBBbPP9JWubKy2olxqljZZupDMSIBwiWZsZAk0UlmvGQNugYUxoaHN K3z1hRAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qP4IZ-00GyGd-0W; Thu, 27 Jul 2023 16:57:11 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qP4IP-00Gy09-0u; Thu, 27 Jul 2023 16:57:06 +0000 X-UUID: 69d617a42c9c11ee83ed1395ce914268-20230727 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=CS3Hm4ozWdVn8VxCoaqtbrurbs/IDYCI2iODXuClW5M=; b=o2A5bP3mwTvcQuDioA8MVgbj6nLocDyyjeYELlPgBatyIxex8CtI85gL/6IIaiJCJ+vhO3+blrYGBatho9lh2Wh221PZgv3Y5F19eColFdYjtzmEtr/Cdfy23J5Ab7S3tMCgGxvSjGlSDq9CPonR9xQV+9hoQvtqtphVGzlY6OE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.30,REQID:739a2d8c-4e32-48ad-9787-22fb647bf91a,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.30,REQID:739a2d8c-4e32-48ad-9787-22fb647bf91a,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:1fcc6f8,CLOUDID:94728742-d291-4e62-b539-43d7d78362ba,B ulkID:2307280041201EKBPAFQ,BulkQuantity:1,Recheck:0,SF:17|19|48|38|29|28,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_ASC,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_SNR, TF_CID_SPAM_SDM X-UUID: 69d617a42c9c11ee83ed1395ce914268-20230727 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1360793341; Thu, 27 Jul 2023 09:41:19 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 28 Jul 2023 00:41:16 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 28 Jul 2023 00:41:16 +0800 From: Jason-JH.Lin To: Chun-Kuang Hu , AngeloGioacchino Del Regno CC: Matthias Brugger , Jason-ch Chen , Johnson Wang , "Jason-JH . Lin" , Singo Chang , Nancy Lin , Shawn Sung , , , , , Subject: [PATCH v7 2/4] drm/mediatek: Fix using wrong drm private data to bind mediatek-drm Date: Fri, 28 Jul 2023 00:41:12 +0800 Message-ID: <20230727164114.20638-3-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230727164114.20638-1-jason-jh.lin@mediatek.com> References: <20230727164114.20638-1-jason-jh.lin@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230727_095701_449854_845C4E79 X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add checking the length of each data path before assigning drm private data into all_drm_priv array. Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys support") Signed-off-by: Jason-JH.Lin Reviewed-by: CK Hu Reviewed-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 249c9fd6347e..d2fb1fb4e682 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -351,6 +351,7 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev) { struct mtk_drm_private *drm_priv = dev_get_drvdata(dev); struct mtk_drm_private *all_drm_priv[MAX_CRTC]; + struct mtk_drm_private *temp_drm_priv; struct device_node *phandle = dev->parent->of_node; const struct of_device_id *of_id; struct device_node *node; @@ -373,9 +374,18 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev) if (!drm_dev || !dev_get_drvdata(drm_dev)) continue; - all_drm_priv[cnt] = dev_get_drvdata(drm_dev); - if (all_drm_priv[cnt] && all_drm_priv[cnt]->mtk_drm_bound) - cnt++; + temp_drm_priv = dev_get_drvdata(drm_dev); + if (temp_drm_priv) { + if (temp_drm_priv->mtk_drm_bound) + cnt++; + + if (temp_drm_priv->data->main_len) + all_drm_priv[0] = temp_drm_priv; + else if (temp_drm_priv->data->ext_len) + all_drm_priv[1] = temp_drm_priv; + else if (temp_drm_priv->data->third_len) + all_drm_priv[2] = temp_drm_priv; + } } if (drm_priv->data->mmsys_dev_num == cnt) {