Page MenuHomeFreeBSD

gve: Use load-acquire to fetch generation bits
ClosedPublic

Authored by jtranoleary_google.com on Fri, May 16, 7:33 PM.
Tags
None
Referenced Files
F119324966: D50384.diff
Sat, Jun 7, 4:25 PM
F119324965: D50384.diff
Sat, Jun 7, 4:25 PM
F119324964: D50384.diff
Sat, Jun 7, 4:25 PM
F119324963: D50384.diff
Sat, Jun 7, 4:25 PM
F119324962: D50384.diff
Sat, Jun 7, 4:25 PM
Unknown Object (File)
Sat, Jun 7, 6:08 AM
Unknown Object (File)
Fri, Jun 6, 9:36 PM
Unknown Object (File)
Sun, Jun 1, 12:06 PM
Subscribers

Details

Summary

When running the driver using the DQO queue format, we must load the
generation bit and check it before possibly reading the rest of the
descriptor's fields.

Previously, we guarded against reordering of reads using an explicit
thread fence. This commit changes the thread fence to a load with
acquire semantics. Because the tx and rx generation fields are in a
bitfield, we cannot explicitly address them in an atomic load. Instead
we load the respective containing bytes in the descriptor and mask them
appropriately.

Signed-off-by: Jasper Tran O'Leary <jtranoleary@google.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/gve/gve_dqo.h
270

Since the field itself is in a uint16_t bitmask, aren't these values endian-dependent?

sys/dev/gve/gve_dqo.h
270

Correct, the offset and mask here match the endianness of the only device that uses the DQO queue format. The same goes for the TX descriptor offset and mask. Does this answer your question?

markj added inline comments.
sys/dev/gve/gve_dqo.h
270

You might consider adding a compile-time assertion that the kernel is little-endian, if that's not already present somehow.

This revision is now accepted and ready to land.Tue, May 20, 8:10 PM
jtranoleary_google.com added inline comments.
sys/dev/gve/gve_dqo.h
270

I'm open to adding a compile-time assertion, but I don't understand yet why it'd apply here. If I'm loading only a single byte, shouldn't kernel endianness not have any effect?

sys/dev/gve/gve_dqo.h
270

Sorry, I wasn't thinking too clearly--the descriptor layout is solely defined by the device, as you already said. So please ignore me.