From owner-freebsd-current@FreeBSD.ORG Mon May 26 12:22:03 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2987D37B404; Mon, 26 May 2003 12:22:03 -0700 (PDT) Received: from dmlb.org (pc2-cmbg4-6-cust36.cmbg.cable.ntl.com [81.96.76.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4373243F3F; Mon, 26 May 2003 12:22:02 -0700 (PDT) (envelope-from dmlb@dmlb.org) Received: from orac.my.domain ([192.168.200.75] helo=orac) by dmlb.org with smtp (Exim 3.36 #1) id 19KNXk-000GF2-00; Mon, 26 May 2003 20:22:00 +0100 Message-ID: <001d01c323bc$1a474cd0$4bc8a8c0@orac> From: "Duncan Barclay" To: , Date: Mon, 26 May 2003 20:22:09 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: kldunload and device detach panics X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2003 19:22:03 -0000 Hi Whilst starting work on porting the Linux Broadcom 440x 10/100 driver I've come across a bit of a problem with kldunload and its interaction with device xxx_detach. I'm cribbing code from if_bge.c and if_rl.c (picked at random). if_rl.c uses a mutex for locking the softc. If the rl_detach routine is called twice (for example failing attach and then kldunload) the mutex gets destroyed twice - leading to a panic with witness. Is there a safe sequence of mutex checking etc. to avoid killing the machine in this way? At present I'm assuming that if the mutex is not initialised then _detach doesn't need to clean as nothing could have been set up, or it has already been cleaned. Duncan