Re: arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars

From: Roland Dreier
Date: Tue Apr 21 2009 - 13:08:08 EST


> Okay, I'm going to throw in yet another wrench in the machinery.

> There are devices which really only want to use writeq() if it is an
> inexpensive (no x86 MMX hacks) atomic operation.

Interesting example. It does seem there are several reasonable hardware
design patters where a driver needs to know if writeq() and/or readq()
is atomic.

> One way to deal with that is the <linux/io64*.h> method, another is with
> feature test macros.

A further idea would be to add readq_atomic()/writeq_atomic() that
behave as the current 64-bit versions do: a single instruction,
generates a single bus cycle, etc. Then drivers that really need to
use the full semantics that the 64-bit versions gave can use those,
while drivers that just want a convenient way to read a 64-bit register
can use readq()/writeq().

This only makes sense if we define a 32-bit fallback for
readq()/writeq() for all 32-bit architectures -- in fact it would be
good to do it in asm-generic so that there can be a single
implementation that guarantees that non-atomic versions always do, say,
low 32 bits then high 32 bits. (So eg niu can use the generic version)
And then drivers like drivers/infiniband/hw/mthca can be switched to
"#ifndef writeq_atomic <...hardware specific fallback...>"

However I worry that this just leaves driver authors too much rope.
Choosing readq_atomic() vs. readq() is just one more thing to get wrong.

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