@samitouri / QOSamiQemu / commits / 11438bb2b4

hw/usb/hcd-ehci: Add ctrldssegment-default property

When 64-bit addressing is supported, the Linux EHCI driver programs the segment register to zero. See ehci_run function: https://github.com/torvalds/linux/blob/master/drivers/usb/host/ehci-hcd.c The driver comment also notes that descriptor structures allocated from the DMA pool use segment zero semantics. Descriptor memory is allocated using the DMA API. The platform driver configures a 64-bit DMA mask so memory can be allocated above 4GB. See ehci_platform_probe function: https://github.com/torvalds/linux/blob/master/drivers/usb/host/ehci-platform.c On AST2700 platforms, system DRAM is mapped above 4GB at 0x400000000. As a result, descriptor addresses constructed directly from the guest EHCI registers do not match the actual system address used by the controller when fetching queue heads (QH) and queue element transfer descriptors (qTD). Add a ctrldssegment-default property so platforms can provide a descriptor address offset when constructing descriptor addresses. This allows systems where DRAM resides above 4GB to access EHCI descriptors correctly. The default value is zero, so existing machines are not affected. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260713032704.3583103-8-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Jamin Lin committed Jul 13, 2026 at 03:27 UTC 11438bb2b44de3724cde65fc9dfbc423044d0019
2 files changed +5 -1
hw/usb/hcd-ehci.c
+1
@@ -1162,6 +1162,7 @@ static void ehci_opreg_write(void *ptr, hwaddr addr,
1162 "64-bit addressing capability is disabled\n");
1163 return;
1164 }
1165 + val |= s->ctrldssegment_default;
1166 break;
1167
1168 case ASYNCLISTADDR:
hw/usb/hcd-ehci.h
+4 -1
@@ -268,6 +268,7 @@ struct EHCIState {
268 */
269 bool migrate_fetch_addr_64bit;
270 bool caps_64bit_addr;
271 + uint32_t ctrldssegment_default;
272
273 /*
274 * EHCI spec version 1.0 Section 2.3
@@ -333,7 +334,9 @@ struct EHCIState {
334 DEFINE_PROP_BOOL("x-migrate-fetch-addr-64bit", _state, \
335 ehci.migrate_fetch_addr_64bit, true), \
336 DEFINE_PROP_BOOL("caps-64bit-addr", _state, \
336 - ehci.caps_64bit_addr, false)
337 + ehci.caps_64bit_addr, false), \
338 + DEFINE_PROP_UINT32("ctrldssegment-default", _state, \
339 + ehci.ctrldssegment_default, 0)
340
341 extern const VMStateDescription vmstate_ehci;
342