Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2009 19:30:50 +0100
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        freebsd-usb@freebsd.org
Subject:   Re: [ prevent ehci_takecontroller from looping at infinite ]
Message-ID:  <200901121930.51916.hselasky@c2i.net>
In-Reply-To: <e6d291490901120938ya302a34ue68bf381069ed220@mail.gmail.com>
References:  <e6d291490901120938ya302a34ue68bf381069ed220@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901121930.51916.hselasky>