From owner-freebsd-usb@FreeBSD.ORG Tue Dec 20 13:08:31 2011 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31DF2106566B for ; Tue, 20 Dec 2011 13:08:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 819388FC12 for ; Tue, 20 Dec 2011 13:08:30 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id PAA00729; Tue, 20 Dec 2011 15:08:26 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1RczQf-000JKm-V9; Tue, 20 Dec 2011 15:08:25 +0200 Message-ID: <4EF088C8.8090906@FreeBSD.org> Date: Tue, 20 Dec 2011 15:08:24 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111206 Thunderbird/8.0 MIME-Version: 1.0 To: Hans Petter Selasky X-Enigmail-Version: undefined Content-Type: text/plain; charset=X-VIET-VPS Content-Transfer-Encoding: 7bit Cc: freebsd-usb@FreeBSD.org Subject: ukbd locking update 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: Tue, 20 Dec 2011 13:08:31 -0000 I completing a patch that changes some locking in ukbd to account for SCHEDULER_STOPPED and for other realities of the code. As a preview I would like to share couple of observations that had their effect on the patch. 1. Acquiring Giant in device_attach, _detach in similar newbus method implementations should be redundant because those are already executed with Giant held. That's done either by the general newbus code or via usbd_enum_lock() when the operations are executed in the USB explore thread. 2. As discussed before: if (!mutex_owned(&Giant)) mutex_lock(&Giant) this pattern does not make sense, because the Giant is recursive and can be simply acquired without any check. Do you agree? -- Andriy Gapon