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)
Thu, Nov 7, 8:51 AM
Unknown Object (File)
Wed, Nov 6, 3:47 PM
Unknown Object (File)
Fri, Oct 25, 3:13 PM
Unknown Object (File)
Fri, Oct 25, 3:13 PM
Unknown Object (File)
Fri, Oct 25, 2:55 PM
Unknown Object (File)
Fri, Oct 25, 1:56 PM
Unknown Object (File)
Wed, Oct 16, 2:30 PM
Unknown Object (File)
Tue, Oct 15, 12:56 AM
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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/hyperv/vmbus/vmbus.c
201

This should be with the other bus interface functions

227

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

233

Missing newline

1460

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
1465

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

sys/dev/hyperv/vmbus/vmbus.c
1465

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

sys/dev/hyperv/vmbus/vmbus.c
1465

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