From owner-freebsd-current@FreeBSD.ORG Thu Jun 19 17:04:01 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 792D59BF; Thu, 19 Jun 2014 17:04:01 +0000 (UTC) Received: from mail-wg0-x22f.google.com (mail-wg0-x22f.google.com [IPv6:2a00:1450:400c:c00::22f]) (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 B88C12504; Thu, 19 Jun 2014 17:04:00 +0000 (UTC) Received: by mail-wg0-f47.google.com with SMTP id k14so2606254wgh.30 for ; Thu, 19 Jun 2014 10:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=oEKdTMGVGBds3INTkEX1aupDz+v4rCHU4L6L9k01eYU=; b=TJuG5w39opTz/k2SJXQegdLgItz28dCLA/o/TfOJcjVv/3Z9cxhFVcDUIlCLwMsCwL u4285yLB6hsOOZ6DgIFOz8kncxkC9UA8nYQwoAeT9LshlaEmW/DbDDUU4qVV1fB3wI4B 6KVM2SS8vPF8ZSQFB7sRTvyv32xqEFFBxf9PSXUTFywKZ1aU4DjG9GUkiQpqR8mAtLx5 6QKeYX4gNCHF1vRflJNHepPkPBtoxxg9w/Cxy821q1aelYUaaaR/l3VARqwgyWJI0210 TI/tCWmsV6icf8dPbbghz9VpHqKuxcvPYOaaPlAbhatlC13iMe/tT48VK6WljQNF6+CQ df3w== X-Received: by 10.194.238.134 with SMTP id vk6mr6239494wjc.93.1403197439099; Thu, 19 Jun 2014 10:03:59 -0700 (PDT) Received: from brick.home (actd159.neoplus.adsl.tpnet.pl. [83.11.57.159]) by mx.google.com with ESMTPSA id d6sm9897299wjb.4.2014.06.19.10.03.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jun 2014 10:03:58 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Thu, 19 Jun 2014 19:03:56 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: John Baldwin Subject: Re: [patch] USB after second suspend/resume on ThinkPads. Message-ID: <20140619170356.GA1271@brick.home> Mail-Followup-To: John Baldwin , freebsd-current@freebsd.org, jhibbits@freebsd.org References: <20140616192155.GE13481@brick.home> <201406181303.09834.jhb@freebsd.org> <20140618184609.GA1297@brick.home> <201406181515.19927.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201406181515.19927.jhb@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: jhibbits@freebsd.org, freebsd-current@freebsd.org 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: Thu, 19 Jun 2014 17:04:01 -0000 On 0618T1515, John Baldwin wrote: > On Wednesday, June 18, 2014 2:46:09 pm Edward Tomasz Napierała wrote: > > On 0618T1303, John Baldwin wrote: > > > On Wednesday, June 18, 2014 12:13:15 pm Edward Tomasz Napierała wrote: > > > > On 0618T0947, John Baldwin wrote: > > > > > On Monday, June 16, 2014 3:21:55 pm Edward Tomasz Napierała wrote: > > > > > > 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. > > > > > > > > > > Good find. Have you thought about a more generic fix for this wherein you > > > > > track power resources and flip them on during resume in ACPI before doing > > > > > DEVICE_RESUME() on the root bus? > > > > > > > > Thing is, after resume this device claims to be on already. The following > > > > simple hack was enough to make it work: > > > > > > Ahh, I think I see. Try this instead: > > > > > > Index: sys/dev/acpica/acpi_powerres.c > > > =================================================================== > > > --- acpi_powerres.c (revision 267550) > > > +++ acpi_powerres.c (working copy) > > > @@ -645,7 +645,7 @@ acpi_pwr_switch_power(void) > > > acpi_name(rp->ap_resource), status)); > > > /* XXX is this correct? Always switch if in doubt? */ > > > continue; > > > - } else if (rp->ap_state == ACPI_PWR_UNK) > > > + } else > > > rp->ap_state = cur; > > > > > > /* > > > @@ -689,7 +689,7 @@ acpi_pwr_switch_power(void) > > > acpi_name(rp->ap_resource), status)); > > > /* XXX is this correct? Always switch if in doubt? */ > > > continue; > > > - } else if (rp->ap_state == ACPI_PWR_UNK) > > > + } else > > > rp->ap_state = cur; > > > > > > /* > > > > > > (We were ignoring what _STA told us and believed it was ON because we had > > > cached that state previously.) > > > > Works! > > Hmmm. If we go this route, ap_state is actually useless and should just be > removed. Here is an updated version that does that. If this works as well Works as well.