From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796036277; b=m48rjhdh3VIl8keS7P7L3onY0+PP7phPEk8vpvS+wLfpBQyvaXrf38iAaVGDpb4sWT1n e9qtY+lKdZbIJnrwQPGa1D252t1zZYvwKbZ+eWON5PDvfy1wcnn7xhfIwvJULK4bPAAUF qMLYrgeEogva4grR7kl/xi5Eea4IsRPFnoPWnhzQyhNVOJBCiOP7SWfWIxeRQRgedj07E VZVDP11/MeXZdy6fJImST9q4K3ykbHPplcnzj+qGjQr5YLjOc80jBJxFrS+5X3pMKjICS uEetO+gPWuO5YKDhVQSQwmBC0u2TINbSr2O/pwlyC6tjfgBiaIRzOd1kU7gqwUh14fw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796036277; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=00TwEx3qVVwU7sDqwyO5SGyla5VzQRvr2GX8TFJMIrM=; b=B9Dzs8PvkS8qLe1XryDIex/vnzBhuA7nZ2XBbdL5EZUmFTH2aeUAdYimmPuGV3nC+QlL 62+5f7oqIOhmefFl3L+gPIv0SIpvTjsmP5PHnDgZ0Dc2V4IE0oMceBwPtSAWf19iHlHeb 6ta5Hx6/ulrXImhOWJO9c90ma7qZQXhrEaFr88h6P1s1eA9e3q4H7G07vRCcD3vCzj5Mp cDIVuiXhW96ESVS74/poltOulchSEwOCId8/up235ZVGLxRLNCn0D+subY7c5/Zc6MymK rlRcGD//3cnWceVN4nD6BZf76f9Zjie7/5p0fd7nUI+FL3w30OmtwYw02RXDUzA8LQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="eyad/c+u"; arc=none smtp.remote-ip=209.85.128.51 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E80C606A329 for ; Mon, 30 Nov 2026 10:57:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E80C606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eyad/c+u Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb702a7548so93559055e9.1 for ; Mon, 30 Nov 2026 02:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796036276; x=1796641076; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=00TwEx3qVVwU7sDqwyO5SGyla5VzQRvr2GX8TFJMIrM=; b=eyad/c+ueYLPYqrXhx/uSz17q7UAdy6eXQ1NTU0/VUNVeu7nQJ4TF/qpGFUG3HYBJ4 FTFOatMuoQI/q5AvfPVC8I+JLPc6HPB7L8YmomqKcq4eb94GbuHPL0OE2laxM81z5mjx k9VuIvBPLGincTqPgu2VPhygGRNvSPkXYE2MMZjhGNzrg0dA8u+2xyWeiKblZrJGsVGr jv4kC8nkNuiDPJO+ii25g0agZrE/Y/a6WaN77ukABsrykqnBPFhM9dAkL0dSH3daFurg HkZsjlB89uV3bs1Uw6MsLulEIzeCCM3YaIjF1UqqDPfKf258W2mtBQoLWwwY6Smqb8TE nv6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796036276; x=1796641076; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=00TwEx3qVVwU7sDqwyO5SGyla5VzQRvr2GX8TFJMIrM=; b=kIhWj4XO936hgHGGl8znl1pwa1GEmbMrlnIuOSSjYLlt1C5ViNRteVXDADpoSbhagN RExSB6WfW8BHZYAe2vMIgKrfaNz2f5JLKAWam6F0XOWHRkoZLJz5seQFAW2d2LyP4+Rq k4pmeOjA/IJjztS4G4XTnHhc817N4H+qA7FwcxeZlKPuAofjDDPM/bFhb1t57El+g9H4 tI0gmOhKLk9PXBaZZoSed9yolwnBFR/dsanWFspFAqVmlZuMGhpF4zu8EWfBYvwgbRch 6XK1O05hqqzl+qW5BrvtfkWzcLtLO13e94e8Vp+FuafzfXiqUMkewQAVZBlRyuFSczga VD9g== X-Forwarded-Encrypted: i=1; AL+hErFeZMxmlbjjLS7f9hEAzEDzFxwf/Ed49Bhmktrj8Hphsvz2ayBZ60z8UjsAmg/cDC80eubdLu2KQByZ@vger.kernel.org X-Gm-Message-State: APuU4Z8MVivvX4d3Qd/3O08XHVk1CooCFbO1TOczctNWJk06ay0bviM7 SJMzcPku6iX93RAMqC7NYwhvjUPx3UNNDmYyY8jfZgRT1cVrw4ZKB1Pu X-Gm-Gg: AZFdTZePkPLLrwleGVCjSsBbqBDqLrt5kSj+vcjB3qan8adRQvUy42FBngI+AlzFGp5 R+CH1juzPrtcAQHtKEzjjbQ33T6uhy+yFEpVtoBBVIpu4+A83WApkkhpBh9nXsB8ZapCLLr6tRp 7z2iVr9XR+U8QucbSpWhxdK/RwJAlklGk0pGPaSHwW/hph/UJKr8siwRqjbaFqqiwD3OerSCULT xO7h5S0oRc9IRItfUbQQsYyUn1PeMn0uPRcI1pf8kZcnKz/wLvxovPcGsmfIRgmvmsvvKson3ih +wuCFm90jNJ8gQbzEvC1kHyqITcTJ753D1KwKKHKQBHycsJM0iahxiY0SLxZ8tvAQ/sOro/4ghe /KOxjj3Gb/8Je2PvpfEESJEDhGhDG1py6OIoLECY++23fhrG98M9n9wrxmNKHAIY/jl2HcQd3cc rCmC6dnq2z7+RRpEiC6qEKOz6/Aqcrsz8/qB0oyYMNYW9h+4kboYveLLNfEepQ5pS3txDHDhNnW Ex7DxjsY63iBtkMsKi+gkybuvYrkUwCF71xGNzTQpLwA4JDfP1/SSSZhfiM57AXbA2Au1wfAKC7 5sNQ+7PKBw5Cj4Ak43+BleITQLrVTOzrkaoGI1E= X-Received: by 2002:a05:600c:37c6:b0:4bb:7033:c938 with SMTP id 5b1f17b1804b1-4bb888147b7mr662722265e9.14.1796036275686; Mon, 30 Nov 2026 02:57:55 -0800 (PST) Received: from foxbook (bfj60.neoplus.adsl.tpnet.pl. [83.28.47.60]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8960068fsm372314855e9.4.2026.11.30.02.57.54 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 30 Nov 2026 02:57:55 -0800 (PST) Date: Mon, 30 Nov 2026 11:57:53 +0100 From: Michal Pecio To: Mario Limonciello Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Mika Westerberg , linux-acpi@vger.kernel.org, "Chia-Lin Kao (AceLan)" , Alan Stern Subject: Re: [PATCH v3] USB: hub: call ACPI _PRR reset during port power-cycle on enumeration failure Message-ID: <20261130115753.5cb59dd2.michal.pecio@gmail.com> In-Reply-To: <20260706080117.3754550-1-v3-1-0e3069228fe9@kernel.org> References: <20260706080117.3754550-1-v3-1-0e3069228fe9@kernel.org> X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 03 Nov 2026 00:08:43 -0600, Mario Limonciello wrote: > Some USB-connected devices (e.g. MT7925 Bluetooth on Dell laptops) expose > their hardware reset line via an ACPI Power Resource for Reset (_PRR) > rather than relying solely on VBUS cycling for recovery. When the reset > GPIO gets stuck low the device stops responding on USB; a VBUS power-cycle > alone cannot recover it because the chip remains in reset regardless of > VBUS state. Could this be the widely-known "onboard Bluetooth fails to enumerate causing boot delays" issue affecting many different machines? > Add usb_acpi_port_prr_reset() in usb-acpi.c that, given a hub device and > one-based port number, looks up the port's ACPI companion handle, evaluat= es > _PRR to obtain the power-resource reference, and then calls _RST on that > reference to toggle the reset line. The function is a no-op if the port > has no ACPI handle or no _PRR method, so it is safe to call unconditional= ly > for every port. >=20 > Wire it into hub_port_connect() during the mid-retry VBUS power-cycle > (at (PORT_INIT_TRIES-1)/2 iterations), calling usb_acpi_port_prr_reset() > *after* VBUS goes off and *before* VBUS comes back on. The ordering is > critical: on the tested hardware the ACPI _RST method (MBTR._RST) drives > BT_RST low for 200 ms then high again. If _RST is called after VBUS is > already restored the GPIO pulse races with device enumeration starting on > the live bus; the device begins asserting USB signals while still held in > reset and enumeration fails. Performing the reset while the port is > de-powered ensures the GPIO pulse completes fully before the device is > given power and time to initialise. >=20 > After VBUS is restored, add an msleep(100) conditional on _PRR._RST having > succeeded. USB 2.0 spec =C2=A77.1.7.3 (Fig. 7-29) mandates a minimum of = 100 ms > between VBUS power-on and the first reset signalling for power settling. > On root hubs, hub_power_on_good_delay() returns bPwrOn2PwrGood * 2 with > no minimum floor; on the tested xHCI root hub bPwrOn2PwrGood =3D 10, yiel= ding > only 20 ms =E2=80=94 well below the spec minimum. (External hubs already= enforce > a 100 ms minimum via hub_power_on_good_delay().) When _PRR._RST has been > exercised the device must also complete its full power-on sequence (GPIO > de-assertion, internal oscillator start, firmware load) before USB > enumeration begins. The 100 ms sleep enforces the spec minimum and gives > the device adequate settling time. >=20 > Tested on a Dell laptop with MT7925 Bluetooth (idVendor=3D0489, > idProduct=3De139) whose BT_RST GPIO was stuck low. With this fix the > device recovers autonomously at boot without requiring a G3 > (mechanical power-off) cycle. The relevant dmesg sequence: >=20 > [ 1.448491] usb 3-10: new high-speed USB device number 4 using xhci_= hcd > [ 6.813942] usb 3-10: device descriptor read/64, error -110 > [ 22.685978] usb 3-10: device descriptor read/64, error -110 > [ 22.901715] usb 3-10: new high-speed USB device number 5 using xhci_= hcd > [ 28.317963] usb 3-10: device descriptor read/64, error -110 > [ 44.189949] usb 3-10: device descriptor read/64, error -110 > [ 44.294065] usb usb3-port10: attempt power cycle > [ 44.872709] usb 3-10: new high-speed USB device number 6 using xhci_= hcd > [ 44.888293] usb 3-10: New USB device found, idVendor=3D0489, idProdu= ct=3De139, bcdDevice=3D 1.00 > [ 44.888318] usb 3-10: Manufacturer: MediaTek Inc. >=20 > Signed-off-by: Chia-Lin Kao (AceLan) > Reviewed-by: Mario Limonciello (AMD) > Link: https://patch.msgid.link/20260706080117.3754550-1-acelan.kao@canoni= cal.com > Signed-off-by: Mario Limonciello (AMD) > --- > This was sent last cycle but got no feedback except for my review comment. > I think we should bring it forward this cycle. >=20 > Changes from v2: > * Rebase on 7.4-rc1 > * Link to v2: https://lore.kernel.org/linux-usb/20260706080117.3754550-1-= acelan.kao@canonical.com/ > --- > drivers/usb/core/hub.c | 14 ++++++++++ > drivers/usb/core/usb-acpi.c | 68 +++++++++++++++++++++++++++++++++++++++= ++++++ > drivers/usb/core/usb.h | 3 ++ > 3 files changed, 85 insertions(+) >=20 > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 199d3f535a891..72da7aea94cc4 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -5621,11 +5621,25 @@ static void hub_port_connect(struct usb_hub *hub,= int port1, u16 portstatus, > =20 > /* When halfway through our retry count, power-cycle the port */ > if (i =3D=3D (PORT_INIT_TRIES - 1) / 2) { > + int prr_reset; > + > dev_info(&port_dev->dev, "attempt power cycle\n"); > usb_hub_set_port_power(hdev, hub, port1, false); > msleep(2 * hub_power_on_good_delay(hub)); > + prr_reset =3D usb_acpi_port_prr_reset(hdev, port1); > usb_hub_set_port_power(hdev, hub, port1, true); > msleep(hub_power_on_good_delay(hub)); > + /* > + * USB 2.0 spec =C2=A77.1.7.3 requires at least 100 ms > + * between VBUS power-on and the first reset for power > + * settling. hub_power_on_good_delay() on an xHCI root > + * hub returns bPwrOn2PwrGood * 2 with no minimum floor, > + * which can be as little as 20 ms. When _PRR _RST was > + * also exercised the device must complete its power-on > + * sequence before enumeration; enforce the spec minimum. > + */ Nothing xHCI-specific about it. It seems hub_power_on_good_delay() used to enforce this, but that has been disabled on root hubs for some reason by 90d28fb53d4a5 without updating this caller. If next iteration resets the port before 100ms passes then it's a USB spec violation in all cases, not only for this device, isn't it? And I suspect that nobody who reaches this point would mind an extra 80ms of delay by default - this is not a "fast path". Was the delay seen to make a difference for this device? Regards, Michal > + if (prr_reset =3D=3D 0) > + msleep(100); > } > } > if (hub->hdev->parent || > diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c > index 489dbdc96f94a..bb1b5e8cdc15e 100644 > --- a/drivers/usb/core/usb-acpi.c > +++ b/drivers/usb/core/usb-acpi.c > @@ -142,6 +142,74 @@ int usb_acpi_set_power_state(struct usb_device *hdev= , int index, bool enable) > } > EXPORT_SYMBOL_GPL(usb_acpi_set_power_state); > =20 > +/** > + * usb_acpi_port_prr_reset - issue an ACPI _PRR reset on a hub port > + * @hdev: USB device belonging to the usb hub > + * @port1: port number (one-based) > + * > + * Some devices expose their hardware reset line via an ACPI Power Resou= rce for > + * Reset (_PRR). When such a device fails to enumerate (e.g. because th= e reset > + * GPIO is stuck low), the USB power-cycle alone is not enough; the firm= ware > + * reset path must also be exercised. > + * > + * This function evaluates _PRR on the port's ACPI companion to obtain t= he > + * power-resource reference and then calls _RST on that resource to togg= le the > + * reset line. It is intended to be called alongside the mid-retry VBUS > + * power-cycle already performed by hub_port_connect(). > + * > + * Returns 0 on success, -ENODEV if the port has no ACPI handle or no _P= RR > + * method, or a negative error code on failure. > + */ > +int usb_acpi_port_prr_reset(struct usb_device *hdev, int port1) > +{ > + acpi_handle port_handle; > + struct acpi_buffer buffer =3D { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *pkg, *ref; > + acpi_status status; > + int ret =3D 0; > + > + port_handle =3D usb_get_hub_port_acpi_handle(hdev, port1); > + if (!port_handle) > + return -ENODEV; > + > + if (!acpi_has_method(port_handle, "_PRR")) > + return -ENODEV; > + > + status =3D acpi_evaluate_object(port_handle, "_PRR", NULL, &buffer); > + if (ACPI_FAILURE(status)) { > + dev_dbg(&hdev->dev, "port%d: _PRR evaluation failed: %s\n", > + port1, acpi_format_exception(status)); > + return -ENODEV; > + } > + > + pkg =3D buffer.pointer; > + if (!pkg || pkg->type !=3D ACPI_TYPE_PACKAGE || pkg->package.count !=3D= 1) { > + dev_dbg(&hdev->dev, "port%d: _PRR returned unexpected object\n", > + port1); > + ret =3D -EINVAL; > + goto out; > + } > + > + ref =3D &pkg->package.elements[0]; > + if (ref->type !=3D ACPI_TYPE_LOCAL_REFERENCE || !ref->reference.handle)= { > + dev_dbg(&hdev->dev, "port%d: _PRR element is not a reference\n", > + port1); > + ret =3D -EINVAL; > + goto out; > + } > + > + status =3D acpi_evaluate_object(ref->reference.handle, "_RST", NULL, NU= LL); > + if (ACPI_FAILURE(status)) { > + dev_dbg(&hdev->dev, "port%d: _RST evaluation failed: %s\n", > + port1, acpi_format_exception(status)); > + ret =3D -EIO; > + } > + > +out: > + kfree(buffer.pointer); > + return ret; > +} > + > /** > * usb_acpi_add_usb4_devlink - add device link to USB4 Host Interface fo= r tunneled USB3 devices > * > diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h > index a9b37aeb515be..4d3dc3bd881b2 100644 > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -211,7 +211,10 @@ extern int usb_acpi_register(void); > extern void usb_acpi_unregister(void); > extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, > int port1); > +extern int usb_acpi_port_prr_reset(struct usb_device *hdev, int port1); > #else > static inline int usb_acpi_register(void) { return 0; }; > static inline void usb_acpi_unregister(void) { }; > +static inline int usb_acpi_port_prr_reset(struct usb_device *hdev, > + int port1) { return -ENODEV; } > #endif >=20 > --- > base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 > change-id: 20260706080117.3754550-1-acelan.kao@canonical.com >=20 > Best regards, > -- =20 > Mario Limonciello >=20