[PATCH] nvme: avoid cqe corruption when update at the same time as read

Marta Rybczynska mrybczyn at kalray.eu
Thu Mar 10 03:08:48 PST 2016


----- Le 9 Mar 16, à 18:08, Christoph Hellwig hch at infradead.org a écrit :

> On Sat, Mar 05, 2016 at 08:23:15AM +0100, Marta Rybczynska wrote:
>> The cqe structure read normally happens from lower to upper addresses
>> and the validity bit (status) is at the highest address. If the PCI
>> updates the memory when the cqe is read by multiple non-atomic loads,
>> the structure may be corrupted. Avoid this by reading the status
>> first and then the whole structure.
> 
> Doing the phase check separately sounds sensible to me, but how about
> doing something like the version below, which ensures we only read the
> whole cqe after the check, and cleans things up a bit by using a common
> helper:
> 

Looks like a good refactoring to me. However, it seems to me that in
nvme_cqe_valid we should be checking for phase, not for head.

I will test it and re-submit.

Regards,
Marta Rybczynska



More information about the Linux-nvme mailing list