dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping
@ 2017-03-10  9:39 Laurent Pinchart
  2017-03-10  9:39 ` [PATCH 1/7] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Laurent Pinchart @ 2017-03-10  9:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

Hello,

Memory leaks have been reported when allocating a cached omap_bo (with
OMAP_BO_CACHED. Investigation showed that this can only come from the DMA
mapping debug layer, as on ARM32 the non-coherent, non-IOMMU DMA mapping code
doesn't allocate memory to map a page (and kmemcheck facility is only
available on x86, so it can't be a source of memory leaks either on ARM).

The DMA debug layer pre-allocates DMA debugging entries and stores them in a
list. As the omapdrm driver maps cached buffer page by page, the list of 4096
pre-allocated entries is starved very soon. However, raising the number of DMA
mapping debug entries to 32 * 4096 (through the dma_debug_entries kernel
command line argument) led to more interesting results.

The number of entries being large enough to handle all the pages mapped by
kmstest, monitoring the DMA mapping statistics through
/sys/kernel/debug/dma-api/ showed that the number of free entries dropped
significantly when kmstest was started and didn't raise when it was stopped.
In particular, running kmstest without flipping resulting in a drop of 1266
free entries, which corresponds to one 1440x900 framebuffer in XR24. The
proved that the pages backing the framebuffer, while freed when the
framebuffer was destroyed, were not unmapped.

I've thus started investigating the driver GEM implementation. After a few
confusing moments that resulted in the 1/7 to 6/7 cleanup patches, I wrote
patch 7/7 that should fix the issue.

No memory leak was noticed through /sys/kernel/debug/dma-api/ or /proc/meminfo
running kmstest --flip for 300 frames in a loop for one hour with cached
buffers on the latest upstream kernel (merge of v4.11-rc1, drm-next and
drm-misc-next). With this patch series the same results should be reproducible
for cached buffers too, but I haven't been able to test that as I don't have
access to a display right now. Tomi, would you be able to perform tests ?

Patches for kms++ and kmstest to support cached mappings are available at

	git://git.ideasonboard.com/renesas/kmsxx.git omap/cache

Laurent Pinchart (7):
  drm: omapdrm: Remove remap argument to omap_gem_get_paddr()
  drm: omapdrm: Rename occurrences of paddr to dma_addr
  drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
  drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer()
  drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs
  drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  drm: omapdrm: DMA-unmap pages for all buffer types when freeing
    buffers

 drivers/gpu/drm/omapdrm/omap_drv.h        |   9 +-
 drivers/gpu/drm/omapdrm/omap_fb.c         |  25 ++--
 drivers/gpu/drm/omapdrm/omap_fbdev.c      |  15 ++-
 drivers/gpu/drm/omapdrm/omap_gem.c        | 196 ++++++++++++++++--------------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  12 +-
 5 files changed, 136 insertions(+), 121 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-04-15 21:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-10  9:39 [PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping Laurent Pinchart
2017-03-10  9:39 ` [PATCH 1/7] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 2/7] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
2017-03-10  9:39 ` [PATCH 3/7] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 4/7] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 5/7] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
2017-03-10  9:39 ` [PATCH 6/7] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
2017-03-10 12:13   ` Tomi Valkeinen
2017-04-15 21:47     ` Laurent Pinchart
2017-03-10  9:39 ` [PATCH 7/7] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
2017-03-15 11:17 ` [PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox