Re: memory barrier to ensure copy_to_user() completes

From: Alan Cox
Date: Fri Aug 31 2007 - 11:59:47 EST


> 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/