Re: Loading drivers via kldload

From: John Baldwin <jhb_at_freebsd.org>
Date: Tue, 16 Aug 2011 11:45:02 -0400
On Monday, August 15, 2011 9:06:34 am Andriy Gapon wrote:
> on 13/08/2011 00:20 David Somayajulu said the following:
> > 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 run
> > kldload and load the driver in a system with HBAs which have a valid Subsytem
> > 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 panics
> > and the stack trace is as shown below(FreeBSD 8.2 on amd64 machine). I don't
> > understand why ata_pci_attach() is getting invoked.
> 
> This is because ata_pci_probe returns BUS_PROBE_GENERIC for any pci device that
> has PCIC_STORAGE class and PCIS_STORAGE_IDE subclass.  So I'd guess that it tries
> to attach to your non-trivial hardware in this case and gets some incorrect
> resource configuration (e.g. BARs) from the hardware.

Well, that would seem odd, still.  It only returns BUS_PROBE_GENERIC (not 0), so
David's driver's probe routine should still be called to get a chance to attach to
the device.  Also, the ATA driver only allocates its BAR once, so it shouldn't
trigger the panic in question in that case (the panic is only triggered when you
try to double-allocate a BAR).

> Whether we actually have to panic in such situation is a different question.

Yes, it could possibly return an error instead.  Other places in the resource list
code currently panic rather than returning errors as well though.

-- 
John Baldwin
Received on Tue Aug 16 2011 - 13:45:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:16 UTC