From owner-freebsd-usb@FreeBSD.ORG Mon Jul 16 15:44:48 2007 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1DB5C16A402 for ; Mon, 16 Jul 2007 15:44:48 +0000 (UTC) (envelope-from xiaofanc@gmail.com) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.227]) by mx1.freebsd.org (Postfix) with ESMTP id CFE7813C4A5 for ; Mon, 16 Jul 2007 15:44:47 +0000 (UTC) (envelope-from xiaofanc@gmail.com) Received: by nz-out-0506.google.com with SMTP id l8so784198nzf for ; Mon, 16 Jul 2007 08:44:47 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VdfAP9NWG4tlH9eWt5DPjWV4PA3XoAQ3brQjeWgzmuT8S3Rq1Vdxq24V0SJp3Fcc2Q/tRwbgOOQxetfruMJk/FP065/WQGDFpgtDalSBifmXXGnCqkb39I/fd52IiHBkEE+T9WvhmDspQNabK+axPqt2CBgYu5QYJ3h0ds7TfhA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=XJLLSgTYPFrZ+QZ8/QWLSeG0GqfpkH7ji8ww3hDRJtftCFFpam2gIATNfm1to05QDkY5E2Op8BlrPHIjtD0zgcAqifJ6tUlgfqhxtg2zLG189vq9NA9hnY4e8t3Jbc9Y/EHmxNrcKLnFL8f+6iRW2xhzAFh3wNlhTGLrR8oIhTQ= Received: by 10.114.170.1 with SMTP id s1mr4252994wae.1184600686841; Mon, 16 Jul 2007 08:44:46 -0700 (PDT) Received: by 10.114.176.17 with HTTP; Mon, 16 Jul 2007 08:44:46 -0700 (PDT) Message-ID: Date: Mon, 16 Jul 2007 11:44:46 -0400 From: "Xiaofan Chen" To: "Hans Petter Selasky" , "M. Warner Losh" In-Reply-To: <200707151118.28211.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200707091835.50445.hselasky@c2i.net> <200707151118.28211.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: libusb usb_interrupt_read hangs under FreeBSD 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: Mon, 16 Jul 2007 15:44:48 -0000 On 7/15/07, Hans Petter Selasky wrote: > > > > 2) For the host, how does it know that the buffer data is still correct if > > the buffer is not cleared? > > Clear stall should only clear the data toggle! > > You need a second control command to reset the buffers and/or the protocol! > > > > > 2) What cause the stall to happen in the first place? > > It is either a wrong data-toggle bit or a protocol error. The device can send > stall at any time! > Thanks a lot for the detailed explanation. If it is a protocol error for the control endpoint 0 (EP0), the host will not need to send a clear stall feature request to EP0. Even if it is sent (shall we consider it a bug of the USB stack if that is the case?), the current PICkit 2 firmware will filter out it and ignore it. So I think we can narrow it down to the wrong data-toggle bit. I will dig further. I'd like to convince the PICKit 2 firmware developer that something is wrong even though it is now working under FreeBSD. Could we see the reason for the stall from the following USB log? ===[mcuee] ~ # dmesg | grep ugen ugen0: ugenopen: flag=1, mode=8192 ugenioctl: cmd=40125569 ugenclose: flag=1, mode=8192 ugenopen: flag=3, mode=8192 ugenioctl: cmd=80045572 ugenioctl: cmd=c018556f ugenioctl: cmd=80045572 ugenioctl: cmd=c018556f ugenioctl: cmd=80045572 ugenioctl: cmd=c018556f ugenioctl: cmd=80045572 ugenioctl: cmd=c018556f ugenclose: flag=3, mode=8192 ugenopen: flag=3, mode=8192 ugenioctl: cmd=80045565 ugen_set_config: configno 1, sc=0xc31ad800 ugenclose: flag=0, mode=0 ugenopen: flag=3, mode=8192 ugenioctl: cmd=80045572 ugenwrite: ugenwrite: transferred 64 bytes ugenioctl: cmd=80045572 ugenwrite: ugenwrite: transferred 64 bytes ugenioctl: cmd=80045572 ugenioctl: cmd=80045571 ugenread: ugen_open_pipe_read: interrupt open done ugenclose: flag=3, mode=8192 ugenclose: flag=3, mode=8192 On 7/8/07, M. Warner Losh wrote: > : > Why FreeBSD sends out the clear stall feature request for PICKit 2? > : > : Therefore it must be a 'protocol stall' and FreeBSD does not need to > : send a clear feature request for the endpoint 0 to PICkit 2. > > I need to look it up, but I believe that a clear endpoint stall also > resets the toggle, and that was the bug that was tracked down. > > Remind me when is this clear endpoint stall sent? In 7.x we don't > send one on pipe open unless the device is quirked to require one. On > RELENG_6, at least as of today, we never send one on the open. > I am using the alternative stack from Hans and 6.2 Stable version. So maybe there is a difference here. Xiaofan