From owner-freebsd-current@FreeBSD.ORG Mon Jun 16 19:22:00 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C22857BC for ; Mon, 16 Jun 2014 19:22:00 +0000 (UTC) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A3C324EE for ; Mon, 16 Jun 2014 19:22:00 +0000 (UTC) Received: by mail-wi0-f179.google.com with SMTP id cc10so4640998wib.12 for ; Mon, 16 Jun 2014 12:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mail-followup-to :mime-version:content-type:content-disposition:user-agent; bh=b1xEbPkxWaw4sUfxNi+PedcTEhfPQ4GlA9NFcfMkwps=; b=buVYvCpHPciR/eX2pU+O/zg6MyOu0FpcNjj6kskoy3BZiFJH8c9ZlpSP54PZ8Suc/D asN4iBgTvRnBcOlmGss/NjxbJrHUINBX4H7nqtj0+qSRZmbkgCSoIZhjCrftISjpb+tb Y/9QOT7fTv6Yg5bzheGdb3qwDDsaF4TYAeAdNajDedXTsYXriI4fXRTKtI6P51msQQ4Y Eig3zqRQTb1zF4gj128K2vqBnIWD0hkd6sD4KFZxRLbQi6yWVG+KlF/CfACwYc/Y/aEd yVawb+ouIRb1ath3YCVGJjDc6TImess7lFnc4fxKe2XCr4sZpAwIfG0enKa2F8DqHG4Q xdEg== X-Received: by 10.194.84.101 with SMTP id x5mr30863163wjy.52.1402946518729; Mon, 16 Jun 2014 12:21:58 -0700 (PDT) Received: from brick.home (aeei199.neoplus.adsl.tpnet.pl. [79.186.112.199]) by mx.google.com with ESMTPSA id f45sm35877580eem.15.2014.06.16.12.21.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jun 2014 12:21:58 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Mon, 16 Jun 2014 21:21:55 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: freebsd-current@FreeBSD.org Subject: [patch] USB after second suspend/resume on ThinkPads. Message-ID: <20140616192155.GE13481@brick.home> Mail-Followup-To: freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2014 19:22:00 -0000 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) @@ -169,6 +169,9 @@ 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; @@ -365,6 +368,7 @@ 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__); @@ -448,6 +452,17 @@ 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); } @@ -476,6 +491,7 @@ 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__); @@ -495,6 +511,15 @@ 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);