Page MenuHomeFreeBSD

amdiommu: Fix device table segment base register offsets
ClosedPublic

Authored by jah on Mon, Nov 25, 11:32 PM.
Tags
None
Referenced Files
F104719391: D47752.diff
Mon, Dec 9, 2:19 AM
Unknown Object (File)
Fri, Dec 6, 3:28 AM
Unknown Object (File)
Fri, Dec 6, 1:57 AM
Unknown Object (File)
Tue, Dec 3, 9:09 PM
Unknown Object (File)
Tue, Dec 3, 1:02 PM
Unknown Object (File)
Tue, Dec 3, 1:02 PM
Unknown Object (File)
Tue, Dec 3, 12:53 PM
Unknown Object (File)
Fri, Nov 29, 7:14 PM

Details

Summary

Segment base registers are at 8-byte intervals, while the register
write helper takes a byte-aligned offset. This fixes
DEV_TAB_HARDWARE_ERROR events and associated peripheral I/O failures
on an Epyc-based system with 8-segment device tables.

Diff Detail

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

Event Timeline

jah requested review of this revision.Mon, Nov 25, 11:32 PM
This revision is now accepted and ready to land.Mon, Nov 25, 11:40 PM
crest_freebsd_rlwinm.de added inline comments.
sys/x86/iommu/amd_drv.c
280

Do we have an appropriate struct type to allow a more (human) friendly way to write this? e.g. (i - 1) * sizeof(struct some_struct) instead of (i - 1) << magic_number?

sys/x86/iommu/amd_drv.c
280

And if we don't have a struct that matches the bitfields inside reg would (i - 1) * sizeof(reg) make sense?

sys/x86/iommu/amd_drv.c
280

Is this better?

		reg = i == 0 ? AMDIOMMU_DEVTAB_BASE : AMDIOMMU_DEVTAB_S1_BASE +
		    (i - 1) * (AMDIOMMU_DEVTAB_S2_BASE -
		    AMDIOMMU_DEVTAB_S1_BASE));
sys/x86/iommu/amd_drv.c
280

If we're that concerned about readability here, it seems as though it would be better to just have a small static array with the relevant DEVTAB offset in each entry. That would avoid the special "i == 0" case and would also allow us to add a KASSERT and to easily add entries if AMD should ever decide to add support for more than 8 segments (which would also necessitate placing the new segment base registers in some area not contiguous with the current S1_BASE-S7_BASE)

sys/x86/iommu/amd_drv.c
280