From owner-svn-src-head@freebsd.org Fri Sep 2 08:44:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03850BCDDB7; Fri, 2 Sep 2016 08:44:16 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA02CFE5; Fri, 2 Sep 2016 08:44:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u828iFGh023922; Fri, 2 Sep 2016 08:44:15 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u828iF3L023921; Fri, 2 Sep 2016 08:44:15 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201609020844.u828iF3L023921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 2 Sep 2016 08:44:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305284 - head/lib/libusb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2016 08:44:16 -0000 Author: hselasky Date: Fri Sep 2 08:44:14 2016 New Revision: 305284 URL: https://svnweb.freebsd.org/changeset/base/305284 Log: Fix array size issue when using the pre-scaling feature for ISOCHRONOUS USB transfers. Make sure enough length and buffer pointers are allocated when setting up the libusb transfer structure to support the maximum number of frames the kernel can handle. MFC after: 1 week Modified: head/lib/libusb/libusb20.c Modified: head/lib/libusb/libusb20.c ============================================================================== --- head/lib/libusb/libusb20.c Fri Sep 2 08:17:43 2016 (r305283) +++ head/lib/libusb/libusb20.c Fri Sep 2 08:44:14 2016 (r305284) @@ -176,6 +176,12 @@ libusb20_tr_open_stream(struct libusb20_ return (LIBUSB20_ERROR_BUSY); if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) { MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE; + /* + * The kernel can setup 8 times more frames when + * pre-scaling ISOCHRONOUS transfers. Make sure the + * length and pointer buffers are big enough: + */ + MaxFrameCount *= 8; pre_scale = 1; } else { pre_scale = 0; @@ -200,8 +206,13 @@ libusb20_tr_open_stream(struct libusb20_ } memset(xfer->ppBuffer, 0, size); - error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, - MaxFrameCount, ep_no, stream_id, pre_scale); + if (pre_scale) { + error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, + MaxFrameCount / 8, ep_no, stream_id, 1); + } else { + error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, + MaxFrameCount, ep_no, stream_id, 0); + } if (error) { free(xfer->ppBuffer);