Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1502220rwd; Tue, 13 Jun 2023 09:57:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SR4MNFMiuK70gdWMgwoN+w/9Xgi2FINQhMfXaOclbLAPSwjg2QhZ64tyceXyokz9Bo5Nq X-Received: by 2002:a05:6a00:1d24:b0:653:791b:d326 with SMTP id a36-20020a056a001d2400b00653791bd326mr19069790pfx.1.1686675438235; Tue, 13 Jun 2023 09:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686675438; cv=none; d=google.com; s=arc-20160816; b=Ds/gtbhPsLy/+t2ZY729fyQBEG2X5sjdB0T0U5S7qeVsdxrbWUEMnLYvgIIj51BPjY as2tqbdwJmaK3IfMoTWSShuP7Ytrx5s1tPLZg9ZvNgeogW1pTJpsuvTuEls3md/R1Q4u trJstTDqOBem0H64q1MutkNT1bCTTFtk4qwNgKAdec8SphQMPjuHrsk1+y5jfPD+a2zk Le+Z6q1LKigH0EbPHdewLpNr3fZDRpH6G5d0TMmUa9poc3606S/rVPo6o0ogix1n3pZi kZPzks8x3y4ZfVo5sVLmj26YJUp/OzIHmZrBmJp8/1iD6zZWZfyHWbEf2xXLS9Gwj21E D/8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XfqpkM01/8dpD3Pp3+L6rRC1aBBh3fc8rWIqv7GNVqs=; b=MiT64xW/MFno6FUZH9esraUNk9l5H61I2FY2RhG1m72lHGN9zRVze3aarj/nynnXra cVoSzzsqUGnqgH7vPCwhHUYam0JsCz54czv+nBalHlTAoh+RfWflWoHIxUcyDHSEi8Z6 gI5w1Zbyex16VYWJPO+IBRFWPFUI8tsEBXniNqznjRtcWvSs+Qzrs2pldw91tygfxuw3 YHgCeVlcma8JP9YBmbQ30RCYRy6RCyDdLFNPcZuW1FHws6ntHwmxHbkaifx2EihWvCeh tW3OyaozsP/c4igBqJ/Fy3DT0g6knwJFOP+RsIDpZmb1E6ArqY7MmpY9yqp6r2yDwt/x 8Mnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tVbpwH2f; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a63b250000000b00517f7c24652si6073655pgo.890.2023.06.13.09.57.05; Tue, 13 Jun 2023 09:57:18 -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=@kernel.org header.s=k20201202 header.b=tVbpwH2f; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241271AbjFMQEM (ORCPT + 99 others); Tue, 13 Jun 2023 12:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243010AbjFMQEB (ORCPT ); Tue, 13 Jun 2023 12:04:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0EF172A; Tue, 13 Jun 2023 09:03:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BE07B63805; Tue, 13 Jun 2023 16:03:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6505EC4AF5C; Tue, 13 Jun 2023 16:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686672237; bh=hRs/09I3nVePGyq7+ZAJUlWdpGWIbMI1XEr6/Yow+u8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tVbpwH2fLHIWbej7jYshdnJlpjWYAHpIevTgNAUXsmMojFrbopyryR+rfDUL8xCv1 /X96DIpLwGVYwA9TQPDXiz5IWgsOEPpoHu9Qb7yYylwZyRSU2GXXbqK4P6BSZ4uwv1 qVGi9XqLxwx35wynCx2Qvsnm3jgctojsLBxG/O+7c8FnkGePCFlMH27pUGGAHjo9y9 zR+HJHoMVB1dd4NOoHwvZ5E0EAvHUR9Fwf76b/ER8ZhpuSz8miIPlaMasDVR5sTZPI cWGnxa0BQnrC1BULZIN4vUjbBFGUN9oKFlTk6O0llidTzw5w5qgMWGpQuAAMI9UqxY 62P++rDdTFT+A== Date: Tue, 13 Jun 2023 09:07:20 -0700 From: Bjorn Andersson To: Dmitry Baryshkov Cc: Bjorn Andersson , Rob Clark , Abhinav Kumar , Marijn Suijten , Konrad Dybcio , Jessica Zhang , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/msm/dpu: Configure DP INTF/PHY selector Message-ID: <20230613160720.2a6ouut5qn3cewqd@ripper> References: <20230612221047.1886709-1-quic_bjorande@quicinc.com> <435dd068-fbf2-10cf-4f78-377e689abb2c@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <435dd068-fbf2-10cf-4f78-377e689abb2c@linaro.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, Jun 13, 2023 at 01:31:40AM +0300, Dmitry Baryshkov wrote: > On 13/06/2023 01:10, Bjorn Andersson wrote: > > From: Bjorn Andersson > > > > Some platforms provides a mechanism for configuring the mapping between > > (one or two) DisplayPort intfs and their PHYs. > > > > In particular SC8180X provides this functionality, without a default > > configuration, resulting in no connection between its two external > > DisplayPort controllers and any PHYs. > > > > The change implements the logic for optionally configuring which phy > > each of the intfs should be connected to, provides a new entry in the > > DPU catalog for specifying how many intfs to configure and marks the > > SC8180X DPU to program 2 entries. > > > > For now the request is simply to program the mapping 1:1, any support > > for alternative mappings is left until the use case arrise. > > > > Note that e.g. msm-4.14 unconditionally maps intf 0 to phy 0 on all > > rlatforms, so perhaps this is needed in order to get DisplayPort working > > on some other platforms as well. > > > > Signed-off-by: Bjorn Andersson > > Signed-off-by: Bjorn Andersson > > --- > > .../msm/disp/dpu1/catalog/dpu_5_1_sc8180x.h | 1 + > > .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 2 ++ > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c | 23 +++++++++++++++++++ > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h | 8 +++++++ > > drivers/gpu/drm/msm/disp/dpu1/dpu_hwio.h | 1 + > > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 10 ++++++++ > > 6 files changed, 45 insertions(+) > > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_1_sc8180x.h b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_1_sc8180x.h > > index 8ed2b263c5ea..9da952692a69 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_1_sc8180x.h > > +++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_1_sc8180x.h > > @@ -19,6 +19,7 @@ static const struct dpu_caps sc8180x_dpu_caps = { > > .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE, > > .max_hdeci_exp = MAX_HORZ_DECIMATION, > > .max_vdeci_exp = MAX_VERT_DECIMATION, > > + .num_dp_intf_sel = 2, > > }; > > static const struct dpu_ubwc_cfg sc8180x_ubwc_cfg = { > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > index ac4a9e73705c..4cb8d096d8ec 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > @@ -357,6 +357,7 @@ struct dpu_rotation_cfg { > > * @pixel_ram_size size of latency hiding and de-tiling buffer in bytes > > * @max_hdeci_exp max horizontal decimation supported (max is 2^value) > > * @max_vdeci_exp max vertical decimation supported (max is 2^value) > > + * @num_dp_intf_sel number of DP intfs to configure PHY selection for > > */ > > struct dpu_caps { > > u32 max_mixer_width; > > @@ -371,6 +372,7 @@ struct dpu_caps { > > u32 pixel_ram_size; > > u32 max_hdeci_exp; > > u32 max_vdeci_exp; > > + u32 num_dp_intf_sel; > > }; > > /** > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c > > index 963bdb5e0252..5afa99cb148c 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c > > @@ -250,6 +250,27 @@ static void dpu_hw_intf_audio_select(struct dpu_hw_mdp *mdp) > > DPU_REG_WRITE(c, HDMI_DP_CORE_SELECT, 0x1); > > } > > +static void dpu_hw_dp_phy_intf_sel(struct dpu_hw_mdp *mdp, unsigned int *phys, > > + unsigned int num_intfs) > > +{ > > + struct dpu_hw_blk_reg_map *c = &mdp->hw; > > + unsigned int intf; > > + u32 sel = 0; > > + > > + if (!num_intfs) > > + return; > > + > > + for (intf = 0; intf < num_intfs; intf++) { > > + /* Specify the PHY (1-indexed) for @intf */ > > + sel |= (phys[intf] + 1) << (intf * 3); > > + > > + /* Specify the @intf (1-indexed) of targeted PHY */ > > + sel |= (intf + 1) << (6 + phys[intf] * 3); > > From what I can see, phys[intf] is const. What about defining indexed masks > instead? > intf is the loop variable. What am I missing? > > + } > > + > > + DPU_REG_WRITE(c, DP_PHY_INTF_SEL, sel); > > +} > > + > > static void _setup_mdp_ops(struct dpu_hw_mdp_ops *ops, > > unsigned long cap) > > { > > @@ -264,6 +285,8 @@ static void _setup_mdp_ops(struct dpu_hw_mdp_ops *ops, > > ops->get_safe_status = dpu_hw_get_safe_status; > > + ops->dp_phy_intf_sel = dpu_hw_dp_phy_intf_sel; > > Should this be gated for DPU < 4.0? Or 5.0? > > > + > > if (cap & BIT(DPU_MDP_AUDIO_SELECT)) > > ops->intf_audio_select = dpu_hw_intf_audio_select; > > } > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h > > index a1a9e44bed36..8446d74d59b0 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h > > @@ -125,6 +125,14 @@ struct dpu_hw_mdp_ops { > > void (*get_safe_status)(struct dpu_hw_mdp *mdp, > > struct dpu_danger_safe_status *status); > > + /** > > + * dp_phy_intf_sel - configure intf to phy mapping > > + * @mdp: mdp top context driver > > + * @phys: list of phys the @num_intfs intfs should be connected to > > + * @num_intfs: number of intfs to configure > > + */ > > + void (*dp_phy_intf_sel)(struct dpu_hw_mdp *mdp, unsigned int *phys, > > + unsigned int num_intfs); > > /** > > * intf_audio_select - select the external interface for audio > > * @mdp: mdp top context driver > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hwio.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hwio.h > > index 5acd5683d25a..6d31bdc7269c 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hwio.h > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hwio.h > > @@ -59,6 +59,7 @@ > > #define MDP_WD_TIMER_4_CTL2 0x444 > > #define MDP_WD_TIMER_4_LOAD_VALUE 0x448 > > #define DCE_SEL 0x450 > > +#define DP_PHY_INTF_SEL 0x460 > > MDP_DP_PHY_INTF_SEL, if you don't mind. > I don't mind. > > #define MDP_PERIPH_TOP0 MDP_WD_TIMER_0_CTL > > #define MDP_PERIPH_TOP0_END CLK_CTRL3 > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > > index aa8499de1b9f..5dbe5d164c01 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > > @@ -1011,6 +1011,14 @@ unsigned long dpu_kms_get_clk_rate(struct dpu_kms *dpu_kms, char *clock_name) > > return clk_get_rate(clk); > > } > > +static void dpu_kms_dp_phy_intf_sel(struct dpu_kms *dpu_kms) > > +{ > > + const unsigned int num_intfs = dpu_kms->catalog->caps->num_dp_intf_sel; > > + static unsigned int phy_map[] = {0, 1, 2}; > > Please move this to dp_phy_intf_sel() and make it const. > There's a possible use case for passing a phy_map of {0, 2} or {2, 1} on SC8180X. While this is left to someone in the future to have that use case, as split dp_phy_intf_sel() would handle such variations. That said, per the layout of the DP_PHY_INTF_SEL, num_intfs can not be more than 2, so this list shouldn't have 3 elements. Regards, Bjorn > > + > > + dpu_kms->hw_mdp->ops.dp_phy_intf_sel(dpu_kms->hw_mdp, phy_map, num_intfs); > > +} > > + > > static int dpu_kms_hw_init(struct msm_kms *kms) > > { > > struct dpu_kms *dpu_kms; > > @@ -1122,6 +1130,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms) > > goto perf_err; > > } > > + dpu_kms_dp_phy_intf_sel(dpu_kms); > > + > > dpu_kms->hw_intr = dpu_hw_intr_init(dpu_kms->mmio, dpu_kms->catalog); > > if (IS_ERR_OR_NULL(dpu_kms->hw_intr)) { > > rc = PTR_ERR(dpu_kms->hw_intr); > > -- > With best wishes > Dmitry >