From owner-freebsd-current@FreeBSD.ORG Fri Aug 12 21:20:30 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 6B2041065670; Fri, 12 Aug 2011 21:20:30 +0000 (UTC) (envelope-from david.somayajulu@qlogic.com) Received: from TX2EHSOBE001.bigfish.com (tx2ehsobe001.messaging.microsoft.com [65.55.88.11]) by mx1.freebsd.org (Postfix) with ESMTP id AA7598FC17; Fri, 12 Aug 2011 21:20:29 +0000 (UTC) Received: from mail8-tx2-R.bigfish.com (10.9.14.252) by TX2EHSOBE001.bigfish.com (10.9.40.21) with Microsoft SMTP Server id 14.1.225.22; Fri, 12 Aug 2011 21:20:29 +0000 Received: from mail8-tx2 (localhost.localdomain [127.0.0.1]) by mail8-tx2-R.bigfish.com (Postfix) with ESMTP id 1F3152A00FE; Fri, 12 Aug 2011 21:20:29 +0000 (UTC) X-SpamScore: -14 X-BigFish: VPS-14(zz9371K542M14ffOzz1202hzz8275bh8275dhz2ei2a8h668h839h944h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:198.70.193.64; KIP:(null); UIP:(null); IPVD:NLI; H:avexcashub1.qlogic.com; RD:avexcashub2.qlogic.com; EFVD:NLI Received-SPF: neutral (mail8-tx2: 198.70.193.64 is neither permitted nor denied by domain of qlogic.com) client-ip=198.70.193.64; envelope-from=david.somayajulu@qlogic.com; helo=avexcashub1.qlogic.com ; 1.qlogic.com ; Received: from mail8-tx2 (localhost.localdomain [127.0.0.1]) by mail8-tx2 (MessageSwitch) id 1313184027502900_31576; Fri, 12 Aug 2011 21:20:27 +0000 (UTC) Received: from TX2EHSMHS025.bigfish.com (unknown [10.9.14.245]) by mail8-tx2.bigfish.com (Postfix) with ESMTP id 6B10B4005D; Fri, 12 Aug 2011 21:20:27 +0000 (UTC) Received: from avexcashub1.qlogic.com (198.70.193.64) by TX2EHSMHS025.bigfish.com (10.9.99.125) with Microsoft SMTP Server (TLS) id 14.1.225.22; Fri, 12 Aug 2011 21:20:20 +0000 Received: from avexmb1.qlogic.org ([fe80::9545:3a4f:c131:467d]) by avexcashub2.qlogic.org ([::1]) with mapi; Fri, 12 Aug 2011 14:20:18 -0700 From: David Somayajulu To: Stanislav Sedov Date: Fri, 12 Aug 2011 14:20:17 -0700 Thread-Topic: Loading drivers via kldload Thread-Index: AcxYu6/k+15G/mNGTCGaBhMT2TmQygAdbGGg Message-ID: <75E1A2A7D185F841A975979B0906BBA67BCC877180@AVEXMB1.qlogic.org> References: <75E1A2A7D185F841A975979B0906BBA67BCC877062@AVEXMB1.qlogic.org> <20110811234736.d4a181cf.stas@FreeBSD.org> In-Reply-To: <20110811234736.d4a181cf.stas@FreeBSD.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: qlogic.com Cc: "freebsd-current@freebsd.org" Subject: RE: Loading drivers via kldload 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: Fri, 12 Aug 2011 21:20:30 -0000 This is pretty bizarre. I have been experimenting with a very simple driver= (see source below) which essentially checks the PCI vendor and Device ID's= in the probe routine. The attach and detach are empty functions. When I ru= n kldload and load the driver in a system with HBAs which have a valid Subs= ytem Vendor and Device ID's, the driver loads and attaches to the functions= . However when the Subsystem Vendor and Device ID's are zero, the system pani= cs and the stack trace is as shown below(FreeBSD 8.2 on amd64 machine). I d= on't understand why ata_pci_attach() is getting invoked. I even put a panic= () call at the top of qla_pci_probe(), and noticed that it wasn't getting i= nvoked! =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D panic: resource_list_alloc: resource_ entry is busy 0xFFFFFFFF805F4E0E at kdb_backtrace+0x5E 0xFFFFFFFF805C2D07 at panic+0x187 0xFFFFFFFF805F0616 at resource_list_alloc+0x1C6 0xFFFFFFFF804450F7 at pci_alloc_resource+0x147 0xFFFFFFFF805F0439 at bus_alloc_resource+0x89 0xFFFFFFFF8027A467 at ata_pci_attach+0xE7 0xFFFFFFFF805EEA09 at device_attach+0x69 0xFFFFFFFF80447ACA at pci_driver_added+0xDA 0xFFFFFFFF805ECD55 at devclass_driver_added+0x75 0xFFFFFFFF805EE715 at driver_module_handler+0x165 0xFFFFFFFF805B24B8 at module_register_init+0xB8 0xFFFFFFFF805AADB6 at linker_load_module+0x996 0xFFFFFFFF805AB6C4 at kern_kldload+0xB4 0xFFFFFFFF805AB894 at kldload+0x84 0xFFFFFFFF80600DD5 at syscallenter+0x1E5 0xFFFFFFFF808ACA5B at syscall+0x4B 0xFFFFFFFF80895292 at Xfast_syscall+0xE2 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Source Code =3D=3D=3D=3D=3D=3D=3D= =3D //#includes deleted // file: qla_os.c static int qla_pci_probe (device_t); static int qla_pci_attach (device_t); static int qla_pci_detach (device_t); static device_method_t qla_pci_methods[] =3D { /* Device interface */ DEVMETHOD(device_probe, qla_pci_probe), DEVMETHOD(device_attach, qla_pci_attach), DEVMETHOD(device_detach, qla_pci_detach), { 0, 0 } }; static driver_t qla_pci_driver =3D { "qltest", qla_pci_methods, sizeof (uint64_t), }; static devclass_t qla_devclass; MODULE_VERSION(qltest, 1); DRIVER_MODULE(qltest, pci, qla_pci_driver, qla_devclass, 0, 0); char dev_str[50]; /* * Name: qla_pci_probe */ static int qla_pci_probe(device_t dev) { int i; // I put call to panic() here and // it did not get invoked when Subsytem Vendor/DeviceIDs were zeros switch ((pci_get_device(dev) << 16) | (pci_get_vendor(dev))) { case ((QLA_PCI_DEVICEID << 16) | 0x1077): sprintf(dev_str, "%s ","Qlogic Adapter"); device_set_desc(dev, dev_str); break; default: device_printf(dev, "%s: Invalid Device[0x%04x: 0x%04x]\n", __func__, pci_get_vendor(dev), pci_get_device(dev))= ; return (ENXIO); } return (0); } static int qla_pci_attach(device_t dev) { device_printf(dev, "%s: called\n", __func__); return 0; } static int qla_pci_detach(device_t dev) { device_printf(dev, "%s: called\n", __func__); return (0); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Makefile =3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D KMOD=3Dqltest SRCS=3Dqla_os.c SRCS+=3D device_if.h bus_if.h pci_if.h clean: rm -f opt_bdg.h device_if.h bus_if.h pci_if.h export_syms rm -f *.o *.kld *.ko rm -f @ machine .include =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Thanks david S. -----Original Message----- From: Stanislav Sedov [mailto:stas@FreeBSD.org] Sent: Thursday, August 11, 2011 11:48 PM To: David Somayajulu Cc: freebsd-current@freebsd.org Subject: Re: Loading drivers via kldload On Thu, 11 Aug 2011 17:08:30 -0700 David Somayajulu mentioned: > Hi All, > While loading PCIe based HBA drivers via kldload, does FreeBSD expect a v= alid (i.e., non-zero) PCI subsystem Vendor and Device IDs? > It depends on the specific driver. FreeBSD doesn't check for the PCI ID in general. Usually, drivers contains a routine that check if this driver can be used with that hardware based on the PCI ID. -- Stanislav Sedov ST4096-RIPE () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments This message and any attached documents contain information from QLogic Cor= poration or its wholly-owned subsidiaries that may be confidential. If you = are not the intended recipient, you may not read, copy, distribute, or use = this information. If you have received this transmission in error, please n= otify the sender immediately by reply e-mail and then delete this message.