Skip to contentSkip to conversation

Problem of initialization of platform-ehci-usb in sbsa-ref

DISCUSSION 王宇泉 3 participants 7 messages Apr 24, 2023 – May 9, 2023

lore
Share & tools
lore

王宇泉

author
#0 lore raw

Hi Peter,

As a junior OS engineer, I met a problem of initialization of platform-ehci-usb in sbsa-ref recently.

The result of sbsa-acs(UEFI Shell application) on sbsa-ref shows that "Peripheral: Num of USB controllers: 0".

And I found that the platform-ehci-usb in qemu is a 32-bits DMA device while our sbsa-ref machine does not own

DRAM memory below 4G. It seems like a contradiction point.Connecting SMMUv3 with the platform EHCI

in order to probe it can be a goood way ? Or there are some detail usage I ignored?​

Thanks

Yuquan Wang

信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.This mail communication is confidential.Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.

#1 lore raw
Quoted 7 lines · 王宇泉

As a junior OS engineer, I met a problem of initialization of platform-ehci-usb in sbsa-ref recently.

The result of sbsa-acs(UEFI Shell application) on sbsa-ref shows that "Peripheral: Num of USB controllers: 0".

And I found that the platform-ehci-usb in qemu is a 32-bits DMA device while our sbsa-ref machine does not own

DRAM memory below 4G. It seems like a contradiction point.

This definitely doesn't seem like an intentional thing. What specifically do you mean by "32-bits DMA device" ? Is our implementation of this device accidentally not handling addresses above 4GB? Or is the specification of the device itself limited to 4GB addresses? Or is this a guest driver problem?

thanks
-- PMM

#2 lore raw
Quoted 18 lines

On 2023-04-25 16:34:04, Peter Maydell replied:

Quoted 7 lines · 王宇泉

As a junior OS engineer, I met a problem of initialization of platform-ehci-usb in sbsa-ref recently.

The result of sbsa-acs(UEFI Shell application) on sbsa-ref shows that "Peripheral: Num of USB controllers: 0".

And I found that the platform-ehci-usb in qemu is a 32-bits DMA device while our sbsa-ref machine does not own

DRAM memory below 4G. It seems like a contradiction point.

This definitely doesn't seem like an intentional thing. What specifically do you mean by "32-bits DMA device" ? Is our implementation of this device accidentally not handling addresses above 4GB? Or is the specification of the device itself limited to 4GB addresses? Or is this a guest driver problem?

Quoted 2 lines

thanks
-- PMM

Hi,

Maybe the specific explanation is that qemu implements that:
In hw/usb/hcd-ehci.c:
void usb_ehci_init(EHCIState *s, DeviceState *dev) {
...
"s->caps[0x08] = 0x80;"

According to EHCI spec version 1.0 Section 2.2.4, the set of "0x80" on Host Controller Capability Parameters Register means this(qemu) EHCI Host Controller does not have 64-bit Addressing Capability. So, I think above information can prove that our implementation of this device can not handle addresses above 4GB without the help of SMMU.

Thanks
Yuquan

信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.This mail communication is confidential.Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.

#3 lore raw
Quoted 26 lines · Yuquan Wang
Quoted 10 lines

On 2023-04-25 16:34:04, Peter Maydell replied:

Quoted 6 lines · 王宇泉

As a junior OS engineer, I met a problem of initialization of platform-ehci-usb in sbsa-ref recently.

The result of sbsa-acs(UEFI Shell application) on sbsa-ref shows that "Peripheral: Num of USB controllers: 0".

And I found that the platform-ehci-usb in qemu is a 32-bits DMA device while our sbsa-ref machine does not own

Quoted 8 lines
Quoted 1 line

DRAM memory below 4G. It seems like a contradiction point.

This definitely doesn't seem like an intentional thing. What specifically do you mean by "32-bits DMA device" ? Is our implementation of this device accidentally not handling addresses above 4GB? Or is the specification of the device itself limited to 4GB addresses? Or is this a guest driver problem?

Maybe the specific explanation is that qemu implements that:
In hw/usb/hcd-ehci.c:
void usb_ehci_init(EHCIState *s, DeviceState *dev) {
...
"s->caps[0x08] = 0x80;"

Quoted 4 lines

According to EHCI spec version 1.0 Section 2.2.4, the set of "0x80" on Host Controller Capability Parameters Register means this(qemu) EHCI Host Controller does not have 64-bit Addressing Capability.

Ah, I see; thanks for providing the reference to the spec and the source code.

Gerd, is there a particular reason our EHCI controller only claims to be able to do 32-bit DMA ? Should we give it a QOM property so boards that only have RAM above the 4GB mark can use it ? (Would the x86 PC benefit from allowing >4GB DMA?)

thanks
-- PMM

#4 lore raw

Hi,

Quoted 4 lines

Gerd, is there a particular reason our EHCI controller only claims to be able to do 32-bit DMA ? Should we give it a QOM property so boards that only have RAM above the 4GB mark can use it ? (Would the x86 PC benefit from allowing >4GB DMA?)

Can be done, but it's more complex than just a property. All the EHCI descriptors exist in two variants, one for 32bit and one for 64bit. The current code base only supports the 32bit versions.

Alternatives:
(a) use an iommu to map 32bit to 64bit dma addresses.
(b) use xhci instead of ehci.

I'd recommend (b) as the xhci hardware design is much more virtualization-friendly.

take care,
Gerd

#5 lore raw
Quoted 13 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

Gerd, is there a particular reason our EHCI controller only claims to be able to do 32-bit DMA ? Should we give it a QOM property so boards that only have RAM above the 4GB mark can use it ? (Would the x86 PC benefit from allowing >4GB DMA?)

Can be done, but it's more complex than just a property. All the EHCI descriptors exist in two variants, one for 32bit and one for 64bit. The current code base only supports the 32bit versions.

Quoted 6 lines

Alternatives:
(a) use an iommu to map 32bit to 64bit dma addresses.
(b) use xhci instead of ehci.

I'd recommend (b) as the xhci hardware design is much more virtualization-friendly.

Thanks. Leif, do you have any preference there?

-- PMM

#6 lore raw
In reply to Peter Maydell
Quoted 18 lines

On 2023-04-25 16:34:04, Peter Maydell replied:

Quoted 7 lines · 王宇泉

As a junior OS engineer, I met a problem of initialization of platform-ehci-usb in sbsa-ref recently.

The result of sbsa-acs(UEFI Shell application) on sbsa-ref shows that "Peripheral: Num of USB controllers: 0".

And I found that the platform-ehci-usb in qemu is a 32-bits DMA device while our sbsa-ref machine does not own

DRAM memory below 4G. It seems like a contradiction point.

This definitely doesn't seem like an intentional thing. What specifically do you mean by "32-bits DMA device" ? Is our implementation of this device accidentally not handling addresses above 4GB? Or is the specification of the device itself limited to 4GB addresses? Or is this a guest driver problem?

Quoted 2 lines

thanks
-- PMM

Hi,

Maybe the specific explanation is that qemu implements that:
In hw/usb/hcd-ehci.c:
void usb_ehci_init(EHCIState *s, DeviceState *dev) {
...
"s->caps[0x08] = 0x80;"

According to EHCI spec version 1.0 Section 2.2.4, the set of "0x80" on Host Controller Capability Parameters Register means this(qemu) EHCI Host Controller does not have 64-bit Addressing Capability. So, I think above information can prove that our implementation of this device can not handle addresses above 4GB without the help of SMMU.

Thanks
Yuquan

信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.This mail communication is confidential.Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.