From: Sebastian Reichel Subject: Re: [PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Date: Mon, 16 Oct 2017 10:39:19 +0200 Message-ID: <20171016083919.xypzkrok5gxtknfs@earth> References: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> <20171013145944.26557-23-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0458150513==" Return-path: Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id C25D36E2E6 for ; Mon, 16 Oct 2017 08:39:23 +0000 (UTC) In-Reply-To: <20171013145944.26557-23-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart Cc: Tomi Valkeinen , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0458150513== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="x3u55hw5vz5fi7g2" Content-Disposition: inline --x3u55hw5vz5fi7g2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Oct 13, 2017 at 05:59:18PM +0300, Laurent Pinchart wrote: > To prepare for the removal of the global variable storing DSS private > data, pass its pointer to the dss_runtime_{get,put}() functions. >=20 > As this requires getting hold of the DSS private structure in the > callers, we expose the structure through an opaque pointer that can be > retrieved through a new dss_device_get() function. The function > currently returns a pointer to the global data structure, and will later > be updated to get the pointer from device driver data when the DSS > private structure will be allocated dynamically. >=20 > Signed-off-by: Laurent Pinchart > --- Reviewed-by: Sebastian Reichel -- Sebastian > drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++++-- > drivers/gpu/drm/omapdrm/dss/dss.c | 37 ++++++++++++++++++++-------= ------ > drivers/gpu/drm/omapdrm/dss/dss.h | 13 ++++++++---- > drivers/gpu/drm/omapdrm/dss/hdmi.h | 6 ++++-- > drivers/gpu/drm/omapdrm/dss/hdmi4.c | 3 ++- > drivers/gpu/drm/omapdrm/dss/hdmi5.c | 3 ++- > drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 10 +++++---- > drivers/gpu/drm/omapdrm/dss/video-pll.c | 12 ++++++----- > 8 files changed, 58 insertions(+), 33 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/= dss/dsi.c > index a64e6a39ebf1..1dab308c9bc1 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dsi.c > +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c > @@ -5333,7 +5333,8 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw= =3D { > .has_refsel =3D true, > }; > =20 > -static int dsi_init_pll_data(struct platform_device *dsidev) > +static int dsi_init_pll_data(struct dss_device *dss, > + struct platform_device *dsidev) > { > struct dsi_data *dsi =3D dsi_get_dsidrv_data(dsidev); > struct dss_pll *pll =3D &dsi->pll; > @@ -5352,6 +5353,7 @@ static int dsi_init_pll_data(struct platform_device= *dsidev) > pll->base =3D dsi->pll_base; > pll->hw =3D dsi->data->pll_hw; > pll->ops =3D &dsi_pll_ops; > + pll->dss =3D dss; > =20 > r =3D dss_pll_register(pll); > if (r) > @@ -5428,6 +5430,7 @@ static const struct soc_device_attribute dsi_soc_de= vices[] =3D { > static int dsi_bind(struct device *dev, struct device *master, void *dat= a) > { > struct platform_device *dsidev =3D to_platform_device(dev); > + struct dss_device *dss =3D dss_get_device(master); > const struct soc_device_attribute *soc; > const struct dsi_module_id_data *d; > u32 rev; > @@ -5538,7 +5541,7 @@ static int dsi_bind(struct device *dev, struct devi= ce *master, void *data) > if (r) > return r; > =20 > - dsi_init_pll_data(dsidev); > + dsi_init_pll_data(dss, dsidev); > =20 > pm_runtime_enable(&dsidev->dev); > =20 > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/= dss/dss.c > index b45641f6a844..a83277ebe1ef 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dss.c > +++ b/drivers/gpu/drm/omapdrm/dss/dss.c > @@ -93,7 +93,7 @@ struct dss_features { > bool has_lcd_clk_src; > }; > =20 > -static struct { > +struct dss_device { > struct platform_device *pdev; > struct omap_drm_private drm; > =20 > @@ -125,7 +125,9 @@ static struct { > =20 > struct dss_pll *video1_pll; > struct dss_pll *video2_pll; > -} dss; > +}; > + > +static struct dss_device dss; > =20 > static const char * const dss_generic_clk_source_names[] =3D { > [DSS_CLK_SRC_FCK] =3D "FCK", > @@ -382,7 +384,7 @@ static void dss_dump_clocks(struct seq_file *s) > const char *fclk_name; > unsigned long fclk_rate; > =20 > - if (dss_runtime_get()) > + if (dss_runtime_get(&dss)) > return; > =20 > seq_printf(s, "- DSS -\n"); > @@ -394,7 +396,7 @@ static void dss_dump_clocks(struct seq_file *s) > fclk_name, > fclk_rate); > =20 > - dss_runtime_put(); > + dss_runtime_put(&dss); > } > #endif > =20 > @@ -402,7 +404,7 @@ static int dss_dump_regs(struct seq_file *s, void *p) > { > #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r)) > =20 > - if (dss_runtime_get()) > + if (dss_runtime_get(&dss)) > return 0; > =20 > DUMPREG(DSS_REVISION); > @@ -416,7 +418,7 @@ static int dss_dump_regs(struct seq_file *s, void *p) > DUMPREG(DSS_SDI_STATUS); > } > =20 > - dss_runtime_put(); > + dss_runtime_put(&dss); > #undef DUMPREG > return 0; > } > @@ -889,27 +891,32 @@ static void dss_put_clocks(void) > clk_put(dss.parent_clk); > } > =20 > -int dss_runtime_get(void) > +int dss_runtime_get(struct dss_device *dss) > { > int r; > =20 > DSSDBG("dss_runtime_get\n"); > =20 > - r =3D pm_runtime_get_sync(&dss.pdev->dev); > + r =3D pm_runtime_get_sync(&dss->pdev->dev); > WARN_ON(r < 0); > return r < 0 ? r : 0; > } > =20 > -void dss_runtime_put(void) > +void dss_runtime_put(struct dss_device *dss) > { > int r; > =20 > DSSDBG("dss_runtime_put\n"); > =20 > - r =3D pm_runtime_put_sync(&dss.pdev->dev); > + r =3D pm_runtime_put_sync(&dss->pdev->dev); > WARN_ON(r < 0 && r !=3D -ENOSYS && r !=3D -EBUSY); > } > =20 > +struct dss_device *dss_get_device(struct device *dev) > +{ > + return &dss; > +} > + > /* DEBUGFS */ > #if defined(CONFIG_OMAP2_DSS_DEBUGFS) > static int dss_debug_dump_clocks(struct seq_file *s, void *p) > @@ -1297,13 +1304,15 @@ static int dss_video_pll_probe(struct platform_de= vice *pdev) > } > =20 > if (of_property_match_string(np, "reg-names", "pll1") >=3D 0) { > - dss.video1_pll =3D dss_video_pll_init(pdev, 0, pll_regulator); > + dss.video1_pll =3D dss_video_pll_init(&dss, pdev, 0, > + pll_regulator); > if (IS_ERR(dss.video1_pll)) > return PTR_ERR(dss.video1_pll); > } > =20 > if (of_property_match_string(np, "reg-names", "pll2") >=3D 0) { > - dss.video2_pll =3D dss_video_pll_init(pdev, 1, pll_regulator); > + dss.video2_pll =3D dss_video_pll_init(&dss, pdev, 1, > + pll_regulator); > if (IS_ERR(dss.video2_pll)) { > dss_video_pll_uninit(dss.video1_pll); > return PTR_ERR(dss.video2_pll); > @@ -1361,7 +1370,7 @@ static int dss_bind(struct device *dev) > =20 > pm_runtime_enable(&pdev->dev); > =20 > - r =3D dss_runtime_get(); > + r =3D dss_runtime_get(&dss); > if (r) > goto err_runtime_get; > =20 > @@ -1386,7 +1395,7 @@ static int dss_bind(struct device *dev) > rev =3D dss_read_reg(DSS_REVISION); > pr_info("OMAP DSS rev %d.%d\n", FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); > =20 > - dss_runtime_put(); > + dss_runtime_put(&dss); > =20 > r =3D component_bind_all(&pdev->dev, NULL); > if (r) > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/= dss/dss.h > index e688e937da28..009b7ef200cd 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dss.h > +++ b/drivers/gpu/drm/omapdrm/dss/dss.h > @@ -29,6 +29,7 @@ > =20 > struct dentry; > struct dss_debugfs_entry; > +struct dss_device; > struct platform_device; > struct seq_file; > =20 > @@ -198,6 +199,7 @@ struct dss_pll_hw { > struct dss_pll { > const char *name; > enum dss_pll_id id; > + struct dss_device *dss; > =20 > struct clk *clkin; > struct regulator *regulator; > @@ -277,8 +279,10 @@ static inline void dss_debugfs_remove_file(struct ds= s_debugfs_entry *entry) > int dss_init_platform_driver(void) __init; > void dss_uninit_platform_driver(void); > =20 > -int dss_runtime_get(void); > -void dss_runtime_put(void); > +struct dss_device *dss_get_device(struct device *dev); > + > +int dss_runtime_get(struct dss_device *dss); > +void dss_runtime_put(struct dss_device *dss); > =20 > unsigned long dss_get_dispc_clk_rate(void); > unsigned long dss_get_max_fck_rate(void); > @@ -289,8 +293,9 @@ enum dss_hdmi_venc_clk_source_select dss_get_hdmi_ven= c_clk_source(void); > const char *dss_get_clk_source_name(enum dss_clk_source clk_src); > =20 > /* DSS VIDEO PLL */ > -struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id, > - struct regulator *regulator); > +struct dss_pll *dss_video_pll_init(struct dss_device *dss, > + struct platform_device *pdev, int id, > + struct regulator *regulator); > void dss_video_pll_uninit(struct dss_pll *pll); > =20 > void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable); > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm= /dss/hdmi.h > index a66f8ff06c24..4dbc4f3d728c 100644 > --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h > +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h > @@ -29,6 +29,8 @@ > #include "omapdss.h" > #include "dss.h" > =20 > +struct dss_device; > + > /* HDMI Wrapper */ > =20 > #define HDMI_WP_REVISION 0x0 > @@ -324,8 +326,8 @@ phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp= _data *wp); > =20 > /* HDMI PLL funcs */ > void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s); > -int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pl= l, > - struct hdmi_wp_data *wp); > +int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev, > + struct hdmi_pll_data *pll, struct hdmi_wp_data *wp); > void hdmi_pll_uninit(struct hdmi_pll_data *hpll); > =20 > /* HDMI PHY funcs */ > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdr= m/dss/hdmi4.c > index ada4e3a9dba7..d84eba8440c8 100644 > --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c > +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c > @@ -717,6 +717,7 @@ static int hdmi_audio_register(struct device *dev) > static int hdmi4_bind(struct device *dev, struct device *master, void *d= ata) > { > struct platform_device *pdev =3D to_platform_device(dev); > + struct dss_device *dss =3D dss_get_device(master); > int r; > int irq; > =20 > @@ -734,7 +735,7 @@ static int hdmi4_bind(struct device *dev, struct devi= ce *master, void *data) > if (r) > return r; > =20 > - r =3D hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); > + r =3D hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp); > if (r) > return r; > =20 > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdr= m/dss/hdmi5.c > index 00ea975b75f9..64cfed89c79b 100644 > --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c > +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c > @@ -719,6 +719,7 @@ static int hdmi_audio_register(struct device *dev) > static int hdmi5_bind(struct device *dev, struct device *master, void *d= ata) > { > struct platform_device *pdev =3D to_platform_device(dev); > + struct dss_device *dss =3D dss_get_device(master); > int r; > int irq; > =20 > @@ -736,7 +737,7 @@ static int hdmi5_bind(struct device *dev, struct devi= ce *master, void *data) > if (r) > return r; > =20 > - r =3D hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); > + r =3D hdmi_pll_init(dss, pdev, &hdmi.pll, &hdmi.wp); > if (r) > return r; > =20 > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/oma= pdrm/dss/hdmi_pll.c > index 55bee81f4dd5..9915354b66c9 100644 > --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c > @@ -128,7 +128,8 @@ static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = =3D { > .has_refsel =3D true, > }; > =20 > -static int hdmi_init_pll_data(struct platform_device *pdev, > +static int hdmi_init_pll_data(struct dss_device *dss, > + struct platform_device *pdev, > struct hdmi_pll_data *hpll) > { > struct dss_pll *pll =3D &hpll->pll; > @@ -145,6 +146,7 @@ static int hdmi_init_pll_data(struct platform_device = *pdev, > pll->id =3D DSS_PLL_HDMI; > pll->base =3D hpll->base; > pll->clkin =3D clk; > + pll->dss =3D dss; > =20 > if (hpll->wp->version =3D=3D 4) > pll->hw =3D &dss_omap4_hdmi_pll_hw; > @@ -160,8 +162,8 @@ static int hdmi_init_pll_data(struct platform_device = *pdev, > return 0; > } > =20 > -int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pl= l, > - struct hdmi_wp_data *wp) > +int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev, > + struct hdmi_pll_data *pll, struct hdmi_wp_data *wp) > { > int r; > struct resource *res; > @@ -174,7 +176,7 @@ int hdmi_pll_init(struct platform_device *pdev, struc= t hdmi_pll_data *pll, > if (IS_ERR(pll->base)) > return PTR_ERR(pll->base); > =20 > - r =3D hdmi_init_pll_data(pdev, pll); > + r =3D hdmi_init_pll_data(dss, pdev, pll); > if (r) { > DSSERR("failed to init HDMI PLL\n"); > return r; > diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/om= apdrm/dss/video-pll.c > index 38a239cc5e04..7ef30f61c52b 100644 > --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c > @@ -62,7 +62,7 @@ static int dss_video_pll_enable(struct dss_pll *pll) > struct dss_video_pll *vpll =3D container_of(pll, struct dss_video_pll, = pll); > int r; > =20 > - r =3D dss_runtime_get(); > + r =3D dss_runtime_get(pll->dss); > if (r) > return r; > =20 > @@ -81,7 +81,7 @@ static int dss_video_pll_enable(struct dss_pll *pll) > err_reset: > dss_dpll_disable_scp_clk(vpll); > dss_ctrl_pll_enable(pll->id, false); > - dss_runtime_put(); > + dss_runtime_put(pll->dss); > =20 > return r; > } > @@ -96,7 +96,7 @@ static void dss_video_pll_disable(struct dss_pll *pll) > =20 > dss_ctrl_pll_enable(pll->id, false); > =20 > - dss_runtime_put(); > + dss_runtime_put(pll->dss); > } > =20 > static const struct dss_pll_ops dss_pll_ops =3D { > @@ -134,8 +134,9 @@ static const struct dss_pll_hw dss_dra7_video_pll_hw = =3D { > .errata_i886 =3D true, > }; > =20 > -struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id, > - struct regulator *regulator) > +struct dss_pll *dss_video_pll_init(struct dss_device *dss, > + struct platform_device *pdev, int id, > + struct regulator *regulator) > { > const char * const reg_name[] =3D { "pll1", "pll2" }; > const char * const clkctrl_name[] =3D { "pll1_clkctrl", "pll2_clkctrl" = }; > @@ -187,6 +188,7 @@ struct dss_pll *dss_video_pll_init(struct platform_de= vice *pdev, int id, > pll->base =3D pll_base; > pll->hw =3D &dss_dra7_video_pll_hw; > pll->ops =3D &dss_pll_ops; > + pll->dss =3D dss; > =20 > r =3D dss_pll_register(pll); > if (r) > --=20 > Regards, >=20 > Laurent Pinchart >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --x3u55hw5vz5fi7g2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlnkcDQACgkQ2O7X88g7 +ppBUw/+JALRg0yURiwu2It9eHssI8Ik3/ye8/+aPibLzAz9p43qMugJ7DNap5Xa 2eqHiW6mcnf237r3McXRmDV13fCMrpnlPq8OQ5EiXNQVioUP9YFquzm6rcrdIBfG SH/v/lQoricpFk8bKYeKCrvsia2xOxa3E9vnEtDEsRsoPpAVeGq/kxqwADuzLLXF ux0eBXuHnR2GYq7dl7kk3THSpjQvgN4ZZLRmobZp9KbuUs4s94Lk7Mdnl4gb2Uh/ VzS2+6wgZvqwaEEsgxAkkOOy/gfkstAJY5Ho2AuKYPXB21TNqhJl6VPXK3ZbqzMb W+JXYd2X1K/0r6rr6cAWSt6gDDjxzsolLrbhvx874LEaYPGjctaaVnrx1ndShMSX fAIhBB/sKuIOauzWGBSGZASyexrwgR9/6XbloOsgjc1tSbPj2Aj9PdibeJUdKTDc 1ZMgaCk5HzkS8a8H4fhPS70jaEUhW1HUAgkJc5RGo8J+aJxE8KyqsXQLDKLY9D4w qgwyVbpb5I0fL6Kmw+NyAPrVqrzr9yg061udwFUZAx/Co09r+kQyAFCGg5fr1YkU SqA/NacxbrtU9XrkCqrmitMUDqeVvw8vt+32b5Fra5zXhyhGp0/PSNhv5BbbAQCw yLhLLqWGV17dQYPxyyd4E0n3/AtwV/zOlxJHFg7QkE2/41Xlqcs= =++QI -----END PGP SIGNATURE----- --x3u55hw5vz5fi7g2-- --===============0458150513== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0458150513==--