From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 18 14:37:55 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F5E1106566C for ; Fri, 18 Feb 2011 14:37:55 +0000 (UTC) (envelope-from onwahe@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 57F478FC16 for ; Fri, 18 Feb 2011 14:37:55 +0000 (UTC) Received: by qwj9 with SMTP id 9so3280581qwj.13 for ; Fri, 18 Feb 2011 06:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=nHIGJoKaQv7mk85FNzxorcciRf3uJYRTYKCVvLi73qQ=; b=QNoBxR8HYTmHSqN/YLXUhkFZO7fnSzp5vbtlMc0w9sTQu9U/T9VOZkL/+ROBdHIsXa BC8Rwsti+xufJV4rh2tUF0hGz8cNsHYFeDrytNhJX4AVLMWWqGkbHatQ9gMV7d4Oyx7x yJtTwJMyatASqqPDcV1Un18JwIV91JepNvY4g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ixxLV8B0TGoFVvXqVC9P2f9zZBvkrHg9MU8cqrP3sxsSfKeOIOgyKEzcM0gb//etS1 kjHU8ah8F4GXZZLq5p6JJ8EE/8NNnKgRCYXcozNv7byDwAL3k775YqBpbezVfCYeamXK 9cum6gv5Xi2v+DYIp09BwpomNLa85CE10r29Y= MIME-Version: 1.0 Received: by 10.224.61.18 with SMTP id r18mr641693qah.160.1298038247994; Fri, 18 Feb 2011 06:10:47 -0800 (PST) Received: by 10.224.2.83 with HTTP; Fri, 18 Feb 2011 06:10:47 -0800 (PST) Date: Fri, 18 Feb 2011 15:10:47 +0100 Message-ID: From: Svatopluk Kraus To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: ichsmb - correct locking strategy? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 14:37:55 -0000 Hi, I try to figure out locking strategy in FreeBSD and found 'ichsmb' device. There is a mutex which protects smb bus (ichsmb device). For example in ichsmb_readw() in sys/dev/ichsmb/ichsmb.c, the mutex is locked and a command is written to bus, then unbounded (but with timeout) sleep is done (mutex is unlocked during sleep). After sleep a word is read from bus and the mutex is unlocked. 1. If an use of the device IS NOT serialized by layers around then more calls to this function (or others) can be started or even done before the first one is finished. The mutex don't protect sms bus. 2. If an use of the device IS serialized by layers around then the mutex is useless. Moreover, I don't mension interrupt routine which uses the mutex and smb bus too. Am I right? Or did I miss something? Svata