Re: memory barrier to ensure copy_to_user() completes



Which memory barrier do I require if I need to ensure that a
copy_to_user(dest, src, len) completes before the next statement?

Define "completes"


copy_to_user(dest, src, len) ;
//rmb(); OR wmb(); OR barrier(); OR mb(); ??????

Usually none of them

If I'm writing to hardware, and need to ensure the correct order, I'll
use wmb(), right?

No

e.g.:

#define HW_address1 20
#define HW_address2 40

*((int *)HW_address1) = 0x00000001;
wmb(); // is this good???
*((int *)HW_address2) = 0x00000010;

Linux doesn't define directly poking kernel addresses to hit hardware as
valid (and on many platforms it doesn't work). Use readl/writel and their
ordering is defined.

Read Documentation/io_ordering.txt and Docuemntation/pci.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • memory barrier to ensure copy_to_user() completes
    ... Which memory barrier do I require if I need to ensure that a ... copy_to_user(dest, src, len) completes before the next statement? ... Use wmb() to be sure that all of src is actually written to dest ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • ipf - freebsd 5.x and 6.x hangs
    ... ip route add default via x.x.x.x src y.y.y.y ... So I tried with ipf and execute following rule, ...
    (freebsd-stable)