Re: [patch] USB after second suspend/resume on ThinkPads.

From: Edward Tomasz Napierała <trasz_at_FreeBSD.org>
Date: Thu, 19 Jun 2014 12:44:56 +0200
On 0619T0935, Alexandr Krivulya wrote:
> 18.06.2014 12:29, Edward Tomasz Napierała пишет:
> > On 0618T1108, Alexandr Krivulya wrote:
> >> 16.06.2014 22:21, Edward Tomasz Napierała пишет:
> >>> Hi.  Patch below should fix a problem where USB stops working after
> >>> _second_ suspend/resume, which happens on various ThinkPad models.
> >>> Please test, and report both success stories and failures.  If nothing
> >>> comes up, I'll commit it in a week or so.
> >>>
> >>> (Btw, has anyone encountered the problem on hardware other than ThinkPads?)
> >>>
> >>>
> >>> Index: sys/dev/acpi_support/acpi_ibm.c
> >>> ===================================================================
> >>> --- sys/dev/acpi_support/acpi_ibm.c	(revision 267417)
> >>> +++ sys/dev/acpi_support/acpi_ibm.c	(working copy)
> >>> _at__at_ -169,6 +169,9 _at__at_ struct acpi_ibm_softc {
> >>>  	int		light_get_supported;
> >>>  	int		light_set_supported;
> >>>  
> >>> +	/* USB power workaround */
> >>> +	ACPI_HANDLE	power_handle;
> >>> +
> >>>  	/* led(4) interface */
> >>>  	struct cdev	*led_dev;
> >>>  	int		led_busy;
> >>> _at__at_ -365,6 +368,7 _at__at_ acpi_ibm_attach(device_t dev)
> >>>  {
> >>>  	struct acpi_ibm_softc	*sc;
> >>>  	devclass_t		ec_devclass;
> >>> +	ACPI_STATUS		status;
> >>>  
> >>>  	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
> >>>  
> >>> _at__at_ -448,6 +452,17 _at__at_ acpi_ibm_attach(device_t dev)
> >>>  	if (sc->light_set_supported)
> >>>  		sc->led_dev = led_create_state(ibm_led, sc, "thinklight", sc->light_val);
> >>>  
> >>> +	/*
> >>> +	 * Obtain a handle to the power resource available on many models.
> >>> +	 * This must be turned on manually upon resume. Otherwise the system
> >>> +	 * may, for instance, resume from S3 with usb(4) powered down.
> >>> +	 */
> >>> +	status = AcpiGetHandle(sc->handle, "\\_SB.PCI0.LPC.EC.PUBS", &sc->power_handle);
> >>> +	if (ACPI_FAILURE(status)) {
> >>> +		device_printf(dev, "Failed to get power handle\n");
> >>> +		return (status);
> >>> +	}
> >>> +
> >>>  	return (0);
> >>>  }
> >>>  
> >>> _at__at_ -476,6 +491,7 _at__at_ static int
> >>>  acpi_ibm_resume(device_t dev)
> >>>  {
> >>>  	struct acpi_ibm_softc *sc = device_get_softc(dev);
> >>> +	ACPI_STATUS status;
> >>>  
> >>>  	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
> >>>  
> >>> _at__at_ -495,6 +511,15 _at__at_ acpi_ibm_resume(device_t dev)
> >>>  
> >>>  		acpi_ibm_sysctl_set(sc, i, val);
> >>>  	}
> >>> +	if (sc->power_handle != NULL) {
> >>> +		status = AcpiEvaluateObject(sc->power_handle,
> >>> +		    "_ON", NULL, NULL);
> >>> +		if (ACPI_FAILURE(status)) {
> >>> +			device_printf(dev, "failed to switch %s on - %s\n",
> >>> +			    acpi_name(sc->power_handle),
> >>> +			    AcpiFormatException(status));
> >>> +		}
> >>> +	}
> >>>  	ACPI_SERIAL_END(ibm);
> >>>  
> >>>  	return (0);
> >> Hi. I've never seen this problem before on my ThinkPad E530. However, I
> >> have applied this patch and after reboot all sysctl oids related to
> >> acpi_ibm disappeared.
> >>
> >> root_at_thinkpad:/home/shurik # kldstat|grep ibm
> >> 9 1 0xffffffff82190000 77e8 acpi_ibm.ko
> >>
> >> root_at_thinkpad:/home/shurik # sysctl dev.acpi_ibm
> >> root_at_thinkpad:/home/shurik #
> >>
> >> And in dmesg I see this errors:
> >>
> >> root_at_thinkpad:/home/shurik # dmesg -a|grep ibm
> >> acpi_ibm0: <IBM ThinkPad ACPI Extras> on acpi0
> >> acpi_ibm0: Failed to get power handle
> >> device_attach: acpi_ibm0 attach returned 5
> > Ok, I'll make that attach problem non-fatal.
> >
> > Just to make sure: without the patch you don't have any problems
> > with USB after multiple suspend/resume cycles, and you don't use
> > any workarounds to make it work, eg. setting the dev.uhci.0.wake=1,
> > or making USB ports always powered on in BIOS?
> >
> Exactly. I have no any problems with USB. Average uptime is two-three
> weeks with everyday suspend/resume cycle. And I don't use any special
> settings related to usb in loader.conf or sysctl.conf. The only
> difference with GENERIC - all usb support built and loaded as modules.
> In my BIOS i have turned on such settings:
> 
> - USB Support
> - UEFI BIOS Support
> - Always On USB

The last one is off by default, right?  Turning it on actually
works around the problem in earlier Thinkpad models.  Could you
try to set it to default (disable) and see if the problem still
doesn't occur?
Received on Thu Jun 19 2014 - 08:45:01 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:50 UTC