[ prevent ehci_takecontroller from looping at infinite ]
Hans Petter Selasky
hselasky at c2i.net
Mon Jan 12 10:28:32 PST 2009
On Monday 12 January 2009, lementec fabien wrote:
> Hi,
>
> On an Acer Aspire 5500, freebsd is hanging in
> usb/ehci_pci in the ehci_takecontroller function.
> The device pci conf space reads invalid values
> 0xffffffff, making the function looping at infinite,
> thus never entering ehci_init.
>
> I dont know if the problem does not come from
> earlier, but I did the following patch:
Hi,
The EHCI PCI is looping infinitely in USB1 because "int eecp" is a signed
number. Sign-extension happens during the shift inside XXX_NEXT(), and it
will actually loop in all cases where "cparams & 0x80000000" is non-zero!
Try making the eecp variable "uint32_t".
This is not a problem with USB2. Where "eecp" is already unsigned.
--HPS
>
> --- orig/sys/dev/usb/ehci_pci.c 2009-01-11 06:14:12.000000000 +0100
> +++ new/sys/dev/usb/ehci_pci.c 2009-01-11 06:15:14.000000000 +0100
> @@ -549,6 +549,10 @@
>
> cparams = EREAD4(sc, EHCI_HCCPARAMS);
>
> + /* prevent from looping ad infinite. ehci_init will fail. */
> + if (cparams == 0xffffffff)
> + return ;
> +
> /* Synchronise with the BIOS if it owns the controller. */
> for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
> eecp = EHCI_EECP_NEXT(eec)) {
> @@ -584,6 +588,9 @@
> int eecp;
>
> cparams = EREAD4(sc, EHCI_HCCPARAMS);
> + if (cparams == 0xffffffff)
> + return ;
> +
> for (eecp = EHCI_HCC_EECP(cparams); eecp >= 0x40;
> eecp = EHCI_EECP_NEXT(eec)) {
> eec = pci_read_config(self, eecp, 4);
>
> I hop it helps,
>
> Fabien.
More information about the freebsd-usb
mailing list