mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Incorrect atomic usage in cx88-alsa driver
@ 2007-05-08  3:25 Benjamin Herrenschmidt
  0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2007-05-08  3:25 UTC (permalink / raw)
  To: Ricardo Cerqueira, Carvalho Chehab; +Cc: Linux Kernel list


Hi !

So I see this construct:

	if (test_and_set_bit(0, &chip->opened))
		return -EBUSY;

	.../...

	return 0;
_error:
	dprintk(1,"Error opening PCM!\n");
	clear_bit(0, &chip->opened);
	smp_mb__after_clear_bit();
	return err;

So that's basically an attempt at doing a spinlock. The problem is your
barrier is wrong at the end. Better would be:

done:
	smp_mb__before_clear_bit();
	clear_bit(0, &chip->opened);

Though it's still less optimal that doing:

	if (!spin_trylock(...))
		goto bail;

	.../...

done:
	spin_unlock(...)

If you really want to stick to bitops, then you may want to look at
Nick's upcoming patches adding some bitops with appropriate lock
semantics.


Cheers,
Ben.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-08  3:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-08  3:25 Incorrect atomic usage in cx88-alsa driver Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®