NetBSD Problem Report #58027
From www@netbsd.org Sun Mar 10 09:57:33 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 99B4F1A923C
for <gnats-bugs@gnats.NetBSD.org>; Sun, 10 Mar 2024 09:57:33 +0000 (UTC)
Message-Id: <20240310095337.317EF1A923F@mollari.NetBSD.org>
Date: Sun, 10 Mar 2024 09:53:37 +0000 (UTC)
From: mrg@eterna23.net
Reply-To: mrg@eterna23.net
To: gnats-bugs@NetBSD.org
Subject: ehci failed attach stops suspend/resume
X-Send-Pr-Version: www-1.0
>Number: 58027
>Category: kern
>Synopsis: ehci failed attach stops suspend/resume
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 10 10:00:01 +0000 2024
>Last-Modified: Mon Mar 11 11:00:01 +0000 2024
>Originator: matthew green
>Release: -current
>Organization:
>Environment:
amd64
>Description:
if something in the ehci_pci attach fails, it never registers any pmf
handlers, so the system is unable to suspend.
>How-To-Repeat:
try to suspend a system that has a:
ehci0 at pci1 dev 0 function 4: Realtek Semiconductor product 816d (rev. 0x0e)
ehci0: 32-bit DMA
ehci0: interrupting at msix2 vec 0
ehci0: pre-2.0 USB rev, device ignored
>Fix:
https://www.netbsd.org/~mrg/ehci-detach.v4.diff
>Audit-Trail:
From: Taylor R Campbell <riastradh@NetBSD.org>
To: mrg@NetBSD.org
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/58027: ehci failed attach stops suspend/resume
Date: Mon, 11 Mar 2024 10:57:27 +0000
> if (sc->sc_ih) {
> pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
> + pci_intr_release(sc->sc_pc, sc->sc_pihp, 1);
> sc->sc_ih = NULL;
> }
This part seems wrong -- I think it should be a separate branch:
if (sc->sc_ih) {
pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
sc->sc_ih = NULL;
}
if (sc->sc_pihp) {
pci_intr_release(sc->sc_pc, sc->sc_pihp, 1);
sc->sc_pihp = NULL;
}
and then we can delete some more redundant code in ehci_pci_attach's
pci_intr_establish_xname error branch.
> @@ -262,6 +263,7 @@ ehci_pci_attach(device_t parent, device_
> int err = ehci_init(&sc->sc);
> if (err) {
> aprint_error_dev(self, "init failed, error=%d\n", err);
> + ehci_release_ownership(&sc->sc, sc->sc_pc, sc->sc_tag);
> goto fail;
> }
> ...
> if (sc->sc.sc_size) {
> - ehci_release_ownership(&sc->sc, sc->sc_pc, sc->sc_tag);
> bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
> sc->sc.sc_size = 0;
> }
> ...
> @@ -302,27 +317,17 @@ ehci_pci_detach(device_t self, int flags
> ...
> - if (sc->sc.sc_size) {
> ehci_release_ownership(&sc->sc, sc->sc_pc, sc->sc_tag);
> - bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
> - sc->sc.sc_size = 0;
> }
Why did the ehci_release_ownership part move? I think we should
generally have less logic in the `if (err) goto fail' branches
themselves, and more logic shared in the common cleanup path.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.