From: Daniel Kurtz <djkurtz@chromium.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>,
Michael Turquette <mturquette@baylibre.com>,
dri-devel <dri-devel@lists.freedesktop.org>,
Jie Qiu <jie.qiu@mediatek.com>,
Cawa Cheng <cawa.cheng@mediatek.com>,
YT Shen <yt.shen@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
"open list:OPEN FIRMWARE AND..." <devicetree@vger.kernel.org>,
Jitao Shi <jitao.shi@mediatek.com>,
Sasha Hauer <kernel@pengutronix.de>,
Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Rob Herring <robh+dt@kernel.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Paul Bolle <pebolle@tiscali.nl>,
Stephen Boyd <sboyd@codeaurora.org>,
Tomasz Figa <tfiga@chromium.org>,
Kumar Gala <galak@codeaurora.org>
Subject: Re: [PATCH v9 02/14] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.
Date: Wed, 3 Feb 2016 01:09:15 +0800 [thread overview]
Message-ID: <CAGS+omBcXwO7ZKm_JP7uP3Bzsm-HaCbmeoxkGx2LGLsa2B5G_g@mail.gmail.com> (raw)
In-Reply-To: <1452611750-16283-3-git-send-email-p.zabel@pengutronix.de>
[-- Attachment #1.1: Type: text/plain, Size: 6685 bytes --]
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 <p.zabel@pengutronix.de>
wrote:
> From: CK Hu <ck.hu@mediatek.com>
>
> 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 <ck.hu@mediatek.com>
> Signed-off-by: YT Shen <yt.shen@mediatek.com>
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
[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;
> +}
[-- Attachment #1.2: Type: text/html, Size: 14208 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-02-02 17:09 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 15:15 [PATCH v9 00/14] MT8173 DRM support Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 01/14] dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 02/14] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173 Philipp Zabel
2016-01-20 22:23 ` Daniel Kurtz
2016-02-03 14:31 ` Philipp Zabel
2016-02-02 17:09 ` Daniel Kurtz [this message]
2016-02-02 17:12 ` Daniel Kurtz
2016-02-03 14:31 ` Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 03/14] drm/mediatek: Add DSI sub driver Philipp Zabel
2016-02-02 13:32 ` Daniel Kurtz
2016-02-03 11:01 ` Philipp Zabel
[not found] ` <1454497304.3867.1.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-02-04 6:37 ` CK Hu
2016-02-04 12:24 ` Daniel Kurtz
2016-02-04 12:48 ` Philipp Zabel
[not found] ` <1454590099.3356.22.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-02-05 9:06 ` CK Hu
2016-01-12 15:15 ` [PATCH v9 04/14] drm/mediatek: Add DPI " Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 05/14] dt-bindings: drm/mediatek: Add Mediatek HDMI dts binding Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 06/14] drm/mediatek: Add HDMI support Philipp Zabel
[not found] ` <1452611750-16283-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-01-12 15:15 ` [PATCH v9 07/14] drm/mediatek: enable hdmi output control bit Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 08/14] arm64: dts: mt8173: Add display subsystem related nodes Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 09/14] arm64: dts: mt8173: Add HDMI " Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 10/14] clk: mediatek: make dpi0_sel propagate rate changes Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 11/14] clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 12/14] dt-bindings: hdmi-connector: add DDC I2C bus phandle documentation Philipp Zabel
2016-01-12 15:15 ` [PATCH v9 13/14] clk: mediatek: remove hdmitx_dig_cts from TOP clocks Philipp Zabel
2016-02-25 23:09 ` Stephen Boyd
2016-01-12 15:15 ` [PATCH v9 14/14] drm/mediatek: Add interface to allocate Mediatek GEM buffer Philipp Zabel
2016-01-12 15:47 ` Frank Binns
2016-01-12 22:02 ` Rob Herring
2016-01-12 22:40 ` Daniel Vetter
2016-01-13 11:42 ` Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGS+omBcXwO7ZKm_JP7uP3Bzsm-HaCbmeoxkGx2LGLsa2B5G_g@mail.gmail.com \
--to=djkurtz@chromium.org \
--cc=cawa.cheng@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jie.qiu@mediatek.com \
--cc=jitao.shi@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=pawel.moll@arm.com \
--cc=pebolle@tiscali.nl \
--cc=robh+dt@kernel.org \
--cc=sboyd@codeaurora.org \
--cc=tfiga@chromium.org \
--cc=yingjoe.chen@mediatek.com \
--cc=yt.shen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).