Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Aug 2011 14:20:17 -0700
From:      David Somayajulu <david.somayajulu@qlogic.com>
To:        Stanislav Sedov <stas@FreeBSD.org>
Cc:        "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   RE: Loading drivers via kldload
Message-ID:  <75E1A2A7D185F841A975979B0906BBA67BCC877180@AVEXMB1.qlogic.org>
In-Reply-To: <20110811234736.d4a181cf.stas@FreeBSD.org>
References:  <75E1A2A7D185F841A975979B0906BBA67BCC877062@AVEXMB1.qlogic.org> <20110811234736.d4a181cf.stas@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <bsd.kmod.mk>

=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 <david.somayajulu@qlogic.com> 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.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?75E1A2A7D185F841A975979B0906BBA67BCC877180>