[PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux