From owner-svn-src-head@FreeBSD.ORG Wed Dec 3 21:55:45 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5643B3E8; Wed, 3 Dec 2014 21:55:45 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 4279C1FC; Wed, 3 Dec 2014 21:55:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sB3Ltjfu043365; Wed, 3 Dec 2014 21:55:45 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sB3LtjJN043364; Wed, 3 Dec 2014 21:55:45 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201412032155.sB3LtjJN043364@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 3 Dec 2014 21:55:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275468 - head/sys/dev/usb/controller 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.18-1 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: Wed, 03 Dec 2014 21:55:45 -0000 Author: hselasky Date: Wed Dec 3 21:55:44 2014 New Revision: 275468 URL: https://svnweb.freebsd.org/changeset/base/275468 Log: Optimise the bit searching loops, by quickly skipping the 16 first set bits if all the 16 first bits are set. This way the worst case searching time is reduced from 32 to 16 cycles. Modified: head/sys/dev/usb/controller/saf1761_otg.c Modified: head/sys/dev/usb/controller/saf1761_otg.c ============================================================================== --- head/sys/dev/usb/controller/saf1761_otg.c Wed Dec 3 21:48:30 2014 (r275467) +++ head/sys/dev/usb/controller/saf1761_otg.c Wed Dec 3 21:55:44 2014 (r275468) @@ -230,7 +230,7 @@ saf1761_host_channel_alloc(struct saf176 map = sc->sc_host_intr_map | sc->sc_host_intr_busy_map[0] | sc->sc_host_intr_busy_map[1]; - for (x = 0; x != 32; x++) { + for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) { if (map & (1 << x)) continue; sc->sc_host_intr_map |= (1 << x); @@ -242,7 +242,7 @@ saf1761_host_channel_alloc(struct saf176 map = sc->sc_host_isoc_map | sc->sc_host_isoc_busy_map[0] | sc->sc_host_isoc_busy_map[1]; - for (x = 0; x != 32; x++) { + for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) { if (map & (1 << x)) continue; sc->sc_host_isoc_map |= (1 << x); @@ -254,7 +254,7 @@ saf1761_host_channel_alloc(struct saf176 map = sc->sc_host_async_map | sc->sc_host_async_busy_map[0] | sc->sc_host_async_busy_map[1]; - for (x = 0; x != 32; x++) { + for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) { if (map & (1 << x)) continue; sc->sc_host_async_map |= (1 << x);