Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5316220ybc; Wed, 27 Nov 2019 02:06:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzvjyyb+i8zKcHUVpkYQHFe2/87yFMhfYR5MxJgxyPqLeKAozeV9yW4GSB/BPNY2ZP6yUui X-Received: by 2002:a17:906:234e:: with SMTP id m14mr46634428eja.94.1574849166641; Wed, 27 Nov 2019 02:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574849166; cv=none; d=google.com; s=arc-20160816; b=mD1msVog13gH5zTyEYAe+phkuC2yex8S4CZHHur8nhe1ziu9Nc0NVn6xoMsOsRLxsF z03HxeUJMiLsnbvJFnr47ULETRuNTn07NRCs8s4Ya93writfbL9yknf0CHJh/2DpTAw7 TlIOWYMRLxKV2iDlDr/H6vr4dEZm8oeFwR6RM0vXJYU9VvPWt0FZjAFrzVEIaEqfr6Y6 WBcVJnJLrQxKvMpSDYRl3YKt5jW/tBetEiSX0Egl6z4Y8OeTRPch0HbCbcLS9WmJenYY 0rYC5GoyWVtD5zsjraLrfBmZ0hDJ20S8mVQR56/cGra8OMXIt6yGMQaxL3LPCYSmuPSc p9YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=Fla0mLE3kPARMpuw52rBb145CpRIcrUfv5y6FZzfYow=; b=VX9ks0Xjugm2XrhXt6eo2c+2hVXG3FSf64IDa0kAjyXaO8tSOEpx+90gtUtIrUlQ+J 0LRQ2X+Idky2jXiqCitvSDJsxl9vncFAPdjW+bxgTZxp1SpB6gLzUNiA2RlibDmiAMrR SbYW4mVG15/gx81rv2Px7IaIxcsN5Kjl9QCM6Ym/mePgf0ISoGSVXHLOqRnODM+Afgmq Kh2bpnxVvVMbiXVXis4jToJOxlSHFi6lKHXsJfn/FIDSQNxmQMOBTRal0xiUut3kt1zr VphfzrF14Bp8+h9a1qv59XZhkxMVNAfbGTS1gMs4G2VAUXFPn7FoPuYVpHx/DMinvGar qHww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b="RwOyeu/b"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si9327444ejn.212.2019.11.27.02.05.41; Wed, 27 Nov 2019 02:06:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b="RwOyeu/b"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726537AbfK0KE2 (ORCPT + 99 others); Wed, 27 Nov 2019 05:04:28 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45728 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfK0KE2 (ORCPT ); Wed, 27 Nov 2019 05:04:28 -0500 Received: by mail-pg1-f193.google.com with SMTP id k1so10539613pgg.12 for ; Wed, 27 Nov 2019 02:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Fla0mLE3kPARMpuw52rBb145CpRIcrUfv5y6FZzfYow=; b=RwOyeu/bPVGltW59qJ4ylCblmR5cOGkzUq9UNiaKHpWvfQPMChAxhON+4bSUJovU8n zUPQsv3tpq+x4Lwhx4KaW+DIEzK+DzY9Kc7Cg5Lh4sj0Tgu9zIi8ibZ8YPn58QTJuUO+ G4lekg7BfIooWsOH7uQR0q7Y9LKF4gHyFwK9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Fla0mLE3kPARMpuw52rBb145CpRIcrUfv5y6FZzfYow=; b=mVA9+6X0yREkS3Z9Nr7IaD/AZeL2O0x86nRjv3lRkd4XfZ4hah1rqTuRApROxEneo2 0iRtzvsePGImBT16LqsHunTq/wKx9zHxjxeA8D8KfLAzZTuqm7GmIgLLYL9gTFli7gxA SZCLc38dc9rfxndtTO1ahBHMr2uRglYEVmHZVehZkj4KFIL8BuThh3a2uQI4hJpT1ga5 /Nh2FS8YiPxQkBOxzVEz+CjzIiAlJx1L4UZNAQMInIYa/iGGgYA+lHYK6mjLnzbUK8rl E0gCThKSvcsZB2HdnEDqpNY/+d+4BbalRUVZaOd/UrwPWcLAMVcvimfj9GAaR0IoZDiU w+Fg== X-Gm-Message-State: APjAAAUmT3HHThC1WUpSYz7XkqxCFOnOI6Gd74SMk5C+1xutRnPNvoOp hAMfBJJYaeBeQak8hKgs6Cde/Q== X-Received: by 2002:a65:4809:: with SMTP id h9mr3814513pgs.265.1574849067339; Wed, 27 Nov 2019 02:04:27 -0800 (PST) Received: from pihsun-z840.tpe.corp.google.com ([2401:fa00:1:10:7889:7a43:f899:134c]) by smtp.googlemail.com with ESMTPSA id n18sm16063907pff.152.2019.11.27.02.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 02:04:26 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Yongqiang Niu , CK Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , Sean Paul , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR MEDIATEK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/mediatek: Fix can't get component for external display plane. Date: Wed, 27 Nov 2019 18:04:19 +0800 Message-Id: <20191127100419.130300-1-pihsun@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yongqiang Niu The original logic is ok for primary display, but will not find out component for external display. For example, plane->index is 6 for external display, but there are only 2 layer nr in external display, and this condition will never happen: if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) Fix this by using the offset of the plane to mtk_crtc->planes as index, instead of plane->index. Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a plane") Signed-off-by: Yongqiang Niu Signed-off-by: Pi-Hsun Shih --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index f80a8ba75977..b34e7d70702a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -215,11 +215,12 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc, struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); struct mtk_ddp_comp *comp; int i, count = 0; + unsigned int local_index = plane - mtk_crtc->planes; for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { comp = mtk_crtc->ddp_comp[i]; - if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) { - *local_layer = plane->index - count; + if (local_index < (count + mtk_ddp_comp_layer_nr(comp))) { + *local_layer = local_index - count; return comp; } count += mtk_ddp_comp_layer_nr(comp); base-commit: 1875ff320f14afe21731a6e4c7b46dd33e45dfaa -- 2.24.0.393.g34dc348eaf-goog