From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, david@lechnology.com,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/6] drm/tinydrm: Embed drm_device in tinydrm_device
Date: Fri, 01 Sep 2017 10:28:46 +0300 [thread overview]
Message-ID: <2880086.68ICJ6ZIGv@avalon> (raw)
In-Reply-To: <b0741404-f18b-9a3e-30fd-fbf7ac8eb764@tronnes.org>
Hi Noralf,
On Thursday, 31 August 2017 20:16:42 EEST Noralf Trønnes wrote:
> Den 31.08.2017 12.18, skrev Laurent Pinchart:
> > On Monday, 28 August 2017 20:17:46 EEST Noralf Trønnes wrote:
> >> Might as well embed drm_device since tinydrm_device (embeds pipe struct
> >> and fbdev pointer) needs to stick around after driver-device unbind to
> >> handle open fd's after device removal.
> >>
> >> Cc: David Lechner <david@lechnology.com>
> >> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> >> ---
> >>
> >> drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 44 +++++++++++-----------
> >> drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 2 +-
> >> drivers/gpu/drm/tinydrm/mi0283qt.c | 8 +++---
> >> drivers/gpu/drm/tinydrm/mipi-dbi.c | 12 ++++----
> >> drivers/gpu/drm/tinydrm/repaper.c | 10 +++----
> >> drivers/gpu/drm/tinydrm/st7586.c | 16 +++++------
> >> include/drm/tinydrm/tinydrm.h | 9 +++++-
> >> 7 files changed, 50 insertions(+), 51 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
> >> b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c index 551709e..f11f4cd
> >> 100644
> >> --- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
> >> +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
> >
> > [snip]
> >
> >> @@ -142,23 +142,16 @@ static int tinydrm_init(struct device *parent,
> >> struct
> >> tinydrm_device *tdev, const struct drm_framebuffer_funcs *fb_funcs,
> >>
> >> struct drm_driver *driver)
> >>
> >> {
> >>
> >> - struct drm_device *drm;
> >> + struct drm_device *drm = &tdev->drm;
> >> + int ret;
> >>
> >> mutex_init(&tdev->dirty_lock);
> >> tdev->fb_funcs = fb_funcs;
> >>
> >> - /*
> >> - * We don't embed drm_device, because that prevent us from using
> >> - * devm_kzalloc() to allocate tinydrm_device in the driver since
> >> - * drm_dev_unref() frees the structure. The devm_ functions provide
> >> - * for easy error handling.
> >
> > Don't you then need a custom drm_driver.release handler to free the parent
> > structure ?
>
> I rely on the fact that drm_device is the first member in the driver
> structure and thus it will be freed in drm_dev_release(). A later patch
> adds a drm_driver.release function though.
That's a bit hackish. As a later patch changes this I'd be OK with this one,
but you should mention that you rely on the structure layout in the commit
message.
> >> - */
> >> - drm = drm_dev_alloc(driver, parent);
> >> - if (IS_ERR(drm))
> >> - return PTR_ERR(drm);
> >> -
> >> - tdev->drm = drm;
> >> - drm->dev_private = tdev;
> >> + ret = drm_dev_init(drm, driver, parent);
> >> + if (ret)
> >> + return ret;
> >> +
> >>
> >> drm_mode_config_init(drm);
> >> drm->mode_config.funcs = &tinydrm_mode_config_funcs;
> >
> > [snip]
> >
> >> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c
> >> b/drivers/gpu/drm/tinydrm/mi0283qt.c index 7e5bb7d..77d40c9 100644
> >> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
> >> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
> >
> > [snip]
> >
> >> @@ -169,7 +169,7 @@ static int mi0283qt_probe(struct spi_device *spi)
> >>
> >> u32 rotation = 0;
> >> int ret;
> >>
> >> - mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
> >> + mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
> >
> > Where's the related kfree() ?
> >
> >> if (!mipi)
> >>
> >> return -ENOMEM;
> >
> > [snip]
> >
> >> diff --git a/drivers/gpu/drm/tinydrm/repaper.c
> >> b/drivers/gpu/drm/tinydrm/repaper.c index 30dc97b..b8fc8eb 100644
> >> --- a/drivers/gpu/drm/tinydrm/repaper.c
> >> +++ b/drivers/gpu/drm/tinydrm/repaper.c
> >
> > [snip]
> >
> >> @@ -949,7 +949,7 @@ static int repaper_probe(struct spi_device *spi)
> >>
> >> }
> >>
> >> }
> >>
> >> - epd = devm_kzalloc(dev, sizeof(*epd), GFP_KERNEL);
> >> + epd = kzalloc(sizeof(*epd), GFP_KERNEL);
> >
> > Ditto.
> >
> >> if (!epd)
> >>
> >> return -ENOMEM;
> >
> > [snip]
> >
> >> diff --git a/drivers/gpu/drm/tinydrm/st7586.c
> >> b/drivers/gpu/drm/tinydrm/st7586.c index b439956..bc2b905 100644
> >> --- a/drivers/gpu/drm/tinydrm/st7586.c
> >> +++ b/drivers/gpu/drm/tinydrm/st7586.c
> >
> > [snip]
> >
> >> @@ -349,7 +349,7 @@ static int st7586_probe(struct spi_device *spi)
> >>
> >> u32 rotation = 0;
> >> int ret;
> >>
> >> - mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
> >> + mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
> >
> > Ang here again.
> >
> >> if (!mipi)
> >>
> >> return -ENOMEM;
> >
> > [snip]
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-09-01 7:28 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 17:17 [PATCH 0/6] drm/tinydrm: Support device unplug Noralf Trønnes
2017-08-28 17:17 ` [PATCH 1/6] drm/fb-helper: Avoid NULL ptr dereference in fb_set_suspend() Noralf Trønnes
2017-08-28 21:34 ` Daniel Vetter
2017-08-31 9:30 ` Laurent Pinchart
2017-09-02 12:46 ` Noralf Trønnes
2017-08-28 17:17 ` [PATCH 2/6] drm/fb-helper: Support device unplug Noralf Trønnes
2017-08-28 21:41 ` Daniel Vetter
2017-08-29 16:17 ` Noralf Trønnes
2017-08-30 7:29 ` Daniel Vetter
2017-08-30 13:45 ` Noralf Trønnes
2017-08-28 17:17 ` [PATCH 3/6] drm/fb-cma-helper: " Noralf Trønnes
2017-08-28 21:46 ` Daniel Vetter
2017-08-29 17:23 ` Noralf Trønnes
2017-08-30 7:36 ` Daniel Vetter
2017-08-28 17:17 ` [PATCH 4/6] drm/tinydrm: Embed drm_device in tinydrm_device Noralf Trønnes
2017-08-28 21:47 ` Daniel Vetter
2017-08-29 19:09 ` David Lechner
2017-08-31 10:18 ` Laurent Pinchart
2017-08-31 17:16 ` Noralf Trønnes
2017-09-01 7:28 ` Laurent Pinchart [this message]
2017-09-01 18:46 ` Noralf Trønnes
2017-08-28 17:17 ` [PATCH 5/6] drm/tinydrm/mi0283qt: Let the display pipe handle power Noralf Trønnes
2017-08-28 17:17 ` [PATCH 6/6] drm/tinydrm: Support device unplug Noralf Trønnes
2017-08-28 21:56 ` Daniel Vetter
2017-08-30 16:31 ` Noralf Trønnes
2017-08-30 17:18 ` Daniel Vetter
2017-08-31 12:59 ` Laurent Pinchart
2017-08-31 19:22 ` Noralf Trønnes
2017-09-01 8:38 ` Laurent Pinchart
2017-09-02 20:59 ` Noralf Trønnes
2017-09-04 7:26 ` Daniel Vetter
2017-09-04 8:41 ` Laurent Pinchart
2017-09-04 9:04 ` Daniel Vetter
2017-09-04 9:38 ` Laurent Pinchart
2017-09-04 12:30 ` Noralf Trønnes
2017-09-04 15:20 ` Daniel Vetter
2017-09-04 15:54 ` Noralf Trønnes
2017-09-04 16:39 ` Daniel Vetter
2017-08-28 21:58 ` [PATCH 0/6] " Daniel Vetter
2017-08-29 18:05 ` Noralf Trønnes
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=2880086.68ICJ6ZIGv@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=daniel.vetter@ffwll.ch \
--cc=david@lechnology.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=noralf@tronnes.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.