Page MenuHomeFreeBSD

vmbus bus_get_dma_tag implementation for arm64
ClosedPublic

Authored by schakrabarti_microsoft.com on Sep 5 2023, 10:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 11:39 AM
Unknown Object (File)
Tue, Dec 3, 11:43 PM
Unknown Object (File)
Sun, Dec 1, 2:20 PM
Unknown Object (File)
Mon, Nov 25, 2:18 PM
Unknown Object (File)
Sat, Nov 23, 8:51 PM
Unknown Object (File)
Fri, Nov 22, 6:41 PM
Unknown Object (File)
Fri, Nov 22, 7:08 AM
Unknown Object (File)
Thu, Nov 21, 1:03 PM
Subscribers

Details

Summary

In ARM64 Hyper-V UFS filesystem is getting corruption and those corruptions are consistently happening just after hitting a page boundary.
It is unable to correctly read disk blocks into buffers that are not aligned to 512-byte boundaries.
It happens because storvsc needs physically contiguous memory which may not be the case when bus_dma needs to create a bounce buffer.
This can happen when the destination is not cache-line aligned.

Hyper-V VMs have VMbus synthetic devices and PCI pass-thru devices that are added
dynamically via the VMbus protocol and are not represented in the ACPI DSDT. Only
the top level VMbus node exists in the DSDT. As such, on ARM64 these devices don't
pick up coherence information and default to not hardware coherent.

Test Plan

tested on Azure x86 and arm64

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 53488
Build 50379: arc lint + arc unit

Event Timeline

sys/dev/hyperv/vmbus/vmbus.c
200

This should be with the other bus interface functions

227

Why only on arm64? The DMA tag exists on other architectures.

233

Missing newline

1441

No need to put coherent in the softc, it's only used within this function.

sys/dev/hyperv/vmbus/vmbus.c
227

In x86 gen1 we dont specify CCA in ACPI, but it is coherent by default. So keeping the get_dma_tag for arm64 only.

sys/dev/hyperv/vmbus/vmbus.c
227

You should be passing the parent bus to bus_dma_tag_create. If the bus is coherent then the child will be.

sys/dev/hyperv/vmbus/vmbus.c
1446

bus_get_dma_tag(dev) should be used here instead of using NULL ? @andrew

sys/dev/hyperv/vmbus/vmbus.c
1446

Yes, because of how the driver works I think vmbus_res is the correct device to follow.

sys/dev/hyperv/vmbus/vmbus.c
1446

Okay. It will be acpi_container, which is the parent of vmbus, we need to follow. ACPI container is the child of ACPI.

  • Changed the function vmbus_get_dma_tag to create the tag inside.

Creating the tag in vmbus_get_dma_tag is incorrect as it will create a new tag each time a child asks for it. It was correct in vmbus_doattach as long as it is before any children are added, and you can use sc->vmbus_dev for the device.

  • Changed the function vmbus_get_dma_tag to create the tag inside.
This revision is now accepted and ready to land.Sep 12 2023, 5:45 PM