From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Kurtz Subject: Re: [PATCH v9 02/14] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173. Date: Wed, 3 Feb 2016 01:09:15 +0800 Message-ID: References: <1452611750-16283-1-git-send-email-p.zabel@pengutronix.de> <1452611750-16283-3-git-send-email-p.zabel@pengutronix.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1759535894==" Return-path: In-Reply-To: <1452611750-16283-3-git-send-email-p.zabel@pengutronix.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Philipp Zabel Cc: Mark Rutland , Michael Turquette , dri-devel , Jie Qiu , Cawa Cheng , YT Shen , Yingjoe Chen , "open list:OPEN FIRMWARE AND..." , Jitao Shi , Sasha Hauer , Pawel Moll , Ian Campbell , Rob Herring , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , Paul Bolle , Stephen Boyd , Tomasz Figa , Kumar Gala List-Id: devicetree@vger.kernel.org --===============1759535894== Content-Type: multipart/alternative; boundary=001a11457f30d22808052acc9040 --001a11457f30d22808052acc9040 Content-Type: text/plain; charset=UTF-8 Hi Philipp, Some more potential bugs I discovered today while trying to configure Mediatek DRM to use just the MIPI/DSI path (no HDMI). On Tue, Jan 12, 2016 at 11:15 PM, Philipp Zabel wrote: > From: CK Hu > > This patch adds an initial DRM driver for the Mediatek MT8173 DISP > subsystem. It currently supports two fixed output streams from the > OVL0/OVL1 sources to the DSI0/DPI0 sinks, respectively. > > Signed-off-by: CK Hu > Signed-off-by: YT Shen > Signed-off-by: Daniel Kurtz > Signed-off-by: Philipp Zabel [snip] > +int mtk_drm_crtc_create(struct drm_device *drm_dev, > + const enum mtk_ddp_comp_id *path, unsigned int path_len) > +{ > + struct mtk_drm_private *priv = drm_dev->dev_private; > + struct device *dev = drm_dev->dev; > + struct mtk_drm_crtc *mtk_crtc; > + enum drm_plane_type type; > + unsigned int zpos; > + int pipe = priv->num_pipes; > + int ret; > + int i; > + > + mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL); > + if (!mtk_crtc) > + return -ENOMEM; > + > + mtk_crtc->config_regs = priv->config_regs; > + mtk_crtc->ddp_comp_nr = path_len; > + mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, > + sizeof(*mtk_crtc->ddp_comp), > + GFP_KERNEL); > + > + mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe); > + if (IS_ERR(mtk_crtc->mutex)) { > + ret = PTR_ERR(mtk_crtc->mutex); > + dev_err(dev, "Failed to get mutex: %d\n", ret); > + return ret; > + } > + > + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { > + enum mtk_ddp_comp_id comp_id = path[i]; > + struct mtk_ddp_comp *comp; > + > + comp = priv->ddp_comp[comp_id]; > + if (!comp) { > + dev_err(dev, "Component %s not initialized\n", > + priv->comp_node[comp_id]->full_name); If one of the components is disabled in .dtsi, then its priv->comp_node[comp_id] will be NULL here, and trying to full_name will OOPS. > + ret = -ENODEV; > + goto unprepare; > + } > + > + ret = clk_prepare(comp->clk); > + if (ret) { > + dev_err(dev, > + "Failed to prepare clock for component %s: %d\n", > + priv->comp_node[comp_id]->full_name, ret); > + goto unprepare; > + } > + > + mtk_crtc->ddp_comp[i] = comp; > + } > + > + for (zpos = 0; zpos < OVL_LAYER_NR; zpos++) { > + type = (zpos == 0) ? DRM_PLANE_TYPE_PRIMARY : > + (zpos == 1) ? DRM_PLANE_TYPE_CURSOR : > + DRM_PLANE_TYPE_OVERLAY; > + ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], > + BIT(pipe), type, zpos); > + if (ret) > + goto unprepare; > + } > + > + ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0].base, > + &mtk_crtc->planes[1].base, pipe); > + if (ret < 0) > + goto unprepare; > + > + priv->crtc[pipe] = &mtk_crtc->base; > + priv->num_pipes++; > + > + return 0; > + > +unprepare: > + while (--i >= 0) > + clk_unprepare(mtk_crtc->ddp_comp[i]->clk); > + > + return ret; > +} > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > new file mode 100644 > index 0000000..9db22b4 > --- /dev/null > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c [snip] > +static struct drm_driver mtk_drm_driver = { > + .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | > + DRIVER_ATOMIC, > + .unload = mtk_drm_unload, > + .set_busid = drm_platform_set_busid, I think using drm_platform_set_busid() as our .set_busid may cause an OOPs if userspace does DRM_IOCTL_SET_VERSION. drm_setversion() will calls drm_set_busid(), which calls dev->driver->set_busid() drm_platform_set_busid() accesses dev->platformdev->id. However, dev->platformdev is only set by: drm_platform_init()->drm_get_platform_dev() And, since mtk_drm_bind() does the drm_dev_alloc() / drm_dev_register() itself instead of calling drm_get_platform_dev(), so dev->platformdev will still be NULL. So, why don't we call drm_platform_init() instead and implement a .load callback to do mtk_drm_kms_init()? > + > + .get_vblank_counter = drm_vblank_count, > + .enable_vblank = mtk_drm_crtc_enable_vblank, > + .disable_vblank = mtk_drm_crtc_disable_vblank, > + > + .gem_free_object = mtk_drm_gem_free_object, > + .gem_vm_ops = &mtk_drm_gem_vm_ops, > + .dumb_create = mtk_drm_gem_dumb_create, > + .dumb_map_offset = mtk_drm_gem_dumb_map_offset, > + .dumb_destroy = drm_gem_dumb_destroy, > + > + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, > + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, > + .gem_prime_export = drm_gem_prime_export, > + .gem_prime_import = drm_gem_prime_import, > + .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table, > + .gem_prime_mmap = mtk_drm_gem_mmap_buf, > + .fops = &mtk_drm_fops, > + > + .name = DRIVER_NAME, > + .desc = DRIVER_DESC, > + .date = DRIVER_DATE, > + .major = DRIVER_MAJOR, > + .minor = DRIVER_MINOR, > +}; > + > +static int compare_of(struct device *dev, void *data) > +{ > + return dev->of_node == data; > +} > + > +static int mtk_drm_bind(struct device *dev) > +{ > + struct mtk_drm_private *private = dev_get_drvdata(dev); > + struct drm_device *drm; > + int ret; > + > + drm = drm_dev_alloc(&mtk_drm_driver, dev); > + if (!drm) > + return -ENOMEM; > + > + drm_dev_set_unique(drm, dev_name(dev)); > + > + ret = drm_dev_register(drm, 0); > + if (ret < 0) > + goto err_free; > + > + drm->dev_private = private; > + private->drm = drm; > + > + ret = mtk_drm_kms_init(drm); > + if (ret < 0) > + goto err_unregister; > + > + return 0; > + > +err_unregister: > + drm_dev_unregister(drm); > +err_free: > + drm_dev_unref(drm); > + return ret; > +} --001a11457f30d22808052acc9040 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi P= hilipp,

Some more potential bugs I discovered today while trying to configure Med= iatek DRM to use just the MIPI/DSI path (no HDMI).

On Tue, Jan 12, 2016 at 11:15 = PM, Philipp Zabel <p.zabel@pen= gutronix.de> wrote:
> From: CK Hu= <ck.hu@mediatek.com>
=
>
> This p= atch adds an initial DRM driver for the Mediatek MT8173 DISP
> subsystem. It currently supports two fixed output st= reams from the
> OVL0/OVL1 sources to th= e DSI0/DPI0 sinks, respectively.
>
=
> Signed-off-by: CK Hu <ck.hu@mediatek.com>
> Signed-off-by: YT Shen <yt.shen@mediatek.com>
> Signed-o= ff-by: Daniel Kurtz <djkurtz@chr= omium.org>
> Signed-off-by: Phili= pp Zabel <p.zabel@pengutronix.= de>

[snip]

> +int mtk_drm_crtc_create(struct drm_device *drm_dev,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const enum mtk_ddp_comp_id *path, unsigned = int path_len)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct mtk_drm_private *priv =3D drm= _dev->dev_private;
> + =C2=A0 =C2=A0 = =C2=A0 struct device *dev =3D drm_dev->dev;
> + =C2=A0 =C2=A0 =C2=A0 struct mtk_drm_crtc *mtk_crtc;
> + =C2=A0 =C2=A0 =C2=A0 enum drm_plane_type type;
> + =C2=A0 =C2=A0 =C2=A0 unsigned int zpo= s;
> + =C2=A0 =C2=A0 =C2=A0 int pipe =3D= priv->num_pipes;
> + =C2=A0 =C2=A0 = =C2=A0 int ret;
> + =C2=A0 =C2=A0 =C2=A0= int i;
> +
> + =C2=A0 =C2=A0 =C2=A0 mtk_crtc =3D devm_kzalloc(dev, sizeof(*mtk_= crtc), GFP_KERNEL);
> + =C2=A0 =C2=A0 = =C2=A0 if (!mtk_crtc)
> + =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOMEM;
> +
> + =C2=A0 =C2=A0 =C2=A0 = mtk_crtc->config_regs =3D priv->config_regs;
> + =C2=A0 =C2=A0 =C2=A0 mtk_crtc->ddp_comp_nr =3D path_len;<= /div>
> + =C2=A0 =C2=A0 =C2=A0 mtk_crtc->dd= p_comp =3D devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sizeof(*mtk_crtc->ddp_comp),
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 GFP_KERNEL);
> +
> + =C2=A0 =C2= =A0 =C2=A0 mtk_crtc->mutex =3D mtk_disp_mutex_get(priv->mutex_dev, pi= pe);
> + =C2=A0 =C2=A0 =C2=A0 if (IS_ERR= (mtk_crtc->mutex)) {
> + =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D PTR_ERR(mtk_crtc->mutex);=
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 dev_err(dev, "Failed to get mutex: %d\n", ret);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return ret;
> + =C2=A0 =C2=A0= =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < mtk_crtc->ddp_com= p_nr; i++) {
> + =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 enum mtk_ddp_comp_id comp_id =3D path[i];
=
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 struct mtk_ddp_comp *comp;
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 comp =3D priv->ddp_comp[comp_id];
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!comp) = {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(dev, "Component %s = not initialized\n",
> + =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 priv->comp_node[comp_id]->full_name);

If one of the co= mponents is disabled in .dtsi, then its
pri= v->comp_node[comp_id] will be NULL here, and trying to full_name will OO= PS.

> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D -ENODEV;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto unprepare;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D clk_prepare(comp->clk);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 if (ret) {
> + =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(= dev,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &= quot;Failed to prepare clock for component %s: %d\n",
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 priv->comp_node[= comp_id]->full_name, ret);
> + =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto= unprepare;
> + =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 mtk_crtc->ddp_comp[i] =3D comp;
>= + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 for (zpos =3D 0; zpos <= ; OVL_LAYER_NR; zpos++) {
> + =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 type =3D (zpos =3D=3D 0) ? DRM_PLANE= _TYPE_PRIMARY :
> + =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (zpos =3D=3D 1) ? DRM_PLANE_TYPE_CURSOR :
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DRM_PLANE_TYPE_OVERLAY;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret = =3D mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos],
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0BIT(pipe), type, zpos);
> + =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ret)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 goto unprepare;
> + = =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 ret =3D mtk_drm_crtc_init(dr= m_dev, mtk_crtc, &mtk_crtc->planes[0].base,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &mtk_crtc->planes[1].b= ase, pipe);
> + =C2=A0 =C2=A0 =C2=A0 if = (ret < 0)
> + =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto unprepare;
> +
> + =C2=A0 =C2=A0 =C2=A0 priv-&g= t;crtc[pipe] =3D &mtk_crtc->base;
&g= t; + =C2=A0 =C2=A0 =C2=A0 priv->num_pipes++;
> +
> + =C2=A0 =C2=A0 =C2=A0 ret= urn 0;
> +
> +unprepare:
> + =C2=A0 =C2=A0 = =C2=A0 while (--i >=3D 0)
> + =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 clk_unprepare(mtk_crtc->ddp_co= mp[i]->clk);
> +
> + =C2=A0 =C2=A0 =C2=A0 return ret;
> +}

> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drive= rs/gpu/drm/mediatek/mtk_drm_drv.c
> new = file mode 100644
> index 0000000..9db22b= 4
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c

[snip]

> +static struct = drm_driver mtk_drm_driver =3D {
> + =C2= =A0 =C2=A0 =C2=A0 .driver_features =3D DRIVER_MODESET | DRIVER_GEM | DRIVER= _PRIME |
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DRIVER_ATOMI= C,
> + =C2=A0 =C2=A0 =C2=A0 .unload =3D = mtk_drm_unload,
> + =C2=A0 =C2=A0 =C2=A0= .set_busid =3D drm_platform_set_busid,
I think using drm_platform_set_busid() as= our .set_busid may cause an OOPs if
usersp= ace does DRM_IOCTL_SET_VERSION.

<= div class=3D"gmail_extra">drm_setversion() will calls drm_set_busid(), whic= h calls dev->driver->set_busid()
drm_= platform_set_busid() accesses dev->platformdev->id.

However, dev->plat= formdev is only set by:
=C2=A0 drm_platform= _init()->drm_get_platform_dev()

And, since mtk_drm_bind() does the drm_dev_all= oc() / drm_dev_register() itself instead
of= calling drm_get_platform_dev(), so dev->platformdev will still be NULL.=

So, w= hy don't we call drm_platform_init() instead and implement a .load call= back
to do mtk_drm_kms_init()?

> +
> + =C2=A0 =C2=A0 =C2=A0 .get_vblank_counter =3D dr= m_vblank_count,
> + =C2=A0 =C2=A0 =C2=A0= .enable_vblank =3D mtk_drm_crtc_enable_vblank,
> + =C2=A0 =C2=A0 =C2=A0 .disable_vblank =3D mtk_drm_crtc_disable_v= blank,
> +
> + =C2=A0 =C2=A0 =C2=A0 .gem_free_object =3D mtk_drm_gem_free_object= ,
> + =C2=A0 =C2=A0 =C2=A0 .gem_vm_ops = =3D &mtk_drm_gem_vm_ops,
> + =C2=A0 = =C2=A0 =C2=A0 .dumb_create =3D mtk_drm_gem_dumb_create,
> + =C2=A0 =C2=A0 =C2=A0 .dumb_map_offset =3D mtk_drm_gem_d= umb_map_offset,
> + =C2=A0 =C2=A0 =C2=A0= .dumb_destroy =3D drm_gem_dumb_destroy,
&g= t; +
> + =C2=A0 =C2=A0 =C2=A0 .prime_han= dle_to_fd =3D drm_gem_prime_handle_to_fd,
&= gt; + =C2=A0 =C2=A0 =C2=A0 .prime_fd_to_handle =3D drm_gem_prime_fd_to_hand= le,
> + =C2=A0 =C2=A0 =C2=A0 .gem_prime_= export =3D drm_gem_prime_export,
> + =C2= =A0 =C2=A0 =C2=A0 .gem_prime_import =3D drm_gem_prime_import,
> + =C2=A0 =C2=A0 =C2=A0 .gem_prime_get_sg_table =3D = mtk_gem_prime_get_sg_table,
> + =C2=A0 = =C2=A0 =C2=A0 .gem_prime_mmap =3D mtk_drm_gem_mmap_buf,
> + =C2=A0 =C2=A0 =C2=A0 .fops =3D &mtk_drm_fops,
=
> +
> + = =C2=A0 =C2=A0 =C2=A0 .name =3D DRIVER_NAME,
> + =C2=A0 =C2=A0 =C2=A0 .desc =3D DRIVER_DESC,
> + =C2=A0 =C2=A0 =C2=A0 .date =3D DRIVER_DATE,
> + =C2=A0 =C2=A0 =C2=A0 .major =3D DRIVER_MAJOR,
=
> + =C2=A0 =C2=A0 =C2=A0 .minor =3D DRIVER_MI= NOR,
> +};
> +
> +static int compare_of(struc= t device *dev, void *data)
> +{
> + =C2=A0 =C2=A0 =C2=A0 return dev->of_node = =3D=3D data;
> +}
> +
> +static int mtk_drm_b= ind(struct device *dev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct mtk_drm_private *pr= ivate =3D dev_get_drvdata(dev);
> + =C2= =A0 =C2=A0 =C2=A0 struct drm_device *drm;
&= gt; + =C2=A0 =C2=A0 =C2=A0 int ret;
> +<= /div>
> + =C2=A0 =C2=A0 =C2=A0 drm =3D drm_dev= _alloc(&mtk_drm_driver, dev);
> + = =C2=A0 =C2=A0 =C2=A0 if (!drm)
> + =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOMEM;
> +
> + =C2=A0 =C2= =A0 =C2=A0 drm_dev_set_unique(drm, dev_name(dev));
> +
> + =C2=A0 =C2=A0 =C2=A0 = ret =3D drm_dev_register(drm, 0);
> + = =C2=A0 =C2=A0 =C2=A0 if (ret < 0)
> += =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto err_free;
> +
> + =C2=A0 = =C2=A0 =C2=A0 drm->dev_private =3D private;
> + =C2=A0 =C2=A0 =C2=A0 private->drm =3D drm;
> +
> + =C2=A0 =C2=A0 = =C2=A0 ret =3D mtk_drm_kms_init(drm);
> = + =C2=A0 =C2=A0 =C2=A0 if (ret < 0)
>= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto err_unregister;
> +
> += =C2=A0 =C2=A0 =C2=A0 return 0;
> +
> +err_unregister:
> + =C2=A0 =C2=A0 =C2=A0 drm_dev_unregister(drm);
> +err_free:
> + =C2= =A0 =C2=A0 =C2=A0 drm_dev_unref(drm);
> = + =C2=A0 =C2=A0 =C2=A0 return ret;
> +}<= /div>
--001a11457f30d22808052acc9040-- --===============1759535894== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============1759535894==--