NetBSD Problem Report #40949

From www@NetBSD.org  Wed Mar  4 00:35:56 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id C292063BD3B
	for <gnats-bugs@gnats.netbsd.org>; Wed,  4 Mar 2009 00:35:55 +0000 (UTC)
Message-Id: <20090304003555.9563163BAB8@www.NetBSD.org>
Date: Wed,  4 Mar 2009 00:35:55 +0000 (UTC)
From: khorben@defora.org
Reply-To: khorben@defora.org
To: gnats-bugs@NetBSD.org
Subject: cdce0 does not support suspend/resume
X-Send-Pr-Version: www-1.0

>Number:         40949
>Category:       kern
>Synopsis:       cdce0 does not support suspend/resume
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 04 00:40:00 +0000 2009
>Closed-Date:    Tue Aug 07 13:33:22 +0000 2012
>Last-Modified:  Tue Aug 07 13:33:22 +0000 2012
>Originator:     Pierre Pronchery
>Release:        5.0_RC2
>Organization:
>Environment:
NetBSD syn.defora.rom 5.0_RC2 NetBSD 5.0_RC2 (GENERIC) #20: Wed Mar  4 01:06:19 CET 2009  khorben@syn.defora.rom:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
This is done using an Openmoko Freerunner, connected to my NetBSD laptop running 5.0_RC2 with the patch from PR 40049. The laptop is a Lenovo T60 2007 (using the amd64 port).

With the patch mentioned above and after configuring cdce0 correctly as it appears (either manually or via ifwatchd), I am successfully using an SSH channel to the Freerunner:

cdce0 at uhub2 port 1 configuration 1 interface 0
cdce0: Linux 2.6.28-20090105.git69b2aa26 with s3c2410_ud RNDIS/Ethernet Gadget, rev 2.00/3.12, addr 2
cdce0: faking address
cdce0: address 2a:43:25:00:00:00

cdce0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 2a:43:25:00:00:00
        inet 192.168.0.200 netmask 0xffffff00 broadcast 192.168.0.255

However, after adding a simple call to pmf_device_register(NULL, NULL) to allow a suspend/resume cycle (machdep.sleep_state=3), the laptop hangs with these messages:

ioapic0 reenabling
cdce0: usb error on rx:IOERROR
[then after a few minutes ugen0 and cdce0 disconnect, cbb0 is interrupting again, aps0 fails to wake up, and my patience is exhausted]

Breaking into ddb gives:
lapic_delay() ... +0x6d
cdce_rxeof() ... +0x89
usb_transfer_complete() ... +0x1c4
uhci_softintr() ... +0x1c7

Then upon ddb reboot, cdce0 is automatically detached and the laptop reboots mostly normally (recurrent unrelated issue when flushing the cache).

I forced a detach operation on suspend and the laptop resumes correctly, with the cdce0 interface being attached again when resuming.
>How-To-Repeat:
- apply the patch from #40049 and pmf_device_register(NULL, NULL)
- plug the Openmoko Freerunner
- configure the interface
- suspend the machine through ACPI
- resume the machine and observe hangup
- patch as pasted below
- suspend and resume should work
>Fix:
Applying this additional patch seems to work:

Index: sys/dev/usb/if_cdce.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.18
diff -p -u -r1.18 if_cdce.c
--- sys/dev/usb/if_cdce.c	24 Sep 2008 07:19:18 -0000	1.18
+++ sys/dev/usb/if_cdce.c	4 Mar 2009 00:13:49 -0000
@@ -116,6 +116,7 @@ Static void	 cdce_init(void *);
 Static void	 cdce_watchdog(struct ifnet *);
 Static void	 cdce_stop(struct cdce_softc *);
 Static uint32_t	 cdce_crc32(const void *, size_t);
+Static bool      cdce_suspend(device_t PMF_FN_PROTO);

 Static const struct cdce_type cdce_devs[] = {
   {{ USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2501 }, CDCE_NO_UNION },
@@ -267,6 +301,9 @@ USB_ATTACH(cdce)
 	sc->cdce_attached = 1;
 	splx(s);

+	if(!pmf_device_register(self, cdce_suspend, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->cdce_udev,
 	    USBDEV(sc->cdce_dev));

@@ -836,3 +873,11 @@ cdce_crc32(const void *buf, size_t size)

 	return (crc ^ ~0U);
 }
+
+
+Static bool
+cdce_suspend(device_t dev PMF_FN_ARGS)
+{
+	cdce_detach(dev, 0);
+	return true;
+}

>Release-Note:

>Audit-Trail:
From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/40949: cdce0 does not support suspend/resume
Date: Sat, 7 Aug 2010 22:49:28 +0200

 			Hello,

 I would like to mention that I am still experiencing this problem on a
 NetBSD 5.1_RC3-based system:

 /netbsd: acpi0: entering state 3
 /netbsd: Devices without power management support: cdce0
 /netbsd: acpi0: aborting suspend

 I would therefore appreciate if this issue could be considered again :)

 Cheers,
 -- 
 khorben

From: "Jonathan A. Kollasch" <jakllsch@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40949 CVS commit: src/sys/dev/usb
Date: Sun, 8 Aug 2010 01:57:24 +0000

 Module Name:	src
 Committed By:	jakllsch
 Date:		Sun Aug  8 01:57:24 UTC 2010

 Modified Files:
 	src/sys/dev/usb: if_cdce.c

 Log Message:
 Like some other USB devices, register cdce(4) with pmf(9).
 Addresses PR#40949.


 To generate a diff of this commit:
 cvs rdiff -u -r1.30 -r1.31 src/sys/dev/usb/if_cdce.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: jakllsch@NetBSD.org
State-Changed-When: Sun, 08 Aug 2010 02:21:51 +0000
State-Changed-Why:
issue may have been resolved by recent commit.


From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40949 (cdce0 does not support suspend/resume)
Date: Fri, 20 Aug 2010 09:45:56 +0200

 				Hi,

 On Sun, Aug 08, 2010 at 02:21:52AM +0000, jakllsch@NetBSD.org wrote:
 > Synopsis: cdce0 does not support suspend/resume
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-Why:
 > issue may have been resolved by recent commit.

 unfortunately, at the moment I do not have access to a NetBSD machine
 with sufficient memory and CPU power to compile and test this patch as
 committed. But since I just got the reminder to provide feedback, here's
 what I can say so far.

 Last I played with this code, applying a patch like was done (without
 explicitly detaching cdce) was already allowing me to suspend the
 machine, but then triggering ugly kernel messages upon resume, although
 perhaps only when I had removed the cdce device physically before
 resuming (I do not remember exactly).

 Therefore, I think this patch is not enough as applied at the moment,
 but I would appreciate if someone else could confirm/deny that (or I'll
 do it in a couple of weeks or so).

 HTH,
 -- 
 khorben

From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40949 (cdce0 does not support suspend/resume)
Date: Sat, 07 Jul 2012 19:12:20 +0200

 				Hi,

 On 20/08/2010 09:45, Pierre Pronchery wrote:
 > 
 > Therefore, I think this patch is not enough as applied at the moment,
 > but I would appreciate if someone else could confirm/deny that (or I'll
 > do it in a couple of weeks or so).

 Two weeks, two years.

 Anyway, although I can currently suspend this same laptop without any
 issue with a cdce device connected, I still get this error every time on
 resume:
 Jul  7 19:01:39 syn /netbsd: cdce0: usb error on rx: IOERROR

 This is on netbsd-6. This bug can be closed, I just wonder if anything
 could/should be done about this message.

 Cheers,
 -- 
 khorben

State-Changed-From-To: feedback->closed
State-Changed-By: khorben@NetBSD.org
State-Changed-When: Tue, 07 Aug 2012 13:33:22 +0000
State-Changed-Why:
This problem was fixed long ago.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.