Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: The difference between DSB and DMB instructions of ARM1176JZF-S - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The difference between DSB and DMB instructions of ARM1176JZF-S Data Syncronization Barrier (DSB) / Data Memory Barrier (DMB) Rate Topic: -----

#1 User is offline   Vincent Wu 

  • Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 30-September 11

Posted 30 September 2011 - 06:06 AM

Dear Sirs,

I am currently testing a comstomized SOC with ARM1176JZF-S core, 32KB-cache on Linux-2.6.31.2, and I encountered a cache-DMA data coherence problem in SD host driver. The phenonmenon is random data error while file copying. The error occurs once or twice during 100 iterations of 1GB-file copying test.

The implementation of the DMA operation has followed the suggestion of the kernel document “DMA-API.txt”, that is, the DMA_TO_DEVICE synchronisation is done after the last modification of the memory region that will be read by the DMA device, and the DMA_FROM_DEVICE synchronisation is done before the driver accesses data that was changed by the DMA device. However, the data coherence still cannot be guaranteed.

I referred to an ARM technical support knowledge article at http://infocenter.ar...qs/ka14041.html . For the ARMv6\v7 speculative execution, the DSB and DMB instructions are necessary to ensure data access correctness. The Linux ARMv6 cache operation has utlized DSB instruction, “mcr p15, 0, r0, c7, c10, 4” in the kernel source file, “linux-2.6.31.2/arch/arm/mm/cache-v6.S” to handle the speculative execution issue, but that cannot fix the stale data problem in my case.

Finally, I added a DMB instruction, “mcr p15, 0, r0, c7, c10, 5” after each cache invalidation and clean operation, and then the data error problem does not occur anymore. But I am still not sure if my modification is reasonable. I have some questions about the DSB and DMB instructions as listed below:

1. The Linux kernel utilizes DSB instruction only. Is the DSB instruction sufficient for ensuring the cache coherence?

2. If the DSB instruction is sufficient, why is the stale data still written into the SD card until I added a DMB instruction after the cache invalidation and clean operation?

3. Although the ARM technical article has described the functions of DSB and DMB instructions, I still cannot tell the critical difference between the two instructions. Could anyone explain?

Thanks for helping me!!

This post has been edited by Vincent Wu: 30 September 2011 - 06:13 AM

0

#2 User is offline   isogen74 

  • Super Contributor
  • PipPipPipPip
  • Group: Members
  • Posts: 1098
  • Joined: 20-March 07

Posted 30 September 2011 - 12:53 PM

http://forums.arm.co...807-dmb-vs-dsb/
When optimizing software, consider that the quickest code to run is the bit you removed from the call path.
2

#3 User is offline   Vincent Wu 

  • Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 30-September 11

Posted 03 October 2011 - 02:57 AM

瀏覽文章引用框(isogen74 @ 30 September 2011 - 12:53 PM)



Dear iosgen74,
Thank you for your reply.

Actually, I had read the article which you posted before I posted this issue. In my understanding, DSB is to synchronize both data modification and instruction stream, and DMB is to synchronize data modification only, so a DSB instruction after cache invalidation and write-back is sufficient.

However, in my case, I need to add an additional DMB instruction to ensure the data coherence, and it conflicts my previous understanding. Does DMB execute something that DSB does not perform?

This post has been edited by Vincent Wu: 03 October 2011 - 02:59 AM

0

#4 User is offline   isogen74 

  • Super Contributor
  • PipPipPipPip
  • Group: Members
  • Posts: 1098
  • Joined: 20-March 07

Posted 03 October 2011 - 08:02 AM

引用

Does DMB execute something that DSB does not perform?


No, the DMB is a sub-set of the DSB behavior. However if you are performing cache maintenance operations, then a DSB is what you want to use, not a DMB. You want to ensure that the instruction's behavior has completed executing (i.e. cache maintenance complete) before executing following instructions. The DMB instruction is only really concerned with explicit memory accesses (loads and stores), which is why it doesn't help for cache maintenance.

The following guide provides more information on barriers, and gives more examples:
http://infocenter.ar...ookbook_A08.pdf
Cheers,
Iso

This post has been edited by isogen74: 03 October 2011 - 08:04 AM

When optimizing software, consider that the quickest code to run is the bit you removed from the call path.
1

#5 User is offline   Vincent Wu 

  • Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 30-September 11

Posted 06 October 2011 - 08:20 AM

View Postisogen74, on 03 October 2011 - 08:02 AM, said:



No, the DMB is a sub-set of the DSB behavior. However if you are performing cache maintenance operations, then a DSB is what you want to use, not a DMB. You want to ensure that the instruction's behavior has completed executing (i.e. cache maintenance complete) before executing following instructions. The DMB instruction is only really concerned with explicit memory accesses (loads and stores), which is why it doesn't help for cache maintenance.



Sounds like I had gone a wrong way. Thanks for your explanation!

For the Linux version earlier than 2.6.34, I found a patch to solve DMA-cache coherence problem due to speculative execution.
http://nv-tegra.nvid...8e09f1ee#patch2
This patch seems able to work fine in my case.
1

#6 User is offline   isogen74 

  • Super Contributor
  • PipPipPipPip
  • Group: Members
  • Posts: 1098
  • Joined: 20-March 07

Posted 06 October 2011 - 10:17 AM

No problem; glad of be of some help.

Thanks for posting the link to the patch; I wasn't aware of that one =)

Iso
When optimizing software, consider that the quickest code to run is the bit you removed from the call path.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic