Re: NIU driver: Sun x8 Express Quad Gigabit Ethernet Adapter

Ben Hutchings
2008-11-12T12:54:57Z

On Wed, 2008-11-12 at 04:11 -0800, David Miller wrote:
[...]
> So the following patch should fix this bug. writeq() should
> be OK as-is, so doesn't need a similar change.
>
> diff --git a/drivers/net/niu.c b/drivers/net/niu.c
> index 9acb5d7..d8463b1 100644
> --- a/drivers/net/niu.c
> +++ b/drivers/net/niu.c
> @@ -51,8 +51,7 @@ MODULE_VERSION(DRV_MODULE_VERSION);
> #ifndef readq
> static u64 readq(void __iomem *reg)
> {
> - return (((u64)readl(reg + 0x4UL) << 32) |
> - (u64)readl(reg));
> + return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32);
> }

Since there's no sequence point between the reads, there's no guarantee
that the reads happen in the order written (regardless of barriers
inside readl()). This needs to be split into two statements.

Ben.

--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.