From owner-freebsd-current@FreeBSD.ORG Sat Feb 26 15:59:42 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6435F1065670 for ; Sat, 26 Feb 2011 15:59:42 +0000 (UTC) (envelope-from bschmidt@techwires.net) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id F17AA8FC08 for ; Sat, 26 Feb 2011 15:59:41 +0000 (UTC) Received: by bwz12 with SMTP id 12so3065691bwz.13 for ; Sat, 26 Feb 2011 07:59:40 -0800 (PST) Received: by 10.204.0.65 with SMTP id 1mr3139157bka.111.1298734181594; Sat, 26 Feb 2011 07:29:41 -0800 (PST) Received: from julie.lab.techwires.net (dslb-094-217-128-237.pools.arcor-ip.net [94.217.128.237]) by mx.google.com with ESMTPS id j11sm1183485bka.0.2011.02.26.07.29.39 (version=SSLv3 cipher=OTHER); Sat, 26 Feb 2011 07:29:40 -0800 (PST) Sender: Bernhard Schmidt From: Bernhard Schmidt To: freebsd-current@freebsd.org Date: Sat, 26 Feb 2011 16:25:41 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.1-RELEASE; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201102261625.41522.bschmidt@freebsd.org> Subject: cardbus and kldunload issue X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 26 Feb 2011 15:59:42 -0000 Hi, while working on a wireless driver for a Cardbus card I stumbled over an issue which bugs me quite a bit. The device: % none3@pci0:22:0:0: class=0x028000 card=0x107f1043 chip=0x02011814 rev=0x01 hdr=0x00 Loading the module attaches nicely to the device: # kldload if_ral % ral0: mem 0xf4800000-0xf4801fff irq 16 at device 0.0 on cardbus0 % ral0: MAC/BBP RT2560 (rev 0x04), RF RT2525 % ral0: [ITHREAD] # pciconf -l % ral0@pci0:22:0:0: class=0x028000 card=0x107f1043 chip=0x02011814 rev=0x01 hdr=0x00 Though, kldunload doesn't detach the device, it doesn't even call the module's detach function. # kldunload if_ral # pciconf -l % ral0@pci0:22:0:0: class=0x028000 card=0x107f1043 chip=0x02011814 rev=0x01 hdr=0x00 # kldstat % Id Refs Address Size Name % 1 27 0xffffffff80100000 e640a0 kernel # ifconfig ral0 % ral0: flags=8802 metric 0 mtu 2290 % ether 00:0e:a6:a6:1b:70 % media: IEEE 802.11 Wireless Ethernet autoselect (autoselect) % status: no carrier And of course trying to use the device at that point will result in instant panics. Playing around a bit I've noticed that changing the bus name in: % DRIVER_MODULE(ral, pci, ral_pci_driver, ral_devclass, 0, 0); from pci to cardbus makes a big difference. On module unload the detach function is then called as expected. So, question is, are we doing some too strict checks on module unload while matching the bus? Or is this expected behavior and the drivers are supposed to indiciated that they support both pci and cardbus? I don't see the later anywhere in tree. -- Bernhard