From owner-freebsd-current@FreeBSD.ORG Sat Feb 26 19:05:46 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 B5053106564A for ; Sat, 26 Feb 2011 19:05:46 +0000 (UTC) (envelope-from onemda@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 6F3458FC19 for ; Sat, 26 Feb 2011 19:05:46 +0000 (UTC) Received: by vxc34 with SMTP id 34so2561778vxc.13 for ; Sat, 26 Feb 2011 11:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=s8esLE26yLmZolMlCq8WFgKskd+rzsa37R3tJaU0x7E=; b=G0s24vVTF65Un7J77ZvNawMJe/VIvWHA0vs8v2Ik3P0YoQ/SVBBKF11hybjBDvXOOl 0BtKC5LyrJBVSGy4qtE32zsE5/oa7ZIlcFzqbq0Y4fVMNPybgNjOMit3MANdsonBMtZl E2thaDAdPIvAIkVQWEH1L6n+OBrv8X/0E1/Eg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=w9LHAj/1AmaU+bHsI5Y6vcjIMbt/oXVIrGEieyLwSS5+TR4eqO/J4fRIB4njipKzgS lHVNiwiyBJkoDEuSg7jPLusatF+PMDGL1fbcTyhDpbBW59BllC1gNGarMhXpwEtgKwtV YJBs9IKWHMoCYrux4Gmp4nbP1tQ86uO00WA8s= Received: by 10.52.164.227 with SMTP id yt3mr6346042vdb.103.1298745394113; Sat, 26 Feb 2011 10:36:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.20.77 with HTTP; Sat, 26 Feb 2011 10:36:14 -0800 (PST) In-Reply-To: <201102261625.41522.bschmidt@freebsd.org> References: <201102261625.41522.bschmidt@freebsd.org> From: "Paul B. Mahol" Date: Sat, 26 Feb 2011 19:36:14 +0100 Message-ID: To: Bernhard Schmidt Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-current@freebsd.org Subject: Re: 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 19:05:46 -0000 On Sat, Feb 26, 2011 at 4:25 PM, Bernhard Schmidt wr= ote: > 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: =A0 =A0 =A0class=3D0x028000 card=3D0x107f1043 chip= =3D0x02011814 rev=3D0x01 hdr=3D0x00 > > Loading the module attaches nicely to the device: > > # kldload if_ral > % ral0: mem 0xf4800000-0xf4801fff irq 16 at de= vice 0.0 on cardbus0 > % ral0: MAC/BBP RT2560 (rev 0x04), RF RT2525 > % ral0: [ITHREAD] > # pciconf -l > % ral0@pci0:22:0:0: =A0 =A0 =A0 class=3D0x028000 card=3D0x107f1043 chip= =3D0x02011814 rev=3D0x01 hdr=3D0x00 > > 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: =A0 =A0 =A0 class=3D0x028000 card=3D0x107f1043 chip= =3D0x02011814 rev=3D0x01 hdr=3D0x00 > # kldstat > % Id Refs Address =A0 =A0 =A0 =A0 =A0 =A0Size =A0 =A0 Name > % =A01 =A0 27 0xffffffff80100000 e640a0 =A0 kernel > # ifconfig ral0 > % ral0: flags=3D8802 metric 0 mtu 2290 > % =A0 =A0 =A0 =A0 ether 00:0e:a6:a6:1b:70 > % =A0 =A0 =A0 =A0 media: IEEE 802.11 Wireless Ethernet autoselect (autose= lect) > % =A0 =A0 =A0 =A0 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. There is MODULE_DEPEND(), if_ndis depends on pccard, pci and usb modules and use both MODULE_DEPEND() and DRIVER_MODULE() with them. If I'm not mistaken pccard depends on cardbus.