Re: [PATCH V8 5/5] drm/mediatek: make implementation of recalc_rate() to match the definition

2019-04-07 Thread CK Hu
Hi, Wangyan:

On Tue, 2019-04-02 at 17:36 +0800, wangyan wang wrote:
> From: Wangyan Wang 
> 
> Recalculate the rate of this clock, by querying hardware to
> make implementation of recalc_rate() to match the definition.
> 
> Signed-off-by: Wangyan Wang 
> ---
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.c|  8 --
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.h|  2 --
>  drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 39 
> +++---
>  drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c |  8 ++
>  4 files changed, 43 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> index fe05aa762107..f753ee72971e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> @@ -15,14 +15,6 @@ static const struct phy_ops mtk_hdmi_phy_dev_ops = {
>   .owner = THIS_MODULE,
>  };
>  
> -unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
> -unsigned long parent_rate)
> -{
> - struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
> -
> - return hdmi_phy->pll_rate;
> -}
> -
>  void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
>u32 bits)
>  {
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> index 86895be0d192..2d8b3182470d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> @@ -49,8 +49,6 @@ void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, 
> u32 offset,
>  void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
>  u32 val, u32 mask);
>  struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw);
> -unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
> -unsigned long parent_rate);
>  
>  extern struct platform_driver mtk_hdmi_phy_driver;
>  extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> index 5f8c2b044034..3bb72ae6a7b5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> @@ -79,7 +79,6 @@ static int mtk_hdmi_pll_prepare(struct clk_hw *hw)
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
>   usleep_range(80, 100);
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
> - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
> @@ -94,7 +93,6 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw)
>   mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK);
>   mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK);
>   mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK);
> - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
>   mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN);
>   usleep_range(80, 100);
>   mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK);
> @@ -123,6 +121,7 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, 
> unsigned long rate,
>  
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_PREDIV_MASK);
>   mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK);
> + mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV);
>   mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IC),
> RG_HTPLL_IC_MASK);
>   mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR),
> @@ -160,6 +159,40 @@ static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, 
> unsigned long rate,
>   return rate;
>  }
>  
> +static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
> +unsigned long parent_rate)

Align the first character to the right of '('.

Regards,
CK

> +{
> + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
> + unsigned long out_rate, val;
> +
> + val = (readl(hdmi_phy->regs + HDMI_CON6)
> + & RG_HTPLL_PREDIV_MASK) >> RG_HTPLL_PREDIV;
> + switch (val) {
> + case 0x00:
> + out_rate = parent_rate;
> + break;
> + case 0x01:
> + out_rate = parent_rate / 2;
> + break;
> + default:
> + out_rate = parent_rate / 4;
> + break;
> + }
> +
> + val = (readl(hdmi_phy->regs + HDMI_CON6)
> + & RG_HTPLL_FBKDIV_MASK) >> RG_HTPLL_FBKDIV;
> + out_rate *= (val + 1) * 2;
> + val = (readl(hdmi_phy->regs + HDMI_CON2)
> +  

Re: [PATCH V8 4/5] drm/mediatek: no change parent rate in round_rate() for mt2701 hdmi phy

2019-04-07 Thread CK Hu
Hi, Wangyan:

On Tue, 2019-04-02 at 17:36 +0800, wangyan wang wrote:
> From: Wangyan Wang 
> 
> This is the third step to make MT2701 HDMI stable.
> We should not change the rate of parent for hdmi phy when
> doing round_rate for this clock. The parent clock of hdmi
> phy must be the same as it. We change it when doing set_rate
> only.
> 
> Signed-off-by: Wangyan Wang 
> ---
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.c| 14 --
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.h|  2 --
>  drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c |  6 ++
>  drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 14 ++
>  4 files changed, 20 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> index 13bbaf997819..fe05aa762107 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> @@ -15,20 +15,6 @@ static const struct phy_ops mtk_hdmi_phy_dev_ops = {
>   .owner = THIS_MODULE,
>  };
>  
> -long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
> -  unsigned long *parent_rate)
> -{
> - struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
> -
> - hdmi_phy->pll_rate = rate;
> - if (rate <= 7425)
> - *parent_rate = rate;
> - else
> - *parent_rate = rate / 2;
> -
> - return rate;
> -}
> -
>  unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
>  unsigned long parent_rate)
>  {
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> index 0045824c1be9..86895be0d192 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> @@ -49,8 +49,6 @@ void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, 
> u32 offset,
>  void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
>  u32 val, u32 mask);
>  struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw);
> -long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
> -  unsigned long *parent_rate);
>  unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw,
>  unsigned long parent_rate);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> index 844e622f052c..5f8c2b044034 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> @@ -154,6 +154,12 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, 
> unsigned long rate,
>   return 0;
>  }
>  
> +static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
> +  unsigned long *parent_rate)

Align the first character to the right of '('.

> +{
> + return rate;

You do not assign hdmi_phy->pll_rate here because you depend on the
patch 'drm/mediatek: make implementation of recalc_rate() to match the
definition', so you should move that patch before this patch.

> +}
> +
>  static const struct clk_ops mtk_hdmi_phy_pll_ops = {
>   .prepare = mtk_hdmi_pll_prepare,
>   .unprepare = mtk_hdmi_pll_unprepare,
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> index f44066875dcd..472d2fda0a03 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> @@ -285,6 +285,20 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, 
> unsigned long rate,
>   return 0;
>  }
>  
> +static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
> +  unsigned long *parent_rate)

Align the first character to the right of '('.

Regards,
CK

> +{
> + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw);
> +
> + hdmi_phy->pll_rate = rate;
> + if (rate <= 7425)
> + *parent_rate = rate;
> + else
> + *parent_rate = rate / 2;
> +
> + return rate;
> +}
> +
>  static const struct clk_ops mtk_hdmi_phy_pll_ops = {
>   .prepare = mtk_hdmi_pll_prepare,
>   .unprepare = mtk_hdmi_pll_unprepare,


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH V8 3/5] drm/mediatek: using new factor for tvdpll in MT2701

2019-04-07 Thread CK Hu
Hi, Wangyan:

On Tue, 2019-04-02 at 17:36 +0800, wangyan wang wrote:
> From: Wangyan Wang 
> 
> This is the second step to make MT2701 HDMI stable.
> The factor depends on the divider of DPI in MT2701, therefore,
> we should fix this factor to the right and new one.

Reviewed-by: CK Hu 

> 
> Signed-off-by: Wangyan Wang 
> ---
>  drivers/gpu/drm/mediatek/mtk_dpi.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c 
> b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 69c6e42dad6b..4a2f4a650494 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -662,13 +662,11 @@ static unsigned int mt8173_calculate_factor(int clock)
>  static unsigned int mt2701_calculate_factor(int clock)
>  {
>   if (clock <= 64000)
> - return 16;
> - else if (clock <= 128000)
> - return 8;
> - else if (clock <= 256000)
>   return 4;
> - else
> + else if (clock <= 128000)
>   return 2;
> + else
> + return 1;
>  }
>  
>  static const struct mtk_dpi_conf mt8173_conf = {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH V8 1/5] drm/mediatek: remove flag CLK_SET_RATE_PARENT for mt2701 hdmi phy to not propagate rate change to parent

2019-04-07 Thread CK Hu
Hi, Wangyan:

On Tue, 2019-04-02 at 17:36 +0800, wangyan wang wrote:
> From: Wangyan Wang 
> 
> This is the first step to make MT2701 hdmi stable.
> The parent rate of hdmi phy had set by DPI driver.
> We should not set or change the parent rate of MT2701 hdmi phy,
> as a result we should remove the flags of "CLK_SET_RATE_PARENT"
> from the clock of MT2701 hdmi phy.
> 
> Signed-off-by: Wangyan Wang 
> ---
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.c| 13 +
>  drivers/gpu/drm/mediatek/mtk_hdmi_phy.h|  1 +
>  drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c |  1 +
>  drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c |  1 +
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> index 4ef9c57ffd44..13bbaf997819 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
> @@ -110,13 +110,11 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy 
> *hdmi_phy)
>   return NULL;
>  }
>  
> -static void mtk_hdmi_phy_clk_get_ops(struct mtk_hdmi_phy *hdmi_phy,
> -  const struct clk_ops **ops)
> +static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
> +  struct clk_init_data *clk_init)

Align the first character to the right of '('.

Regards,
CK

>  {
> - if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops)
> - *ops = hdmi_phy->conf->hdmi_phy_clk_ops;
> - else
> - dev_err(hdmi_phy->dev, "Failed to get clk ops of phy\n");
> + clk_init->flags = hdmi_phy->conf->flags;
> + clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops;
>  }
>  
>  static int mtk_hdmi_phy_probe(struct platform_device *pdev)
> @@ -129,7 +127,6 @@ static int mtk_hdmi_phy_probe(struct platform_device 
> *pdev)
>   struct clk_init_data clk_init = {
>   .num_parents = 1,
>   .parent_names = (const char * const *)_clk_name,
> - .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
>   };
>  
>   struct phy *phy;
> @@ -167,7 +164,7 @@ static int mtk_hdmi_phy_probe(struct platform_device 
> *pdev)
>   hdmi_phy->dev = dev;
>   hdmi_phy->conf =
>   (struct mtk_hdmi_phy_conf *)of_device_get_match_data(dev);
> - mtk_hdmi_phy_clk_get_ops(hdmi_phy, _init.ops);
> + mtk_hdmi_phy_clk_get_data(hdmi_phy, _init);
>   hdmi_phy->pll_hw.init = _init;
>   hdmi_phy->pll = devm_clk_register(dev, _phy->pll_hw);
>   if (IS_ERR(hdmi_phy->pll)) {
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h 
> b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> index f39b1fc66612..0045824c1be9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
> @@ -21,6 +21,7 @@ struct mtk_hdmi_phy;
>  
>  struct mtk_hdmi_phy_conf {
>   bool tz_disabled;
> + unsigned long flags;
>   const struct clk_ops *hdmi_phy_clk_ops;
>   void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
>   void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> index fcc42dc6ea7f..67a814649e19 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
> @@ -202,6 +202,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy 
> *hdmi_phy)
>  
>  struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = {
>   .tz_disabled = true,
> + .flags = CLK_SET_RATE_GATE,
>   .hdmi_phy_clk_ops = _hdmi_phy_pll_ops,
>   .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
>   .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c 
> b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> index ed5916b27658..f44066875dcd 100644
> --- a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> +++ b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
> @@ -309,6 +309,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy 
> *hdmi_phy)
>  }
>  
>  struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = {
> + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
>   .hdmi_phy_clk_ops = _hdmi_phy_pll_ops,
>   .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
>   .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH -next] MAINTAINERS: mark lima mailing list as moderated

2019-04-07 Thread Qiang Yu
Looks good for me, patch is:
Reviewed-by: Qiang Yu 

Should I apply this patch to drm-misc in this case? Or this patch will be
submitted in other kernel tree and back merged to drm-misc?

Regards,
Qiang

On Mon, Apr 8, 2019 at 3:12 AM Randy Dunlap  wrote:
>
> From: Randy Dunlap 
>
> Note that the lima mailing list is moderated.
>
> Signed-off-by: Randy Dunlap 
> Cc: Qiang Yu 
> Cc: dri-devel@lists.freedesktop.org
> Cc: l...@lists.freedesktop.org
> ---
>  MAINTAINERS |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- mmotm-2019-0405-1828.orig/MAINTAINERS
> +++ mmotm-2019-0405-1828/MAINTAINERS
> @@ -5226,7 +5226,7 @@ F:Documentation/devicetree/bindings/dis
>  DRM DRIVERS FOR LIMA
>  M: Qiang Yu 
>  L: dri-devel@lists.freedesktop.org
> -L: l...@lists.freedesktop.org
> +L: l...@lists.freedesktop.org (moderated for non-subscribers)
>  S: Maintained
>  F: drivers/gpu/drm/lima/
>  F: include/uapi/drm/lima_drm.h
>
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [mmotm:master 227/248] lima_gem.c:undefined reference to `vmf_insert_mixed'

2019-04-07 Thread Qiang Yu
Thanks Randy, I can add these.

Where should I send/submit the patch to in this case? Still drm-misc?

Regards,
Qiang


On Mon, Apr 8, 2019 at 3:08 AM Randy Dunlap  wrote:
>
> On 4/5/19 11:47 PM, kbuild test robot wrote:
> > Hi Andrew,
> >
> > It's probably a bug fix that unveils the link errors.
> >
> > tree:   git://git.cmpxchg.org/linux-mmotm.git master
> > head:   b09c000f671826e6f073a7f89b266e4ac998952b
> > commit: 39a08f353e1f30f7ba2e8b751a9034010a99666c [227/248] 
> > linux-next-git-rejects
> > config: sh-allyesconfig (attached as .config)
> > compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> > reproduce:
> > wget 
> > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> > ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > git checkout 39a08f353e1f30f7ba2e8b751a9034010a99666c
> > # save the attached .config to linux build tree
> > GCC_VERSION=7.2.0 make.cross ARCH=sh
> >
> > All errors (new ones prefixed by >>):
> >
> >arch/sh/kernel/cpu/sh2/clock-sh7619.o:(.data+0x1c): undefined reference 
> > to `followparent_recalc'
> >drivers/gpu/drm/lima/lima_gem.o: In function `lima_gem_fault':
> >>> lima_gem.c:(.text+0x6c): undefined reference to `vmf_insert_mixed'
>
>
> vmf_insert_mixed() is only built for MMU configs, and the attached config
> does not set/enable MMU.
> Maybe this driver should depend on MMU, like several other drm drivers do.
>
>
> Also, lima_gem.c needs this line to be added to it:
>
> --- mmotm-2019-0405-1828.orig/drivers/gpu/drm/lima/lima_gem.c
> +++ mmotm-2019-0405-1828/drivers/gpu/drm/lima/lima_gem.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0 OR MIT
>  /* Copyright 2017-2019 Qiang Yu  */
>
> +#include 
>  #include 
>  #include 
>
>
>
> --
> ~Randy
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/vc4: Fix with pm_runtime synchronization on DSI

2019-04-07 Thread Hoegeun Kwon
On 4/2/19 2:48 AM, Eric Anholt wrote:
> Hoegeun Kwon  writes:
>
>> There is a problem when often dpms goes from off to on. pm idle is not
>> in sync and the problem occurs. Modify pm_runtime_put from
>> asynchronous to synchronous.
> Why would we need the power domain to go to off before we try to come
> back?  Any idea?  Also, please specify what "the problem" is.

Hi Eric,


First thank you for your review.

There is a problem failed to runtime PM enable on DSI when often dpms

goes from off to on. The cause of this problem is that when we put pm idle,

I think that there is a timing problem if I do not sync.


Best regards,

Hoegeun


>
>> Signed-off-by: Hoegeun Kwon 
>> ---
>>   drivers/gpu/drm/vc4/vc4_dsi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
>> index 11702e1d9011..b0264c7b8bed 100644
>> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
>> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
>> @@ -822,7 +822,7 @@ static void vc4_dsi_encoder_disable(struct drm_encoder 
>> *encoder)
>>  clk_disable_unprepare(dsi->escape_clock);
>>  clk_disable_unprepare(dsi->pixel_clock);
>>   
>> -pm_runtime_put(dev);
>> +pm_runtime_put_sync(dev);
>>   }
>>   
>>   /* Extends the mode's blank intervals to handle BCM2835's integer-only
>> -- 
>> 2.17.1
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[gabbayo:habanalabs-next 24/32] drivers/misc/habanalabs/habanalabs_ioctl.c:143:10-17: WARNING opportunity for memdup_user

2019-04-07 Thread kbuild test robot
tree:   git://people.freedesktop.org/~gabbayo/linux habanalabs-next
head:   19b649b1933c3ed065426d612345115d15d90f23
commit: e4d7235a3c44a17cb0a70e8dde768b6345ba5dd4 [24/32] habanalabs: add new 
IOCTL for debug, tracing and profiling


coccinelle warnings: (new ones prefixed by >>)

>> drivers/misc/habanalabs/habanalabs_ioctl.c:143:10-17: WARNING opportunity 
>> for memdup_user

vim +143 drivers/misc/habanalabs/habanalabs_ioctl.c

   127  
   128  static int debug_coresight(struct hl_device *hdev, struct hl_debug_args 
*args)
   129  {
   130  struct hl_debug_params *params;
   131  void *input = NULL, *output = NULL;
   132  int rc;
   133  
   134  params = kzalloc(sizeof(*params), GFP_KERNEL);
   135  if (!params)
   136  return -ENOMEM;
   137  
   138  params->reg_idx = args->reg_idx;
   139  params->enable = args->enable;
   140  params->op = args->op;
   141  
   142  if (args->input_ptr && args->input_size) {
 > 143  input = kzalloc(args->input_size, GFP_KERNEL);
   144  if (!input) {
   145  rc = -ENOMEM;
   146  goto out;
   147  }
   148  
   149  if (copy_from_user(input,
   150  (void __user *) (uintptr_t) 
args->input_ptr,
   151  args->input_size)) {
   152  dev_err(hdev->dev,
   153  "copy from user failed in debug 
ioctl\n");
   154  rc = -EFAULT;
   155  goto out;
   156  }
   157  
   158  params->input = input;
   159  }
   160  
   161  if (args->output_ptr && args->output_size) {
   162  output = kzalloc(args->output_size, GFP_KERNEL);
   163  if (!output) {
   164  rc = -ENOMEM;
   165  goto out;
   166  }
   167  
   168  params->output = output;
   169  params->output_size = args->output_size;
   170  }
   171  
   172  rc = hdev->asic_funcs->debug_coresight(hdev, params);
   173  if (rc) {
   174  dev_err(hdev->dev,
   175  "debug coresight operation failed %d\n", rc);
   176  goto out;
   177  }
   178  
   179  if (output) {
   180  if (copy_to_user((void __user *) (uintptr_t) 
args->output_ptr,
   181  output,
   182  args->output_size)) {
   183  dev_err(hdev->dev,
   184  "copy to user failed in debug ioctl\n");
   185  rc = -EFAULT;
   186  goto out;
   187  }
   188  }
   189  
   190  out:
   191  kfree(params);
   192  kfree(output);
   193  kfree(input);
   194  
   195  return rc;
   196  }
   197  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110347] pp_od_clk_voltage mV cap ignored

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110347

--- Comment #3 from bednarczyk.pa...@outlook.com ---
Created attachment 143888
  --> https://bugs.freedesktop.org/attachment.cgi?id=143888=edit
dmesg

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110347] pp_od_clk_voltage mV cap ignored

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110347

--- Comment #2 from bednarczyk.pa...@outlook.com ---
Created attachment 143887
  --> https://bugs.freedesktop.org/attachment.cgi?id=143887=edit
Xorg log

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 12/12] drm/client: Hack: Add bootsplash example

2019-04-07 Thread Noralf Trønnes
An example to showcase the client API.

TODO:
A bootsplash client needs a way to tell drm_fb_helper to stay away,
otherwise it will chime in on setup and hotplug.
Most DRM drivers register fbdev before calling drm_dev_register() (the
generic emulation is an exception). This have to be reversed for
bootsplash to fend off fbdev.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/Kconfig  |   5 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/drm_bootsplash.c | 359 +++
 drivers/gpu/drm/drm_client.c |   7 +
 drivers/gpu/drm/drm_drv.c|   4 +
 include/drm/drm_client.h |   3 +
 6 files changed, 379 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_bootsplash.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 98e9ac8498c0..d61de804068a 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -65,6 +65,11 @@ config DRM_DEBUG_SELFTEST
 
  If in doubt, say "N".
 
+config DRM_CLIENT_BOOTSPLASH
+   bool "DRM Bootsplash"
+   help
+ DRM Bootsplash
+
 config DRM_KMS_HELPER
tristate
depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 08c77c10ccbb..ae42c9a91c57 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -32,6 +32,7 @@ drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
+drm-$(CONFIG_DRM_CLIENT_BOOTSPLASH) += drm_bootsplash.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o 
drm_probe_helper.o \
drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
diff --git a/drivers/gpu/drm/drm_bootsplash.c b/drivers/gpu/drm/drm_bootsplash.c
new file mode 100644
index ..37f3ac3fce95
--- /dev/null
+++ b/drivers/gpu/drm/drm_bootsplash.c
@@ -0,0 +1,359 @@
+/* DRM internal client example */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// drm_lastclose()
+#include "drm_internal.h"
+
+static bool drm_bootsplash_enabled = true;
+module_param_named(bootsplash_enabled, drm_bootsplash_enabled, bool, 0600);
+MODULE_PARM_DESC(bootsplash_enabled, "Enable bootsplash client 
[default=true]");
+
+struct drm_bootsplash {
+   struct drm_client_dev client;
+   struct mutex lock;
+   struct work_struct worker;
+   bool started;
+   bool stop;
+
+   unsigned int modeset_mask;
+   struct drm_client_buffer *buffers[2];
+};
+
+static bool drm_bootsplash_key_pressed;
+
+static int drm_bootsplash_keyboard_notifier_call(struct notifier_block *blk,
+unsigned long code, void 
*_param)
+{
+   /* Any key is good */
+   drm_bootsplash_key_pressed = true;
+
+   return NOTIFY_OK;
+}
+
+static struct notifier_block drm_bootsplash_keyboard_notifier_block = {
+   .notifier_call = drm_bootsplash_keyboard_notifier_call,
+};
+
+static void drm_bootsplash_buffer_delete(struct drm_bootsplash *splash)
+{
+   unsigned int i;
+
+   for (i = 0; i < 2; i++) {
+   if (!IS_ERR_OR_NULL(splash->buffers[i]))
+   drm_client_framebuffer_delete(splash->buffers[i]);
+   splash->buffers[i] = NULL;
+   }
+}
+
+static int drm_bootsplash_buffer_create(struct drm_bootsplash *splash, u32 
width, u32 height)
+{
+   unsigned int i;
+
+   for (i = 0; i < 2; i++) {
+   splash->buffers[i] = 
drm_client_framebuffer_create(>client, width, height, 
DRM_FORMAT_XRGB);
+   if (IS_ERR(splash->buffers[i])) {
+   drm_bootsplash_buffer_delete(splash);
+   return PTR_ERR(splash->buffers[i]);
+   }
+   }
+
+   return 0;
+}
+
+static int drm_bootsplash_display_probe(struct drm_bootsplash *splash)
+{
+   struct drm_client_dev *client = >client;
+   unsigned int width = 0, height = 0;
+   unsigned int num_non_tiled = 0, i;
+   struct drm_mode_set *modeset;
+   bool tiled = false;
+   int ret;
+
+   splash->modeset_mask = 0;
+
+   ret = drm_client_modeset_probe(client, 0, 0);
+   if (ret)
+   return ret;
+
+   mutex_lock(>modeset_mutex);
+
+   drm_client_for_each_modeset(modeset, client) {
+   if (!modeset->mode)
+   continue;
+
+   if (modeset->connectors[0]->has_tile)
+   tiled = true;
+   else
+   num_non_tiled++;
+   }
+
+   if (!tiled && !num_non_tiled) {
+   drm_bootsplash_buffer_delete(splash);
+   ret = -ENOENT;
+   goto out;
+   }
+
+   /* Assume only one tiled monitor is possible */
+   if (tiled) {
+   int hdisplay = 0, vdisplay = 0;
+
+   i = 0;
+ 

[PATCH v2 11/12] drm/fb-helper: Move out modeset config code

2019-04-07 Thread Noralf Trønnes
No functional changes, just moving code as-is and fixing includes.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client_modeset.c | 703 ++-
 drivers/gpu/drm/drm_fb_helper.c  | 692 --
 include/drm/drm_client.h |   4 +-
 3 files changed, 701 insertions(+), 698 deletions(-)

diff --git a/drivers/gpu/drm/drm_client_modeset.c 
b/drivers/gpu/drm/drm_client_modeset.c
index 94b52f97c06b..2a428ac00930 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -13,13 +13,22 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "drm_crtc_internal.h"
 #include "drm_internal.h"
 
+#define DRM_CLIENT_MAX_CLONED_CONNECTORS   8
+
+struct drm_client_offset {
+   int x, y;
+};
+
 /* Used by drm_client and drm_fb_helper */
 int drm_client_modeset_create(struct drm_client_dev *client)
 {
@@ -93,7 +102,8 @@ void drm_client_modeset_release(struct drm_client_dev 
*client)
 }
 EXPORT_SYMBOL(drm_client_modeset_release);
 
-struct drm_mode_set *drm_client_find_modeset(struct drm_client_dev *client, 
struct drm_crtc *crtc)
+static struct drm_mode_set *
+drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc)
 {
struct drm_mode_set *modeset;
 
@@ -103,8 +113,695 @@ struct drm_mode_set *drm_client_find_modeset(struct 
drm_client_dev *client, stru
 
return NULL;
 }
-/* TODO: Remove export when modeset code has been moved over */
-EXPORT_SYMBOL(drm_client_find_modeset);
+
+static struct drm_display_mode *
+drm_connector_has_preferred_mode(struct drm_connector *connector, int width, 
int height)
+{
+   struct drm_display_mode *mode;
+
+   list_for_each_entry(mode, >modes, head) {
+   if (mode->hdisplay > width ||
+   mode->vdisplay > height)
+   continue;
+   if (mode->type & DRM_MODE_TYPE_PREFERRED)
+   return mode;
+   }
+   return NULL;
+}
+
+static struct drm_display_mode *
+drm_connector_pick_cmdline_mode(struct drm_connector *connector)
+{
+   struct drm_cmdline_mode *cmdline_mode;
+   struct drm_display_mode *mode;
+   bool prefer_non_interlace;
+
+   cmdline_mode = >cmdline_mode;
+   if (cmdline_mode->specified == false)
+   return NULL;
+
+   /* attempt to find a matching mode in the list of modes
+*  we have gotten so far, if not add a CVT mode that conforms
+*/
+   if (cmdline_mode->rb || cmdline_mode->margins)
+   goto create_mode;
+
+   prefer_non_interlace = !cmdline_mode->interlace;
+again:
+   list_for_each_entry(mode, >modes, head) {
+   /* check width/height */
+   if (mode->hdisplay != cmdline_mode->xres ||
+   mode->vdisplay != cmdline_mode->yres)
+   continue;
+
+   if (cmdline_mode->refresh_specified) {
+   if (mode->vrefresh != cmdline_mode->refresh)
+   continue;
+   }
+
+   if (cmdline_mode->interlace) {
+   if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
+   continue;
+   } else if (prefer_non_interlace) {
+   if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+   continue;
+   }
+   return mode;
+   }
+
+   if (prefer_non_interlace) {
+   prefer_non_interlace = false;
+   goto again;
+   }
+
+create_mode:
+   mode = drm_mode_create_from_cmdline_mode(connector->dev, cmdline_mode);
+   list_add(>head, >modes);
+
+   return mode;
+}
+
+static bool drm_connector_enabled(struct drm_connector *connector, bool strict)
+{
+   bool enable;
+
+   if (connector->display_info.non_desktop)
+   return false;
+
+   if (strict)
+   enable = connector->status == connector_status_connected;
+   else
+   enable = connector->status != connector_status_disconnected;
+
+   return enable;
+}
+
+static void drm_client_connectors_enabled(struct drm_connector **connectors,
+ unsigned int connector_count,
+ bool *enabled)
+{
+   bool any_enabled = false;
+   struct drm_connector *connector;
+   int i = 0;
+
+   for (i = 0; i < connector_count; i++) {
+   connector = connectors[i];
+   enabled[i] = drm_connector_enabled(connector, true);
+   DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id,
+ connector->display_info.non_desktop ? "non 
desktop" : enabled[i] ? "yes" : "no");
+
+   any_enabled |= enabled[i];
+   }
+
+   if (any_enabled)
+   return;
+
+   for (i = 0; i < connector_count; i++)
+ 

[PATCH v2 10/12] drm/fb-helper: Prepare to move out modeset config code

2019-04-07 Thread Noralf Trønnes
This prepares the modeset code so it can be moved out as-is in the next
patch.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 63 +++--
 include/drm/drm_fb_helper.h |  4 ---
 2 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e13026724b2c..9287ff4ae2d8 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -43,6 +43,10 @@
 
 #include "drm_internal.h"
 
+struct drm_client_offset {
+   int x, y;
+};
+
 static bool drm_fbdev_emulation = true;
 module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
 MODULE_PARM_DESC(fbdev_emulation,
@@ -1794,7 +1798,7 @@ static bool drm_client_target_cloned(struct drm_device 
*dev,
 struct drm_connector **connectors,
 unsigned int connector_count,
 struct drm_display_mode **modes,
-struct drm_fb_offset *offsets,
+struct drm_client_offset *offsets,
 bool *enabled, int width, int height)
 {
int count, i, j;
@@ -1873,7 +1877,7 @@ static bool drm_client_target_cloned(struct drm_device 
*dev,
 static int drm_client_get_tile_offsets(struct drm_connector **connectors,
   unsigned int connector_count,
   struct drm_display_mode **modes,
-  struct drm_fb_offset *offsets,
+  struct drm_client_offset *offsets,
   int idx,
   int h_idx, int v_idx)
 {
@@ -1906,7 +1910,7 @@ static int drm_client_get_tile_offsets(struct 
drm_connector **connectors,
 static bool drm_client_target_preferred(struct drm_connector **connectors,
unsigned int connector_count,
struct drm_display_mode **modes,
-   struct drm_fb_offset *offsets,
+   struct drm_client_offset *offsets,
bool *enabled, int width, int height)
 {
const u64 mask = BIT_ULL(connector_count) - 1;
@@ -2070,7 +2074,7 @@ static bool drm_client_firmware_config(struct 
drm_client_dev *client,
   unsigned int connector_count,
   struct drm_crtc **crtcs,
   struct drm_display_mode **modes,
-  struct drm_fb_offset *offsets,
+  struct drm_client_offset *offsets,
   bool *enabled, int width, int height)
 {
unsigned int count = min_t(unsigned int, connector_count, 
BITS_PER_LONG);
@@ -2239,30 +2243,48 @@ static bool drm_client_firmware_config(struct 
drm_client_dev *client,
return ret;
 }
 
-static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
-   u32 width, u32 height)
+/**
+ * drm_client_modeset_probe() - Probe for displays
+ * @client: DRM client
+ * @width: Maximum display mode width (optional)
+ * @height: Maximum display mode height (optional)
+ *
+ * This function sets up display pipelines for enabled connectors and stores 
the
+ * config in the client's modeset array.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+
+int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int 
width, unsigned int height)
 {
struct drm_connector *connector, **connectors = NULL;
-   struct drm_client_dev *client = _helper->client;
struct drm_connector_list_iter conn_iter;
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = client->dev;
unsigned int total_modes_count = 0;
+   struct drm_client_offset *offsets;
unsigned int connector_count = 0;
struct drm_display_mode **modes;
-   struct drm_fb_offset *offsets;
struct drm_crtc **crtcs;
+   int i, ret = 0;
bool *enabled;
-   int i;
 
DRM_DEBUG_KMS("\n");
 
+   if (!width)
+   width = dev->mode_config.max_width;
+   if (!height)
+   height = dev->mode_config.max_height;
+
drm_connector_list_iter_begin(dev, _iter);
drm_client_for_each_connector_iter(connector, _iter) {
struct drm_connector **tmp;
 
tmp = krealloc(connectors, (connector_count + 1) * 
sizeof(*connectors), GFP_KERNEL);
-   if (!tmp)
+   if (!tmp) {
+   ret = -ENOMEM;
goto free_connectors;
+   }
 
connectors = tmp;

[PATCH v2 08/12] drm/fb-helper: Move out commit code

2019-04-07 Thread Noralf Trønnes
Move the modeset commit code to drm_client_modeset.
No changes except exporting API.

v2: Move to drm_client_modeset.c instead of drm_client.c

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client_modeset.c | 287 +++
 drivers/gpu/drm/drm_fb_helper.c  | 282 --
 include/drm/drm_client.h |   4 +
 3 files changed, 291 insertions(+), 282 deletions(-)

diff --git a/drivers/gpu/drm/drm_client_modeset.c 
b/drivers/gpu/drm/drm_client_modeset.c
index bb34222c9db8..94b52f97c06b 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -11,9 +11,14 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
+
+#include "drm_crtc_internal.h"
+#include "drm_internal.h"
 
 /* Used by drm_client and drm_fb_helper */
 int drm_client_modeset_create(struct drm_client_dev *client)
@@ -100,3 +105,285 @@ struct drm_mode_set *drm_client_find_modeset(struct 
drm_client_dev *client, stru
 }
 /* TODO: Remove export when modeset code has been moved over */
 EXPORT_SYMBOL(drm_client_find_modeset);
+
+/**
+ * drm_client_panel_rotation() - Check panel orientation
+ * @modeset: DRM modeset
+ * @rotation: Returned rotation value
+ *
+ * This function checks if the primary plane in @modeset can hw rotate to match
+ * the panel orientation on its connector.
+ *
+ * Note: Currently only 0 and 180 degrees are supported.
+ *
+ * Return:
+ * True if the plane can do the rotation, false otherwise.
+ */
+bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int 
*rotation)
+{
+   struct drm_connector *connector = modeset->connectors[0];
+   struct drm_plane *plane = modeset->crtc->primary;
+   u64 valid_mask = 0;
+   unsigned int i;
+
+   if (!modeset->num_connectors)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+
+static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, 
bool active)
+{
+   struct drm_device *dev = client->dev;
+   struct drm_plane_state *plane_state;
+   struct drm_plane *plane;
+   struct drm_atomic_state *state;
+   struct drm_modeset_acquire_ctx ctx;
+   struct drm_mode_set *mode_set;
+   int ret;
+
+   drm_modeset_acquire_init(, 0);
+
+   state = drm_atomic_state_alloc(dev);
+   if (!state) {
+   ret = -ENOMEM;
+   goto out_ctx;
+   }
+
+   state->acquire_ctx = 
+retry:
+   drm_for_each_plane(plane, dev) {
+   plane_state = drm_atomic_get_plane_state(state, plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto out_state;
+   }
+
+   plane_state->rotation = DRM_MODE_ROTATE_0;
+
+   /* disable non-primary: */
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+   continue;
+
+   ret = __drm_atomic_helper_disable_plane(plane, plane_state);
+   if (ret != 0)
+   goto out_state;
+   }
+
+   drm_client_for_each_modeset(mode_set, client) {
+   struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
+
+   if (drm_client_panel_rotation(mode_set, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
+
+   ret = __drm_atomic_helper_set_config(mode_set, state);
+   if (ret != 0)
+   goto out_state;
+
+   /*
+* __drm_atomic_helper_set_config() sets active when a
+* mode is set, unconditionally clear it if we force DPMS off
+*/
+   if (!active) {
+   struct drm_crtc 

[PATCH v2 06/12] drm/fb-helper: Remove drm_fb_helper_crtc

2019-04-07 Thread Noralf Trønnes
It now only contains the modeset so use that directly instead and attach
a modeset array to drm_client_dev. drm_fb_helper will use this array.
Code will later be moved to drm_client, so add code there in a new file
drm_client_modeset.c with MIT license to match drm_fb_helper.c.

The modeset connector array size is hardcoded for the cloned case to avoid
having to pass in a value from the driver. A value of 8 is chosen to err
on the safe side. This means that the max connector argument for
drm_fb_helper_init() and drm_fb_helper_fbdev_setup() isn't used anymore,
a todo entry for this is added.

In pan_display_atomic() restore_fbdev_mode_force() is used instead of
restore_fbdev_mode_atomic() because that one will later become internal
to drm_client_modeset.

Locking order:
1. drm_fb_helper->lock
2. drm_master_internal_acquire
3. drm_client_dev->modeset_mutex

v2:
- Add modesets array to drm_client (Daniel Vetter)
- Use a new file for the modeset code (Daniel Vetter)
- File has to be MIT licensed (Emmanuel Vadot)
- Add copyrights from drm_fb_helper.c

Signed-off-by: Noralf Trønnes 
---
 Documentation/gpu/todo.rst   |   7 +
 drivers/gpu/drm/Makefile |   2 +-
 drivers/gpu/drm/drm_client.c |  10 +-
 drivers/gpu/drm/drm_client_modeset.c | 102 +
 drivers/gpu/drm/drm_fb_helper.c  | 301 +++
 include/drm/drm_client.h |  28 +++
 include/drm/drm_fb_helper.h  |   8 -
 7 files changed, 272 insertions(+), 186 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_client_modeset.c

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 1528ad2d598b..8fa08b5feab7 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -300,6 +300,13 @@ it to use drm_mode_hsync() instead.
 
 Contact: Sean Paul
 
+drm_fb_helper cleanup tasks
+---
+
+- The max connector argument for drm_fb_helper_init() and
+  drm_fb_helper_fbdev_setup() isn't used anymore and can be removed.
+
+
 Core refactorings
 =
 
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 6c7e8d162b4e..08c77c10ccbb 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -19,7 +19,7 @@ drm-y   :=drm_auth.o drm_bufs.o drm_cache.o \
drm_plane.o drm_color_mgmt.o drm_print.o \
drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
drm_syncobj.o drm_lease.o drm_writeback.o drm_client.o \
-   drm_atomic_uapi.o
+   drm_client_modeset.o drm_atomic_uapi.o
 
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 9b2bd28dde0a..3ad5b57c1419 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -91,14 +91,20 @@ int drm_client_init(struct drm_device *dev, struct 
drm_client_dev *client,
client->name = name;
client->funcs = funcs;
 
-   ret = drm_client_open(client);
+   ret = drm_client_modeset_create(client);
if (ret)
goto err_put_module;
 
+   ret = drm_client_open(client);
+   if (ret)
+   goto err_free;
+
drm_dev_get(dev);
 
return 0;
 
+err_free:
+   drm_client_modeset_free(client);
 err_put_module:
if (funcs)
module_put(funcs->owner);
@@ -147,6 +153,8 @@ void drm_client_release(struct drm_client_dev *client)
 
DRM_DEV_DEBUG_KMS(dev->dev, "%s\n", client->name);
 
+   drm_client_modeset_release(client);
+   drm_client_modeset_free(client);
drm_client_close(client);
drm_dev_put(dev);
if (client->funcs)
diff --git a/drivers/gpu/drm/drm_client_modeset.c 
b/drivers/gpu/drm/drm_client_modeset.c
new file mode 100644
index ..bb34222c9db8
--- /dev/null
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2018 Noralf Trønnes
+ * Copyright (c) 2006-2009 Red Hat Inc.
+ * Copyright (c) 2006-2008 Intel Corporation
+ *   Jesse Barnes 
+ * Copyright (c) 2007 Dave Airlie 
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* Used by drm_client and drm_fb_helper */
+int drm_client_modeset_create(struct drm_client_dev *client)
+{
+   struct drm_device *dev = client->dev;
+   unsigned int num_crtc = dev->mode_config.num_crtc;
+   unsigned int max_connector_count = 1;
+   struct drm_mode_set *modeset;
+   struct drm_crtc *crtc;
+   unsigned int i = 0;
+
+   /* Add terminating zero entry to enable index less iteration */
+   client->modesets = kcalloc(num_crtc + 1, sizeof(*client->modesets), 
GFP_KERNEL);
+   if (!client->modesets)
+   return -ENOMEM;
+
+   mutex_init(>modeset_mutex);
+
+   drm_for_each_crtc(crtc, dev)
+   client->modesets[i++].crtc = crtc;
+
+   /* Cloning is only 

[PATCH v2 04/12] drm/fb-helper: No need to cache rotation and sw_rotations

2019-04-07 Thread Noralf Trønnes
Getting rotation info is cheap so we can do it on demand.

This is done in preparation for the removal of struct drm_fb_helper_crtc.

Cc: Hans de Goede 
Signed-off-by: Noralf Trønnes 
Acked-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fb_helper.c | 131 
 include/drm/drm_fb_helper.h |   8 --
 2 files changed, 65 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index eda8b63f350d..2f71160cc904 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -388,6 +388,49 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
+/* Check if the plane can hw rotate to match panel orientation */
+static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset,
+unsigned int *rotation)
+{
+   struct drm_connector *connector = modeset->connectors[0];
+   struct drm_plane *plane = modeset->crtc->primary;
+   u64 valid_mask = 0;
+   unsigned int i;
+
+   if (!modeset->num_connectors)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+
 static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
 {
struct drm_device *dev = fb_helper->dev;
@@ -428,10 +471,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
for (i = 0; i < fb_helper->crtc_count; i++) {
struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
 
-   /* Cannot fail as we've already gotten the plane state above */
-   plane_state = drm_atomic_get_new_plane_state(state, primary);
-   plane_state->rotation = fb_helper->crtc_info[i].rotation;
+   if (drm_fb_helper_panel_rotation(mode_set, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
 
ret = __drm_atomic_helper_set_config(mode_set, state);
if (ret != 0)
@@ -871,7 +917,6 @@ int drm_fb_helper_init(struct drm_device *dev,
if (!fb_helper->crtc_info[i].mode_set.connectors)
goto out_free;
fb_helper->crtc_info[i].mode_set.num_connectors = 0;
-   fb_helper->crtc_info[i].rotation = DRM_MODE_ROTATE_0;
}
 
i = 0;
@@ -2500,62 +2545,6 @@ static int drm_pick_crtcs(struct drm_fb_helper 
*fb_helper,
return best_score;
 }
 
-/*
- * This function checks if rotation is necessary because of panel orientation
- * and if it is, if it is supported.
- * If rotation is necessary and supported, it gets set in fb_crtc.rotation.
- * If rotation is necessary but not supported, a DRM_MODE_ROTATE_* flag gets
- * or-ed into fb_helper->sw_rotations. In drm_setup_crtcs_fb() we check if only
- * one bit is set and then we set fb_info.fbcon_rotate_hint to make fbcon do
- * the unsupported rotation.
- */
-static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper,
-   struct drm_fb_helper_crtc *fb_crtc,
-   struct drm_connector *connector)
-{
-   struct drm_plane *plane = fb_crtc->mode_set.crtc->primary;
-   uint64_t valid_mask = 0;
-   int i, rotation;
-
-   fb_crtc->rotation = DRM_MODE_ROTATE_0;
-
-   switch (connector->display_info.panel_orientation) {
-   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
-   rotation = DRM_MODE_ROTATE_180;
-   break;
-   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
-   rotation = DRM_MODE_ROTATE_90;
-   break;
-   case 

[PATCH v2 07/12] drm/fb-helper: Prepare to move out commit code

2019-04-07 Thread Noralf Trønnes
This makes the necessary changes so the commit code can be moved out to
drm_client as-is in the next patch. It's split up to ease review.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 122 +---
 1 file changed, 81 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b65edfc99feb..0229e187e6de 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -388,9 +388,20 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
-/* Check if the plane can hw rotate to match panel orientation */
-static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset,
-unsigned int *rotation)
+/**
+ * drm_client_panel_rotation() - Check panel orientation
+ * @modeset: DRM modeset
+ * @rotation: Returned rotation value
+ *
+ * This function checks if the primary plane in @modeset can hw rotate to match
+ * the panel orientation on its connector.
+ *
+ * Note: Currently only 0 and 180 degrees are supported.
+ *
+ * Return:
+ * True if the plane can do the rotation, false otherwise.
+ */
+bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int 
*rotation)
 {
struct drm_connector *connector = modeset->connectors[0];
struct drm_plane *plane = modeset->crtc->primary;
@@ -431,10 +442,9 @@ static bool drm_fb_helper_panel_rotation(struct 
drm_mode_set *modeset,
return true;
 }
 
-static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
+static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, 
bool active)
 {
-   struct drm_client_dev *client = _helper->client;
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = client->dev;
struct drm_plane_state *plane_state;
struct drm_plane *plane;
struct drm_atomic_state *state;
@@ -474,7 +484,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
struct drm_plane *primary = mode_set->crtc->primary;
unsigned int rotation;
 
-   if (drm_fb_helper_panel_rotation(mode_set, )) {
+   if (drm_client_panel_rotation(mode_set, )) {
/* Cannot fail as we've already gotten the plane state 
above */
plane_state = drm_atomic_get_new_plane_state(state, 
primary);
plane_state->rotation = rotation;
@@ -516,15 +526,14 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
goto retry;
 }
 
-static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
+static int drm_client_modeset_commit_legacy(struct drm_client_dev *client)
 {
-   struct drm_client_dev *client = _helper->client;
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = client->dev;
struct drm_mode_set *mode_set;
struct drm_plane *plane;
int ret = 0;
 
-   drm_modeset_lock_all(fb_helper->dev);
+   drm_modeset_lock_all(dev);
drm_for_each_plane(plane, dev) {
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);
@@ -553,35 +562,53 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
goto out;
}
 out:
-   drm_modeset_unlock_all(fb_helper->dev);
+   drm_modeset_unlock_all(dev);
 
return ret;
 }
 
-static int restore_fbdev_mode_force(struct drm_fb_helper *fb_helper)
+/**
+ * drm_client_modeset_commit_force() - Force commit CRTC configuration
+ * @client: DRM client
+ *
+ * Commit modeset configuration to crtcs without checking if there is a DRM 
master.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+int drm_client_modeset_commit_force(struct drm_client_dev *client)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = client->dev;
int ret;
 
-   mutex_lock(_helper->client.modeset_mutex);
+   mutex_lock(>modeset_mutex);
if (drm_drv_uses_atomic_modeset(dev))
-   ret = restore_fbdev_mode_atomic(fb_helper, true);
+   ret = drm_client_modeset_commit_atomic(client, true);
else
-   ret = restore_fbdev_mode_legacy(fb_helper);
-   mutex_unlock(_helper->client.modeset_mutex);
+   ret = drm_client_modeset_commit_legacy(client);
+   mutex_unlock(>modeset_mutex);
 
return ret;
 }
 
-static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+/**
+ * drm_client_modeset_commit() - Commit CRTC configuration
+ * @client: DRM client
+ *
+ * Commit modeset configuration to crtcs.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+int drm_client_modeset_commit(struct drm_client_dev *client)
 {
-   struct 

[PATCH v2 09/12] drm/fb-helper: Remove drm_fb_helper_connector

2019-04-07 Thread Noralf Trønnes
All drivers add all their connectors so there's no need to keep around an
array of available connectors.

Rename functions which signature is changed since they will be moved to
drm_client in a later patch.

Signed-off-by: Noralf Trønnes 
---

checkpatch complains, but I'm unable to satisfy it:

ERROR: Macros with complex values should be enclosed in parentheses
#941: FILE: include/drm/drm_client.h:181:
+#define drm_client_for_each_connector_iter(connector, iter) \
+   drm_for_each_connector_iter(connector, iter) \
+   if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)

 Documentation/gpu/todo.rst  |   3 +
 drivers/gpu/drm/drm_fb_helper.c | 498 ++--
 include/drm/drm_client.h|  15 +
 include/drm/drm_fb_helper.h |  80 ++---
 4 files changed, 192 insertions(+), 404 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 8fa08b5feab7..f6cdd1c26788 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -306,6 +306,9 @@ drm_fb_helper cleanup tasks
 - The max connector argument for drm_fb_helper_init() and
   drm_fb_helper_fbdev_setup() isn't used anymore and can be removed.
 
+- The helper doesn't keep an array of connectors anymore so these can be
+  removed: drm_fb_helper_single_add_all_connectors(),
+  drm_fb_helper_add_one_connector() and drm_fb_helper_remove_one_connector().
 
 Core refactorings
 =
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 73fbcd748ddd..e13026724b2c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -90,12 +90,6 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * Setup fbdev emulation by calling drm_fb_helper_fbdev_setup() and tear it
  * down by calling drm_fb_helper_fbdev_teardown().
  *
- * Drivers that need to handle connector hotplugging (e.g. dp mst) can't use
- * the setup helper and will need to do the whole four-step setup process with
- * drm_fb_helper_prepare(), drm_fb_helper_init(),
- * drm_fb_helper_single_add_all_connectors(), enable hotplugging and
- * drm_fb_helper_initial_config() to avoid a possible race window.
- *
  * At runtime drivers should restore the fbdev console by using
  * drm_fb_helper_lastclose() as their _driver.lastclose callback.
  * They should also notify the fb helper code from updates to the output
@@ -118,8 +112,7 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * encoders and connectors. To finish up the fbdev helper initialization, the
  * drm_fb_helper_init() function is called. To probe for all attached displays
  * and set up an initial configuration using the detected hardware, drivers
- * should call drm_fb_helper_single_add_all_connectors() followed by
- * drm_fb_helper_initial_config().
+ * should call drm_fb_helper_initial_config().
  *
  * If _framebuffer_funcs.dirty is set, the
  * drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit} functions will
@@ -132,165 +125,6 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * deferred I/O (coupled with drm_fb_helper_fbdev_teardown()).
  */
 
-#define drm_fb_helper_for_each_connector(fbh, i__) \
-   for (({ lockdep_assert_held(&(fbh)->lock); }), \
-i__ = 0; i__ < (fbh)->connector_count; i__++)
-
-static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
-struct drm_connector *connector)
-{
-   struct drm_fb_helper_connector *fb_conn;
-   struct drm_fb_helper_connector **temp;
-   unsigned int count;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   lockdep_assert_held(_helper->lock);
-
-   count = fb_helper->connector_count + 1;
-
-   if (count > fb_helper->connector_info_alloc_count) {
-   size_t size = count * sizeof(fb_conn);
-
-   temp = krealloc(fb_helper->connector_info, size, GFP_KERNEL);
-   if (!temp)
-   return -ENOMEM;
-
-   fb_helper->connector_info_alloc_count = count;
-   fb_helper->connector_info = temp;
-   }
-
-   fb_conn = kzalloc(sizeof(*fb_conn), GFP_KERNEL);
-   if (!fb_conn)
-   return -ENOMEM;
-
-   drm_connector_get(connector);
-   fb_conn->connector = connector;
-   fb_helper->connector_info[fb_helper->connector_count++] = fb_conn;
-
-   return 0;
-}
-
-int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
-   struct drm_connector *connector)
-{
-   int err;
-
-   if (!fb_helper)
-   return 0;
-
-   mutex_lock(_helper->lock);
-   err = __drm_fb_helper_add_one_connector(fb_helper, connector);
-   mutex_unlock(_helper->lock);
-
-   return err;
-}
-EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
-
-/**
- * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev
- *emulation 

[PATCH v2 05/12] drm/fb-helper: Remove drm_fb_helper_crtc->{x, y, desired_mode}

2019-04-07 Thread Noralf Trønnes
The values are already present in the modeset.

This is done in preparation for the removal of struct drm_fb_helper_crtc.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fb_helper.c | 12 
 include/drm/drm_fb_helper.h |  2 --
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2f71160cc904..69dddc4a9231 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2021,16 +2021,16 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
 */
bool lastv = true, lasth = true;
 
-   desired_mode = fb_helper->crtc_info[i].desired_mode;
mode_set = _helper->crtc_info[i].mode_set;
+   desired_mode = mode_set->mode;
 
if (!desired_mode)
continue;
 
crtc_count++;
 
-   x = fb_helper->crtc_info[i].x;
-   y = fb_helper->crtc_info[i].y;
+   x = mode_set->x;
+   y = mode_set->y;
 
sizes.surface_width  = max_t(u32, desired_mode->hdisplay + x, 
sizes.surface_width);
sizes.surface_height = max_t(u32, desired_mode->vdisplay + y, 
sizes.surface_height);
@@ -2803,11 +2803,7 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
DRM_DEBUG_KMS("desired mode %s set on crtc %d 
(%d,%d)\n",
  mode->name, 
fb_crtc->mode_set.crtc->base.id, offset->x, offset->y);
 
-   fb_crtc->desired_mode = mode;
-   fb_crtc->x = offset->x;
-   fb_crtc->y = offset->y;
-   modeset->mode = drm_mode_duplicate(dev,
-  
fb_crtc->desired_mode);
+   modeset->mode = drm_mode_duplicate(dev, mode);
drm_connector_get(connector);
modeset->connectors[modeset->num_connectors++] = 
connector;
modeset->x = offset->x;
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index d954f48c9636..0d6d23a15b42 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -48,8 +48,6 @@ struct drm_fb_offset {
 
 struct drm_fb_helper_crtc {
struct drm_mode_set mode_set;
-   struct drm_display_mode *desired_mode;
-   int x, y;
 };
 
 /**
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 00/12] drm/fb-helper: Move modesetting code to drm_client

2019-04-07 Thread Noralf Trønnes
This moves the modesetting code from drm_fb_helper to drm_client so it
can be shared by all internal clients.

The main change this time is to attach the modeset array to
drm_client_dev and honour the drm_fb_helper MIT license. I've dropped
the display abstraction.

Noralf.

Cc: Emmanuel Vadot 

Noralf Trønnes (12):
  drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
  drm/fb-helper: Avoid race with DRM userspace
  drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
  drm/fb-helper: No need to cache rotation and sw_rotations
  drm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode}
  drm/fb-helper: Remove drm_fb_helper_crtc
  drm/fb-helper: Prepare to move out commit code
  drm/fb-helper: Move out commit code
  drm/fb-helper: Remove drm_fb_helper_connector
  drm/fb-helper: Prepare to move out modeset config code
  drm/fb-helper: Move out modeset config code
  drm/client: Hack: Add bootsplash example

 Documentation/gpu/todo.rst   |   10 +
 drivers/gpu/drm/Kconfig  |5 +
 drivers/gpu/drm/Makefile |3 +-
 drivers/gpu/drm/drm_atomic.c |  168 
 drivers/gpu/drm/drm_atomic_helper.c  |  164 
 drivers/gpu/drm/drm_auth.c   |   20 +
 drivers/gpu/drm/drm_bootsplash.c |  359 
 drivers/gpu/drm/drm_client.c |   17 +-
 drivers/gpu/drm/drm_client_modeset.c | 1086 +++
 drivers/gpu/drm/drm_crtc_internal.h  |5 +
 drivers/gpu/drm/drm_drv.c|4 +
 drivers/gpu/drm/drm_fb_helper.c  | 1195 +++---
 drivers/gpu/drm/drm_internal.h   |2 +
 drivers/gpu/drm/i915/intel_fbdev.c   |  218 -
 include/drm/drm_atomic_helper.h  |4 -
 include/drm/drm_client.h |   48 ++
 include/drm/drm_fb_helper.h  |  125 +--
 17 files changed, 1859 insertions(+), 1574 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_bootsplash.c
 create mode 100644 drivers/gpu/drm/drm_client_modeset.c

-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 03/12] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper

2019-04-07 Thread Noralf Trønnes
It is generic code and having it in the helper will let other drivers
benefit from it.

One change was necessary assuming this to be true:
INTEL_INFO(dev_priv)->num_pipes == dev->mode_config.num_crtc

Suggested-by: Daniel Vetter 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: intel-...@lists.freedesktop.org
Signed-off-by: Noralf Trønnes 
Reviewed-by: Jani Nikula 
---
 drivers/gpu/drm/drm_fb_helper.c| 194 -
 drivers/gpu/drm/i915/intel_fbdev.c | 218 -
 include/drm/drm_fb_helper.h|  23 ---
 3 files changed, 190 insertions(+), 245 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a6be09ae899b..eda8b63f350d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2556,6 +2556,194 @@ static void drm_setup_crtc_rotation(struct 
drm_fb_helper *fb_helper,
fb_helper->sw_rotations |= DRM_MODE_ROTATE_0;
 }
 
+static struct drm_fb_helper_crtc *
+drm_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
+{
+   int i;
+
+   for (i = 0; i < fb_helper->crtc_count; i++)
+   if (fb_helper->crtc_info[i].mode_set.crtc == crtc)
+   return _helper->crtc_info[i];
+
+   return NULL;
+}
+
+/* Try to read the BIOS display configuration and use it for the initial 
config */
+static bool drm_fb_helper_firmware_config(struct drm_fb_helper *fb_helper,
+ struct drm_fb_helper_crtc **crtcs,
+ struct drm_display_mode **modes,
+ struct drm_fb_offset *offsets,
+ bool *enabled, int width, int height)
+{
+   struct drm_device *dev = fb_helper->dev;
+   unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
+   unsigned long conn_configured, conn_seq;
+   int i, j;
+   bool *save_enabled;
+   bool fallback = true, ret = true;
+   int num_connectors_enabled = 0;
+   int num_connectors_detected = 0;
+   struct drm_modeset_acquire_ctx ctx;
+
+   save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL);
+   if (!save_enabled)
+   return false;
+
+   drm_modeset_acquire_init(, 0);
+
+   while (drm_modeset_lock_all_ctx(dev, ) != 0)
+   drm_modeset_backoff();
+
+   memcpy(save_enabled, enabled, count);
+   conn_seq = GENMASK(count - 1, 0);
+   conn_configured = 0;
+retry:
+   for (i = 0; i < count; i++) {
+   struct drm_fb_helper_connector *fb_conn;
+   struct drm_connector *connector;
+   struct drm_encoder *encoder;
+   struct drm_fb_helper_crtc *new_crtc;
+
+   fb_conn = fb_helper->connector_info[i];
+   connector = fb_conn->connector;
+
+   if (conn_configured & BIT(i))
+   continue;
+
+   /* First pass, only consider tiled connectors */
+   if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile)
+   continue;
+
+   if (connector->status == connector_status_connected)
+   num_connectors_detected++;
+
+   if (!enabled[i]) {
+   DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
+ connector->name);
+   conn_configured |= BIT(i);
+   continue;
+   }
+
+   if (connector->force == DRM_FORCE_OFF) {
+   DRM_DEBUG_KMS("connector %s is disabled by user, 
skipping\n",
+ connector->name);
+   enabled[i] = false;
+   continue;
+   }
+
+   encoder = connector->state->best_encoder;
+   if (!encoder || WARN_ON(!connector->state->crtc)) {
+   if (connector->force > DRM_FORCE_OFF)
+   goto bail;
+
+   DRM_DEBUG_KMS("connector %s has no encoder or crtc, 
skipping\n",
+ connector->name);
+   enabled[i] = false;
+   conn_configured |= BIT(i);
+   continue;
+   }
+
+   num_connectors_enabled++;
+
+   new_crtc = drm_fb_helper_crtc(fb_helper, 
connector->state->crtc);
+
+   /*
+* Make sure we're not trying to drive multiple connectors
+* with a single CRTC, since our cloning support may not
+* match the BIOS.
+*/
+   for (j = 0; j < count; j++) {
+   if (crtcs[j] == new_crtc) {
+   DRM_DEBUG_KMS("fallback: cloned 
configuration\n");
+   goto bail;
+   }
+  

[PATCH v2 02/12] drm/fb-helper: Avoid race with DRM userspace

2019-04-07 Thread Noralf Trønnes
drm_fb_helper_is_bound() is used to check if DRM userspace is in control.
This is done by looking at the fb on the primary plane. By the time
fb-helper gets around to committing, it's possible that the facts have
changed.

Avoid this race by holding the drm_device->master_mutex lock while
committing. When DRM userspace does its first open, it will now wait
until fb-helper is done. The helper will stay away if there's a master.

Locking rule: Always take the fb-helper lock first.

v2:
- Remove drm_fb_helper_is_bound() (Daniel Vetter)
- No need to check fb_helper->dev->master in
  drm_fb_helper_single_fb_probe(), restore_fbdev_mode() has the check.

Suggested-by: Daniel Vetter 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_auth.c  | 20 
 drivers/gpu/drm/drm_fb_helper.c | 90 -
 drivers/gpu/drm/drm_internal.h  |  2 +
 3 files changed, 67 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 1669c42c40ed..db199807b7dc 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master)
*master = NULL;
 }
 EXPORT_SYMBOL(drm_master_put);
+
+/* Used by drm_client and drm_fb_helper */
+bool drm_master_internal_acquire(struct drm_device *dev)
+{
+   mutex_lock(>master_mutex);
+   if (dev->master) {
+   mutex_unlock(>master_mutex);
+   return false;
+   }
+
+   return true;
+}
+EXPORT_SYMBOL(drm_master_internal_acquire);
+
+/* Used by drm_client and drm_fb_helper */
+void drm_master_internal_release(struct drm_device *dev)
+{
+   mutex_unlock(>master_mutex);
+}
+EXPORT_SYMBOL(drm_master_internal_release);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 84791dd4a90d..a6be09ae899b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -44,6 +44,7 @@
 
 #include "drm_crtc_internal.h"
 #include "drm_crtc_helper_internal.h"
+#include "drm_internal.h"
 
 static bool drm_fbdev_emulation = true;
 module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
@@ -509,7 +510,7 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
return ret;
 }
 
-static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+static int restore_fbdev_mode_force(struct drm_fb_helper *fb_helper)
 {
struct drm_device *dev = fb_helper->dev;
 
@@ -519,6 +520,21 @@ static int restore_fbdev_mode(struct drm_fb_helper 
*fb_helper)
return restore_fbdev_mode_legacy(fb_helper);
 }
 
+static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+{
+   struct drm_device *dev = fb_helper->dev;
+   int ret;
+
+   if (!drm_master_internal_acquire(dev))
+   return -EBUSY;
+
+   ret = restore_fbdev_mode_force(fb_helper);
+
+   drm_master_internal_release(dev);
+
+   return ret;
+}
+
 /**
  * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration
  * @fb_helper: driver-allocated fbdev helper, can be NULL
@@ -556,34 +572,6 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
 
-static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
-{
-   struct drm_device *dev = fb_helper->dev;
-   struct drm_crtc *crtc;
-   int bound = 0, crtcs_bound = 0;
-
-   /*
-* Sometimes user space wants everything disabled, so don't steal the
-* display if there's a master.
-*/
-   if (READ_ONCE(dev->master))
-   return false;
-
-   drm_for_each_crtc(crtc, dev) {
-   drm_modeset_lock(>mutex, NULL);
-   if (crtc->primary->fb)
-   crtcs_bound++;
-   if (crtc->primary->fb == fb_helper->fb)
-   bound++;
-   drm_modeset_unlock(>mutex);
-   }
-
-   if (bound < crtcs_bound)
-   return false;
-
-   return true;
-}
-
 #ifdef CONFIG_MAGIC_SYSRQ
 /*
  * restore fbcon display for all kms driver's using this helper, used for sysrq
@@ -604,7 +592,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue;
 
mutex_lock(>lock);
-   ret = restore_fbdev_mode(helper);
+   ret = restore_fbdev_mode_force(helper);
if (ret)
error = true;
mutex_unlock(>lock);
@@ -663,20 +651,22 @@ static void dpms_legacy(struct drm_fb_helper *fb_helper, 
int dpms_mode)
 static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 {
struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
 
/*
 * For each CRTC in this fb, turn the connectors on/off.
 */
mutex_lock(_helper->lock);
-   if (!drm_fb_helper_is_bound(fb_helper)) {
-   

[PATCH v2 01/12] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()

2019-04-07 Thread Noralf Trønnes
Prepare for moving drm_fb_helper modesetting code to drm_client.
drm_client will be linked to drm.ko, so move
__drm_atomic_helper_disable_plane() and __drm_atomic_helper_set_config()
out of drm_kms_helper.ko.

While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesis

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_atomic.c| 168 
 drivers/gpu/drm/drm_atomic_helper.c | 164 ---
 drivers/gpu/drm/drm_crtc_internal.h |   5 +
 include/drm/drm_atomic_helper.h |   4 -
 4 files changed, 173 insertions(+), 168 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 5eb40130fafb..c3a9ffbf2310 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct 
drm_atomic_state *state)
 }
 EXPORT_SYMBOL(drm_atomic_nonblocking_commit);
 
+/* just used from drm-client and atomic-helper: */
+int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
+ struct drm_plane_state *plane_state)
+{
+   int ret;
+
+   ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+   if (ret != 0)
+   return ret;
+
+   drm_atomic_set_fb_for_plane(plane_state, NULL);
+   plane_state->crtc_x = 0;
+   plane_state->crtc_y = 0;
+   plane_state->crtc_w = 0;
+   plane_state->crtc_h = 0;
+   plane_state->src_x = 0;
+   plane_state->src_y = 0;
+   plane_state->src_w = 0;
+   plane_state->src_h = 0;
+
+   return 0;
+}
+EXPORT_SYMBOL(__drm_atomic_helper_disable_plane);
+
+static int update_output_state(struct drm_atomic_state *state,
+  struct drm_mode_set *set)
+{
+   struct drm_device *dev = set->crtc->dev;
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *new_crtc_state;
+   struct drm_connector *connector;
+   struct drm_connector_state *new_conn_state;
+   int ret, i;
+
+   ret = drm_modeset_lock(>mode_config.connection_mutex,
+  state->acquire_ctx);
+   if (ret)
+   return ret;
+
+   /* First disable all connectors on the target crtc. */
+   ret = drm_atomic_add_affected_connectors(state, set->crtc);
+   if (ret)
+   return ret;
+
+   for_each_new_connector_in_state(state, connector, new_conn_state, i) {
+   if (new_conn_state->crtc == set->crtc) {
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   NULL);
+   if (ret)
+   return ret;
+
+   /* Make sure legacy setCrtc always re-trains */
+   new_conn_state->link_status = DRM_LINK_STATUS_GOOD;
+   }
+   }
+
+   /* Then set all connectors from set->connectors on the target crtc */
+   for (i = 0; i < set->num_connectors; i++) {
+   new_conn_state = drm_atomic_get_connector_state(state,
+   
set->connectors[i]);
+   if (IS_ERR(new_conn_state))
+   return PTR_ERR(new_conn_state);
+
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   set->crtc);
+   if (ret)
+   return ret;
+   }
+
+   for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+   /*
+* Don't update ->enable for the CRTC in the set_config request,
+* since a mismatch would indicate a bug in the upper layers.
+* The actual modeset code later on will catch any
+* inconsistencies here.
+*/
+   if (crtc == set->crtc)
+   continue;
+
+   if (!new_crtc_state->connector_mask) {
+   ret = drm_atomic_set_mode_prop_for_crtc(new_crtc_state,
+   NULL);
+   if (ret < 0)
+   return ret;
+
+   new_crtc_state->active = false;
+   }
+   }
+
+   return 0;
+}
+
+/* just used from drm-client and atomic-helper: */
+int __drm_atomic_helper_set_config(struct drm_mode_set *set,
+  struct drm_atomic_state *state)
+{
+   struct drm_crtc_state *crtc_state;
+   struct drm_plane_state *primary_state;
+   struct drm_crtc *crtc = set->crtc;
+   int hdisplay, vdisplay;
+   int ret;
+
+   crtc_state = drm_atomic_get_crtc_state(state, crtc);
+   if (IS_ERR(crtc_state))
+   return PTR_ERR(crtc_state);
+
+   primary_state = 

[Bug 109887] vega56 undervolting/overclocking voltage issues

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109887

--- Comment #5 from bednarczyk.pa...@outlook.com ---
Did you manage to get this resolved. I have the same issue and in my case
setting P6 = P7 Frequency, the memory clock gets stuck at P0 167 Mhz. I tried
5.1 RC-3 but no joy either.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110347] pp_od_clk_voltage mV cap ignored

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110347

--- Comment #1 from bednarczyk.pa...@outlook.com ---
I am able to work around the voltage issue by setting P6 frequency = P7
Frequency. In this case the voltage sits at the pre-defined value of 950mV, but
I run into another problem. Memory Pstate is stuck at 0 (167 MHZ) so the
overall performance goes down significantly. It seems there's an issue when the
card goes into P7 with respect to voltages.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110347] pp_od_clk_voltage mV cap ignored

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110347

Bug ID: 110347
   Summary: pp_od_clk_voltage mV cap ignored
   Product: DRI
   Version: XOrg git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: DRM/AMDgpu
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: bednarczyk.pa...@outlook.com

Hi all,

I have a Gigabyte Radeon RX Vega 64 GAMING OC 8GB and I have been playing with
undervolting/overclocking the card for a better performance/power draw ratio.

I have set the voltages/frequency as follows:
https://gist.github.com/Bednar87/e4fea34b03b96b2833e2900d3405 with voltage
capped @ 950V

Now of course prior to doing that I added the amdgpu.ppffeaturemask parameter
to the boot line with value 0xfffd7fff.

Looking at sudo watch -n 0.5 cat /sys/kernel/debug/dri/0/amdgpu_pm_info shows
that the voltage is at 1200mV (VDDGFX). The power draw is also not reduced as
one could expect from undervolting the clocks but instead shoots up to 320W and
maintains this value under stress (50% power limit was also enabled). 

The frequency on the clocks seems to work fine and the settings seem to be
honoured but the voltage value seems to be ignored.

cat /sys/class/drm/card0/device/pp_od_clk_voltage

OD_SCLK:
0:852Mhz800mV
1:991Mhz825mV
2:   1084Mhz850mV
3:   1138Mhz875mV
4:   1250Mhz900mV
5:   1370Mhz925mV
6:   1475Mhz950mV
7:   1575Mhz950mV
OD_MCLK:
0:167Mhz800mV
1:500Mhz825mV
2:800Mhz865mV
3:   1050Mhz950mV
OD_RANGE:
SCLK: 852MHz   2400MHz
MCLK: 167MHz   1500MHz
VDDC: 800mV1200mV

I am on Arch Linux kernel 5.0.6 MESA 19.0.1

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v4] dt-bindings: gpu: add bindings for the ARM Mali Bifrost GPU

2019-04-07 Thread Neil Armstrong
Hi Rob,

Le 01/04/2019 13:24, Neil Armstrong a écrit :
> On 01/04/2019 12:00, Steven Price wrote:
>> On 01/04/2019 09:09, Neil Armstrong wrote:
>>> Add the bindings for the Bifrost family of ARM Mali GPUs.
>>>
>>> The Bifrost GPU architecture is similar to the Midgard family,
>>> but with a different Shader Core & Execution Engine structures.
>>>
>>> Bindings are based on the Midgard family bindings, but the inner
>>> architectural changes makes it a separate family needing separate
>>> bindings.
>>>
>>> The Bifrost GPUs are present in a number of recent SoCs, like the
>>> Amlogic G12A Family, and many other vendors.
>>> The Amlogic vendor specific compatible is added to handle the
>>> specific IP integration differences and dependencies.
>>>
>>> Signed-off-by: Neil Armstrong 
>>> ---
>>>  .../bindings/gpu/arm,mali-bifrost.txt | 92 +++
>>>  1 file changed, 92 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/gpu/arm,mali-bifrost.txt
>>>
>>> Changes since v3:
>>> - Added note about discoverable model/revision
>>> - Enforced fixed defined irq order
>>> - Fixed typo in accommodate
>>>
>>> Changes since v2:
>>> - moved to a single compatible since HW is fully discoverable
>>>
>>> diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.txt 
>>> b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.txt
>>> new file mode 100644
>>> index ..711c9ead17a2
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.txt
>>> @@ -0,0 +1,92 @@
>>> +ARM Mali Bifrost GPU
>>> +
>>> +
>>> +Required properties:
>>> +
>>> +- compatible :
>>> +  * Since Mali Bifrost GPU model/revision if fully discoverable by reading
>>  ^^
>> s/if/is/

Should I still send a v5 to fixing this typo ? I can fix it while applying it.

Neil

> 
> Thanks for pointing this.
> 
>>
>>> +some determined registers, must contain the following:
>>> ++ "arm,mali-bifrost"
>>> +  * which must be preceded by one of the following vendor specifics:
>>> ++ "amlogic,meson-g12a-mali"
>>> +
>>> +- reg : Physical base address of the device and length of the register 
>>> area.
>>> +
>>> +- interrupts : Contains the three IRQ lines required by Mali Bifrost 
>>> devices,
>>> +  in the following defined order.
>>> +
>>> +- interrupt-names : Contains the names of IRQ resources in this exact 
>>> defined
>>> +  order: "job", "mmu", "gpu".
>>
>> Is there any point in having "interrupt-names" if we're fixing the
>> order? Although I guess it helps match the Midgard bindings.
> 
> Exact.
> 
> Neil
> 
>>
>> Steve
>>
>>> +
>>> +Optional properties:
>>> +
>>> +- clocks : Phandle to clock for the Mali Bifrost device.
>>> +
>>> +- mali-supply : Phandle to regulator for the Mali device. Refer to
>>> +  Documentation/devicetree/bindings/regulator/regulator.txt for details.
>>> +
>>> +- operating-points-v2 : Refer to 
>>> Documentation/devicetree/bindings/opp/opp.txt
>>> +  for details.
>>> +
>>> +- resets : Phandle of the GPU reset line.
>>> +
>>> +Vendor-specific bindings
>>> +
>>> +
>>> +The Mali GPU is integrated very differently from one SoC to
>>> +another. In order to accommodate those differences, you have the option
>>> +to specify one more vendor-specific compatible, among:
>>> +
>>> +- "amlogic,meson-g12a-mali"
>>> +  Required properties:
>>> +  - resets : Should contain phandles of :
>>> ++ GPU reset line
>>> ++ GPU APB glue reset line
>>> +
>>> +Example for a Mali-G31:
>>> +
>>> +gpu@ffa3 {
>>> +   compatible = "amlogic,meson-g12a-mali", "arm,mali-bifrost";
>>> +   reg = <0xffe4 0x1>;
>>> +   interrupts = ,
>>> +,
>>> +;
>>> +   interrupt-names = "job", "mmu", "gpu";
>>> +   clocks = < CLKID_MALI>;
>>> +   mali-supply = <_gpu>;
>>> +   operating-points-v2 = <_opp_table>;
>>> +   resets = < RESET_DVALIN_CAPB3>, < RESET_DVALIN>;
>>> +};
>>> +
>>> +gpu_opp_table: opp_table0 {
>>> +   compatible = "operating-points-v2";
>>> +
>>> +   opp@53300 {
>>> +   opp-hz = /bits/ 64 <53300>;
>>> +   opp-microvolt = <125>;
>>> +   };
>>> +   opp@45000 {
>>> +   opp-hz = /bits/ 64 <45000>;
>>> +   opp-microvolt = <115>;
>>> +   };
>>> +   opp@4 {
>>> +   opp-hz = /bits/ 64 <4>;
>>> +   opp-microvolt = <1125000>;
>>> +   };
>>> +   opp@35000 {
>>> +   opp-hz = /bits/ 64 <35000>;
>>> +   opp-microvolt = <1075000>;
>>> +   };
>>> +   opp@26600 {
>>> +   opp-hz = /bits/ 64 <26600>;
>>> +   opp-microvolt = <1025000>;
>>> +   };
>>> +   opp@16000 {
>>> +   opp-hz = /bits/ 64 <16000>;
>>> +   opp-microvolt = <925000>;
>>> +   };
>>> +   opp@1 {
>>> +   opp-hz = /bits/ 64 <1>;
>>> +   opp-microvolt = <912500>;
>>> +   };
>>> +};
>>>
>>
>