-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Sonntag, 20. Juni 2004 01:20 schrieb Alan Stern:
> On Sat, 19 Jun 2004, Oliver Neukum wrote:
> 
> > Hi,
> > 
> > there's an SMP memory ordering issue with usb_get/set_intfdata.
> > If a CPU reorders writes, another CPU may use usb_get_intfdata
> > to get a pointer which is uninitialised because the initialising CPU
> > has not yet written the data.
> > This problem is not confined to USB, so I tackled it at the root.
> > Comments?
> 
> >  static inline void
> >  class_set_devdata (struct class_device *dev, void *data)
> >  {
> > +   smp_wmb();
> >     dev->class_data = data;
> >  }
> >  
> > @@ -310,6 +311,7 @@
> >  static inline void
> >  dev_set_drvdata (struct device *dev, void *data)
> >  {
> > +   smp_wmb();
> >     dev->driver_data = data;
> >  }
> 
> Shouldn't these barrier instructions be placed _after_ the assignments?

No.

> Regardless, I think this is a non-problem.  If a driver calls 
> usb_get_intfdata() during probe() or disconnect() then the usb_device is 
> locked.  Another processor that doesn't synchronize by locking shouldn't 
> have any expectations about which value it will see.  If it does

Correct.

> synchronize by a lock then it will always see the correct value, since the 
> unlocking functions -- up() and spin_unlock() -- include write barriers.

The issue is not the pointer itself. The problem is the memory the pointer
is pointing to. Iff the new pointer is returned the caller can expect that
that area of memory is initialised. Therefore the barrier must be before
the assignment. If you depend on the lock's barrier there's a window
in which the assumption is not necessarily true.

        Regards
                Oliver
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA1M0FbuJ1a+1Sn8oRAo8cAJ4pMQnWGeFeF43Q9XyU7jhwLfEU3QCggjcA
Ve3uQuki9bbgATIfVMR/71Q=
=usgw
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to