Does every dma_map_single call require a corresponding dma_unmap_single?


I'm porting a large code base to a Linux kernel device driver. The ASIC uses a huge number of DMA channels.

I kmalloc memory with GFP_KERNEL|GFP_DMA. Before starting the DMA, I use dma_map_single to get the hardware (physical) memory address to feed to the hardware. (Also does a flush/invalidate the memory from dcache?) I sometimes need CPU access to the data once DMA is complete, but not often. Before I access the data via code, I do a dma_unmap_single to avoid cache coherency issues.

In the cases where I do not ever need CPU access, do I still need to call dma_unmap_single? Should I dma_unmap_single every pointer I dma_map_single? Does dma_map_single consume a resource (e.g., table entry) that dma_unmap_single will release?

The DMA-API.txt isn't clear on good DMA memory hygiene.



With dma_map_single you map the memory for DMA transfer. You get the physical pointer to the memory, so the device can DMA to that address.

With dma_unmap_single you unmap the memory mapped above. You should do this when your transfers are over.

You can <em>map</em> a memory region, and use it for multiple DMA transfers and then you <em>unmap</em> when the job is done. Each time you want to access the DMA memory you must synchronize it. If the device is going to access the memory, you should do dma_sync_single_for_device; it the host is going to access the memory, you should do dma_sync_single_for_cpu


the dma_map api may allocate bounce buffers, in this case, you will need to call the dma_unmap function.


  • Android permissions categories and DELETE_PACKAGES and INSTALL_PACKAGES permissions
  • 神经网络中的反向传播法
  • PostgreSQL query on text array value
  • remote emacs client connects, but doesn't create new frame in terminal
  • How should I modify this SQL statement?
  • Default value for resultCode when activity finishes
  • How to implement a loading screen for a SPA written in Vue.js?
  • How was `val hash : 'a -> int` was implemented in OCaml?
  • WP7 Mango - How to get an IP address for a given hostname
  • Way to draw NSString on a curved path?
  • Android Intent Database
  • ld: warning: section __DATA/__objc_imageinfo__DATA has unexpectedly large size
  • How to show a comma separated number with StringFormat in XAML?
  • How to clone an object in Flex?
  • SQL: how to limit a join on the first found row?
  • Why would overwriting .GetHashCode clear these databound values in WinForms?
  • Pandas better way to get rows that has all columns null except one
  • SVG, Raphael.js, JSON data - can't figure out how to get description to appear
  • MySql query to find rooms available given dates 'From' and 'to'
  • How to set the minimum SDK Build Tools version required in an Android Studio project?
  • three.js — fit a background image panorama
  • PhoneStateListener memory leak - android
  • Average of every two lines for all columns except the first one
  • Proper Form of API request to Blogger using Java/App Engine -error 401
  • WP Job Manager: Creating a custom job search form
  • ES not listening to external requests
  • import cv2 doesn't give error on command-Prompt but error on IDLE on Windows 10, Python 3.6.4
  • Two way binding not working in ng-bootstrap radio button in an angular reactive form
  • JQuery Cycle Plugin - Delay Interval Between Slides Question
  • How to get WinForms custom control's default value to be respected when first dropped on a form
  • Google Compute instance receiving email
  • Sorting Custom Listview Items Using Spinner Android
  • jQuery - Prevent activation on first click
  • Generate a runnable jar and include libraries in it with Maven
  • create circular Auto Horizontal Scroll View?
  • Getting/building the SQL (with parameters) from NHibernate 3.2
  • Creating Dictionaries from Lists inside of Dictionaries
  • SQL query for game rental website - game delivery report
  • dmtracedump doesn't work, HELP!
  • jQuery scrollTop if URL has hash