Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3702624iog; Tue, 21 Jun 2022 04:19:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1turMNxh7I3EWCms32obtQdCvLH0KZNi3urIDo3+7DNxhiNPQCw+rzN/ESdIZn6xzTCPbdV X-Received: by 2002:a63:7c49:0:b0:40c:b3f9:18c5 with SMTP id l9-20020a637c49000000b0040cb3f918c5mr9521574pgn.588.1655810386178; Tue, 21 Jun 2022 04:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655810386; cv=none; d=google.com; s=arc-20160816; b=EvxhOAydpO/rHXT8bjJwVOALF7tCJFtn1qPBwuy4cVuURlOF5n6NYFdIg8T9FIJIIl 8cxS3jxgQBGG8+TnvRigPIO+ZGAxllQlvuugRZsU5bZNFqdkne1pwgZ81aYhcMN3dCqw S1/E+kVicCSqC2D8RI4UKLMxYzLSnlucIboGAYinArkJVYvwpRYKMn3oNPNECHdJKhY1 HArY7AMDhflTufp5cDhsVJFOXjg7OEHtYv3jXB16IUlp/i73hbCHDnLhBEoDOpCbLz7r y0VTtoYyypPDFrXeFHCQQK46yYjxb+Ub5/r6R96YxCRA9znP0hwEL16af6BKobh1oxpZ uwMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9qa1MQsdjtp0OEX63gPYIUdKxF/75S2mxsehPpdr6gY=; b=SGump8YdbA23VPqSlxDENcKrSQ2YKPbBQixtmTzP3+WnLzxKgreubzCl12XMvfJ5TU ub3euXNBu4mCrclKYUdOHSjuK2nlC0sfmpiKO58kT/4on0LfWjbzCwh+Xkhw9RhMpoQS aZNloq4zUBVSyIuZsT3muB84hvSURqVglgTg8dNsNYZ3MFmzUvwzwRTj3hVWP6oQtXR0 QCIDrq6rTE0EjMcC0tPv1XfJNt+UGdaIZSaA2Z8D6ZP5CF98SxNSUFst8EZiBhR2xFvu M2NZR8cCED/n+F/UKHcIQf6Iw5EKGzQK6YBoIrQGlPpxFTuMdCnEog9snsn4HVTj+Lwu nDUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l6NGbdp4; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902a5c900b00163dc4774b9si14236196plq.39.2022.06.21.04.19.25; Tue, 21 Jun 2022 04:19:46 -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=@linaro.org header.s=google header.b=l6NGbdp4; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348842AbiFULNG (ORCPT + 99 others); Tue, 21 Jun 2022 07:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348275AbiFULMv (ORCPT ); Tue, 21 Jun 2022 07:12:51 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145C429C9C for ; Tue, 21 Jun 2022 04:12:49 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id c144so9716425qkg.11 for ; Tue, 21 Jun 2022 04:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9qa1MQsdjtp0OEX63gPYIUdKxF/75S2mxsehPpdr6gY=; b=l6NGbdp4FKgTJV9bvxCF+EY/e18GEajW6uYOe172nIpRGpI9MAJlvER6aKZcAPH1vx tqYuoMRyhxog/HbuYMoRJkVNHrpmDj/flJseuG7qmds/cwGcZdnYTgiejUbpLBb+2bfk 9qGIZfD0/x74wCAluBB1HQz6FT/yP4xsV/qzUex1Vn4Gz2HbEYt+ML44shsG+rWdQioW jI5UlxcEkTA6LJqclPrkxDpljoFxKJbpk7dJ/k1DKhbfvnrn04Tb20cJuxhUH56g/CF1 cVM4WmoIMf9b9dd8UXBry8HuoVsSj0nMEI8nt6qy+P6DE7mrj0hu1Y93s40qZ6S0eb4X LQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9qa1MQsdjtp0OEX63gPYIUdKxF/75S2mxsehPpdr6gY=; b=JpSsJt7Di9ygZveSaPHkePaoIsji/QwkxJR7s+/RS6GTk7o9/xYHmDrwOzhJegC8ZJ KJBOiloFFd66+jkhQ4uGWmtm1Eckdi4koDErE2OLhe4r+3z4Er3lDWDHgDaVcrZiHVYH uQh+4I/2aZB6VxDx+6L2UUROIP47o4vvuOSTzDzRFk3z6Lk60mZBDDgQjD8n0ZVMmNme 5ntZONyztzr6NjkQYm8bo55E9p73RTui/LYVZ4cBZjgQoSZO40JQKXT1TH6fX2cfG3N4 6TgYLNsODHOL672NGeKqN3KeojaJSxhBytpYWNae6XgFbmQgEp7Y17g6XN2SUZdz1uYf w6Qw== X-Gm-Message-State: AJIora92vgwwFWTMjjOyDuIKiz+6pZGcfP3Sml+pvuFxRzq2Q7rrgpq2 TSvHxlDpOGdlI1AQYgce6ZjP6Kb4YvcJLUFR6QbniQ== X-Received: by 2002:a05:620a:4305:b0:6a9:3829:c03 with SMTP id u5-20020a05620a430500b006a938290c03mr19272968qko.363.1655809968124; Tue, 21 Jun 2022 04:12:48 -0700 (PDT) MIME-Version: 1.0 References: <1655802387-15275-1-git-send-email-quic_kalyant@quicinc.com> <1655802387-15275-2-git-send-email-quic_kalyant@quicinc.com> In-Reply-To: <1655802387-15275-2-git-send-email-quic_kalyant@quicinc.com> From: Dmitry Baryshkov Date: Tue, 21 Jun 2022 14:12:36 +0300 Message-ID: Subject: Re: [v1 2/2] drm/msm/disp/dpu1: enable crtc color management based on encoder topology To: Kalyan Thota Cc: y@qualcomm.com, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, robdclark@gmail.com, dianders@chromium.org, swboyd@chromium.org, quic_vpolimer@quicinc.com, quic_abhinavk@quicinc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Generic comment: y@qualcomm.com address bounces. Please remove it from the cc list. If you need to send a patch for the internal reasons, please use Bcc. On Tue, 21 Jun 2022 at 12:06, Kalyan Thota wrote: > > Crtc color management needs to be registered only for the crtc which has the > capability to handle it. Since topology decides which encoder will get the > dspp hw block, tie up the crtc and the encoder together (encoder->possible_crtcs) > > Change-Id: If5a0f33547b6f527ca4b8fbb78424b141dbbd711 No change-id's please. This is not the gerrit. > Signed-off-by: Kalyan Thota > --- > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 8 ++++++-- > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 +- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 20 ++++++++++++++++---- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 5 +++++ > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 22 ++++++++++++++++++---- > 5 files changed, 46 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > index 7763558..2913acb 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > @@ -1511,7 +1511,7 @@ static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = { > > /* initialize crtc */ > struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane, > - struct drm_plane *cursor) > + struct drm_plane *cursor, unsigned int enc_mask) > { > struct drm_crtc *crtc = NULL; > struct dpu_crtc *dpu_crtc = NULL; > @@ -1544,7 +1544,11 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane, > > drm_crtc_helper_add(crtc, &dpu_crtc_helper_funcs); > > - drm_crtc_enable_color_mgmt(crtc, 0, true, 0); > + /* Register crtc color management if the encoder has dspp, use the > + * crtc to mark it as possible_crtcs for that encoder. > + */ > + if(BIT(crtc->index) & enc_mask) So, we are checking CRTC's index against the encoder's mask? This is counterintuitive. > + drm_crtc_enable_color_mgmt(crtc, 0, true, 0); > > /* save user friendly CRTC name for later */ > snprintf(dpu_crtc->name, DPU_CRTC_NAME_SIZE, "crtc%u", crtc->base.id); > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h > index b8785c3..0a6458e 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h > @@ -269,7 +269,7 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc); > * @Return: new crtc object or error > */ > struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane, > - struct drm_plane *cursor); > + struct drm_plane *cursor, unsigned int enc_mask); > > /** > * dpu_crtc_register_custom_event - api for enabling/disabling crtc event > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > index f2cb497..893ce68 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > @@ -13,6 +13,8 @@ > #include > #include > #include > +#include > +#include > > #include "msm_drv.h" > #include "dpu_kms.h" > @@ -511,13 +513,18 @@ void dpu_encoder_helper_split_config( > } > } > > -static struct msm_display_topology dpu_encoder_get_topology( > - struct dpu_encoder_virt *dpu_enc, > +struct msm_display_topology dpu_encoder_get_topology( > + struct drm_encoder *drm_enc, > struct dpu_kms *dpu_kms, > struct drm_display_mode *mode) > { > struct msm_display_topology topology = {0}; > + struct dpu_encoder_virt *dpu_enc; > + struct drm_bridge *bridge; > int i, intf_count = 0; > + bool primary_display = false; > + > + dpu_enc = to_dpu_encoder_virt(drm_enc); > > for (i = 0; i < MAX_PHYS_ENCODERS_PER_VIRTUAL; i++) > if (dpu_enc->phys_encs[i]) > @@ -542,7 +549,12 @@ static struct msm_display_topology dpu_encoder_get_topology( > else > topology.num_lm = (mode->hdisplay > MAX_HDISPLAY_SPLIT) ? 2 : 1; > > - if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) { > + drm_for_each_bridge_in_chain(drm_enc, bridge) { > + if (bridge->type != DRM_MODE_CONNECTOR_DisplayPort) > + primary_display = true; > + } I must admit, I never actually liked the original (intf_type == DSI) check. However the new one is even worse. We are checking the whole bridge chain in an attempt to rule out the DP ports for whatever reason. What about the HDMI ports? Should they be also frowned upon? The ugly part is that we are making the decision for the user, which displays are "primary" for him. Can we let the user make this setting? > + > + if (primary_display) { > if (dpu_kms->catalog->dspp && > (dpu_kms->catalog->dspp_count >= topology.num_lm)) > topology.num_dspp = topology.num_lm; > @@ -601,7 +613,7 @@ static int dpu_encoder_virt_atomic_check( > } > } > > - topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode); > + topology = dpu_encoder_get_topology(drm_enc, dpu_kms, adj_mode); extra whitespace change. Please drop. > > /* Reserve dynamic resources now. */ > if (!ret) { > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > index 1f39327..c4daf7c 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > @@ -172,4 +172,9 @@ int dpu_encoder_get_vsync_count(struct drm_encoder *drm_enc); > > bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc); > > +struct msm_display_topology dpu_encoder_get_topology( > + struct drm_encoder *drm_enc, > + struct dpu_kms *dpu_kms, > + struct drm_display_mode *mode); > + > #endif /* __DPU_ENCODER_H__ */ > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > index 3a4da0d..486ff9d 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > @@ -687,9 +687,12 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) > unsigned cursor_idx = 0; > unsigned primary_idx = 0; > bool pin_overlays; > + unsigned int max_dspp_count = 0; > + unsigned int enc_mask = 0; > > struct msm_drm_private *priv; > struct dpu_mdss_cfg *catalog; > + struct msm_display_topology topology = {0}; > > int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret; > int max_crtc_count; > @@ -754,10 +757,19 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) > } > > max_crtc_count = min(max_crtc_count, primary_planes_idx); > + max_dspp_count = catalog->dspp_count; > + > + drm_for_each_encoder(encoder, dev) { > + topology = dpu_encoder_get_topology(encoder, dpu_kms, NULL); This can crash dpu_encoder_get_topology() because it checks mode->hdisplay. And the check anyway is futile here. We do not know if the encoder is going to use 1 or 2 LMs (since we do not know the resolution), so we do not know whether it will use 1 or 2 DSPP blocks. > + if (topology.num_dspp > 0 && (topology.num_dspp <= max_dspp_count)) { > + enc_mask |= BIT(encoder->index); > + max_dspp_count -= topology.num_dspp; > + } > + } > > /* Create one CRTC per encoder */ > for (i = 0; i < max_crtc_count; i++) { > - crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]); > + crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i], enc_mask); > if (IS_ERR(crtc)) { > ret = PTR_ERR(crtc); > return ret; > @@ -765,9 +777,11 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) > priv->crtcs[priv->num_crtcs++] = crtc; > } > > - /* All CRTCs are compatible with all encoders */ > - drm_for_each_encoder(encoder, dev) > - encoder->possible_crtcs = (1 << priv->num_crtcs) - 1; > + /* Attach CRTC's to compatiable encoders */ compatible > + drm_for_each_encoder(encoder, dev) { > + encoder->possible_crtcs = (enc_mask & BIT(encoder->index)) ? > + BIT(encoder->index) : (((1 << priv->num_crtcs) - 1) & ~enc_mask); > + } > > return 0; > } > -- > 2.7.4 > -- With best wishes Dmitry