From owner-freebsd-usb@FreeBSD.ORG Fri May 27 09:44:55 2005 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 857DC16A41C; Fri, 27 May 2005 09:44:55 +0000 (GMT) (envelope-from sigsegv@radiotube.org) Received: from enterprise.localnet.radiotube.org (enterprise.radiotube.org [81.0.166.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BF5E43D49; Fri, 27 May 2005 09:44:53 +0000 (GMT) (envelope-from sigsegv@radiotube.org) Received: from [10.101.17.159] (c51009766.inet.catch.no [81.0.151.102]) (authenticated bits=0) by enterprise.localnet.radiotube.org (8.13.1/8.13.1) with ESMTP id j4R9hpI4005184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 May 2005 11:44:38 +0200 (CEST) (envelope-from sigsegv@radiotube.org) Message-ID: <4296EBFA.1070902@radiotube.org> Date: Fri, 27 May 2005 11:44:26 +0200 From: Jan-Espen Pettersen User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: iedowse@freebsd.org X-Enigmail-Version: 0.91.0.0 OpenPGP: id=89E2E95A Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigACD021B26671C91D09F39611" Cc: freebsd-usb@freebsd.org Subject: ulpt_tick after close X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2005 09:44:55 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigACD021B26671C91D09F39611 Content-Type: multipart/mixed; boundary="------------080206050905070602070505" This is a multi-part message in MIME format. --------------080206050905070602070505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I've for a few weeks suspected that there was more problems with the USB printer implementation than those that have been resolved through usb/78208 (http://www.freebsd.org/cgi/query-pr.cgi?pr=78208). I found that ulpt_read_cb reschedules the ulpt_tick callout, but fails to check if sc->sc_has_callout is set. ulpt_close destroys the read xfer and unsets sc->sc_has_callout. Running ulpt_tick with the read xfer destroyed causes a page fault. Therefore I suggest checking sc->sc_has_callout in ulpt_read_cb before rescheduling the ulpt_tick callout. I have attached the diff I used to test this case. This patch is not ment as a fix, but rather to prove that this problem exists. Running with this patch I recently got this from the kernel (dmesg): ULPT: Warning - Avoided ulpt_tick after ulptclose (ulpt_read_cb) This means that ulpt_read_cb was called with sc->sc_has_callout == 0. I suspect that this happened after ulpt_close had finished. Jan-Espen Pettersen --------------080206050905070602070505 Content-Type: text/x-patch; name="ulpt.c.pft.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ulpt.c.pft.diff" Index: sys/dev/usb/ulpt.c =================================================================== RCS file: /usr/ncvs/src/sys/dev/usb/ulpt.c,v retrieving revision 1.65.2.1 diff -u -r1.65.2.1 ulpt.c --- sys/dev/usb/ulpt.c 30 Jan 2005 01:00:10 -0000 1.65.2.1 +++ sys/dev/usb/ulpt.c 25 Apr 2005 05:47:52 -0000 @@ -816,9 +816,13 @@ if (!err && n > 0) DPRINTF(("ulpt_tick: discarding %d bytes\n", n)); #endif - if (!err || err == USBD_TIMEOUT) - usb_callout(sc->sc_read_callout, hz / ULPT_READS_PER_SEC, - ulpt_tick, sc); + if (!err || err == USBD_TIMEOUT) { + if (sc->sc_has_callout) + usb_callout(sc->sc_read_callout, hz / ULPT_READS_PER_SEC, + ulpt_tick, sc); + else + printf("ULPT: Warning - Avoided ulpt_tick after ulptclose (ulpt_read_cb)\n"); + } } void --------------080206050905070602070505-- --------------enigACD021B26671C91D09F39611 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCluwEH90qNYni6VoRAvkuAJ4z73L6QcjdqTPMJ2Qr3D3XQD8ssgCgwVHN Qt4rdkOiIMkhrbNr7ljVJ50= =ypp5 -----END PGP SIGNATURE----- --------------enigACD021B26671C91D09F39611--