From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
Dave Airlie <airlied@gmail.com>,
Jason Cooper <jason@lakedaemon.net>,
dri-devel@lists.freedesktop.org,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: Re: [PATCH RFC 2/8] DRM: Armada: Add Armada DRM driver
Date: Wed, 12 Jun 2013 20:40:21 +0100 [thread overview]
Message-ID: <20130612194021.GX18614@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20130612170512.GU18614@n2100.arm.linux.org.uk>
On Wed, Jun 12, 2013 at 06:05:12PM +0100, Russell King - ARM Linux wrote:
> On Wed, Jun 12, 2013 at 05:49:14PM +0100, Russell King - ARM Linux wrote:
> > On Wed, Jun 12, 2013 at 09:56:22AM -0400, Rob Clark wrote:
> > > On Wed, Jun 12, 2013 at 9:48 AM, Russell King - ARM Linux
> > > <linux@arm.linux.org.uk> wrote:
> > > > And having thought about this driver, DRM some more, I'm now of the
> > > > opinion that DRM is not suitable for driving hardware where the GPU is
> > > > an entirely separate IP block from the display side.
> > > >
> > > > DRM is modelled after the PC setup where your "graphics card" does
> > > > everything - it has the GPU, display and connectors all integrated
> > > > together. This is not the case on embedded SoCs, which can be a
> > > > collection of different IPs all integrated together.
> > >
> > > actually it isn't even the case on desktop/laptop anymore, where you
> > > can have one gpu with scanout and a second one without (or just with
> > > display controller not hooked up to anything, etc, etc)
> > >
> > > That is the point of dmabuf and the upcoming fence/reservation stuff.
> >
> > Okay, but dmabuf really needs to be fixed, because as it stands this API
> > is really quite broken wrt the DMA API. dma_map_sg() is (a) not supposed
> > to have its return value ignored - mappings can fail, and (b) the returned
> > number indicates how many entries are valid for the _mapped_ version of
> > the scatterlist.
> >
> > Both these points are important if your DMA API implementation uses an
> > IOMMU, which may coalesce the scatterlist array when creating mappings -
> > much as described in Documentation/DMA-API.txt and
> > Documentation/DMA-API-HOWTO.txt.
> >
> > That is not all DRMs fault - (a) is attributable to DRM's prime
> > implementation:
> >
> > sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
> >
> > if (!IS_ERR_OR_NULL(sgt))
> > dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir);
> >
> > and quite why it does the dma_map_sg() beneath the struct_mutex is
> > beyond me - if the array of pages isn't safe without the mutex being
> > held, then it isn't safe after the dma_map_sg() operation has completed
> > and the mutex has been released.
> >
> > However, (b) is more a problem for dmabuf (which I just rather aptly
> > mistyped as dmabug) because either dmabuf's .map_dma_buf method needs
> > to return the value from dma_map_sg(), or it needs to stop requiring
> > this of the .map_dma_buf method and have it done by the caller of
> > this method so the caller can have access to that returned value.
> >
> > Added Sumit Semwal to this email for the dmabuf issue.
> >
> > Thankfully, this being correct isn't a requirement for me, but it's
> > something which _should_ be fixed.
>
> Okay, so Sumit Semwal has been a victim of TI's cuts, so don't expect
> dma_buf to get sorted by the original author...
And now the next muckup in dma-buf/drm_prime - though it's arguably the
fault of IS_ERR_OR_NULL existing in the first place:
drm_gem_prime_import()
{
sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
if (IS_ERR_OR_NULL(sgt)) {
ret = PTR_ERR(sgt);
goto fail_detach;
}
fail_detach:
dma_buf_detach(dma_buf, attach);
return ERR_PTR(ret);
}
What happens if sgt is NULL here? What value does ret get? What does
drm_gem_prime_import() return? How is that interpreted by
drm_gem_prime_fd_to_handle() ?
I can probably oops a kernel running DRM through this if I can manipulate
a dma_buf_map_attachment() to return NULL (there probably is a driver
which is capable of doing so.)
APIs which use IS_ERR_OR_NULL() are problems waiting to happen; we've
already reached some concensus a while back to get rid of this helper,
if only it wasn't soo prolific (like its errors are.)
next prev parent reply other threads:[~2013-06-12 19:40 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 19:06 [RFC v2 0/8] rmk's Dove DRM/TDA19988 Cubox driver Russell King - ARM Linux
2013-06-09 19:29 ` [PATCH RFC 2/8] DRM: Armada: Add Armada DRM driver Russell King
2013-06-10 11:10 ` Sebastian Hesselbarth
2013-06-10 21:48 ` Russell King - ARM Linux
2013-06-10 21:56 ` Sebastian Hesselbarth
2013-06-10 15:57 ` Rob Clark
2013-06-10 17:06 ` Russell King - ARM Linux
2013-06-10 19:59 ` Rob Clark
2013-06-10 20:08 ` Russell King - ARM Linux
2013-06-10 21:01 ` Rob Clark
2013-06-10 21:15 ` Russell King - ARM Linux
2013-06-10 22:49 ` Rob Clark
2013-06-10 22:56 ` Russell King - ARM Linux
2013-06-10 23:17 ` Rob Clark
2013-06-10 23:24 ` Dave Airlie
2013-06-10 23:35 ` Rob Clark
2013-06-10 23:36 ` Russell King - ARM Linux
2013-06-10 23:48 ` Dave Airlie
2013-06-10 23:56 ` Russell King - ARM Linux
2013-06-12 13:48 ` Russell King - ARM Linux
2013-06-12 13:56 ` Rob Clark
2013-06-12 16:49 ` Russell King - ARM Linux
2013-06-12 17:05 ` Russell King - ARM Linux
2013-06-12 19:40 ` Russell King - ARM Linux [this message]
2013-06-12 23:00 ` Russell King - ARM Linux
2013-06-13 0:17 ` Rob Clark
2013-06-13 11:19 ` Russell King - ARM Linux
2013-06-13 11:50 ` Russell King - ARM Linux
2013-06-13 13:03 ` Russell King - ARM Linux
2013-06-14 14:23 ` Daniel Vetter
2013-06-14 14:42 ` Russell King - ARM Linux
2013-06-14 19:50 ` Daniel Vetter
2013-06-14 22:15 ` Russell King - ARM Linux
2013-06-14 22:36 ` Daniel Vetter
2013-06-14 13:53 ` Daniel Vetter
2013-06-14 14:27 ` Russell King - ARM Linux
2013-06-13 12:52 ` Rob Clark
2013-06-13 12:58 ` Daniel Vetter
2013-06-12 20:04 ` Rob Clark
2013-06-10 23:38 ` Russell King - ARM Linux
2013-06-10 23:49 ` Rob Clark
2013-06-10 22:01 ` Daniel Vetter
2013-06-10 22:32 ` Russell King - ARM Linux
2013-06-10 23:12 ` Rob Clark
2013-06-11 7:33 ` Daniel Vetter
2013-06-11 8:08 ` Ville Syrjälä
2013-06-10 21:38 ` Russell King - ARM Linux
2013-06-09 19:30 ` [PATCH RFC 3/8] drm/i2c: nxp-tda998x: fix EDID reading on TDA19988 devices Russell King
2013-06-09 19:31 ` [PATCH RFC 4/8] drm/i2c: nxp-tda998x: ensure VIP output mux is properly set Russell King
2013-06-09 19:32 ` [PATCH RFC 5/8] drm/i2c: nxp-tda998x: fix npix/nline programming Russell King
2013-06-09 20:02 ` Sebastian Hesselbarth
2013-06-09 19:34 ` [PATCH RFC 6/8] drm/i2c: nxp-tda998x: prepare for video input configuration Russell King
2013-06-09 19:35 ` [PATCH RFC 7/8] drm/i2c: nxp-tda998x: add video and audio " Russell King
2013-06-09 19:36 ` [PATCH RFC 8/8] DRM: Armada: add support for drm tda19988 driver Russell King
2013-06-09 19:43 ` [RFC v2 0/8] rmk's Dove DRM/TDA19988 Cubox driver Russell King - ARM Linux
2013-06-10 22:47 ` [RFC v3 0/4] " Russell King - ARM Linux
2013-06-10 22:48 ` [PATCH RFC v3 1/4] DRM: Armada: Add Armada DRM driver Russell King
2013-06-10 22:49 ` [PATCH RFC v3 2/4] DRM: Armada: Add support for hardware cursors Russell King
2013-06-10 22:50 ` [PATCH RFC v3 3/4] DRM: Armada: convert Armada hardware cursor support to RGB+transparency Russell King
2013-06-10 22:51 ` [PATCH RFC v3 4/4] DRM: Armada: convert hardware cursor support to 64x32 or 32x64 ARGB Russell King
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=20130612194021.GX18614@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=robdclark@gmail.com \
--cc=sebastian.hesselbarth@gmail.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