summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
Commit message (Collapse)AuthorAgeFilesLines
* o Use NULL in pereference to 0 in pointer contexts.imp2009-02-111-8/+8
| | | | | o Use newly minted KOBJMETHOD_END as appropriate o fix prototype for root_setup_intr.
* Check for device_set_devclass() errors and skip driver probe/attach if any.mav2009-02-101-4/+12
| | | | | | | | Attach call without devclass set crashes the system. On resume AHCI driver sometimes tries to create duplicate adX device. It is surely his own problem, but IMHO it is not a reason to crash here. Other reasons are also possible.
* Declare bus_data_devices to be static: it isn't used elsewhere.imp2009-02-031-5/+5
| | | | | Use NULL in a couple of places rather than 0 in the context of pointers to be consistent with the rest of the file.
* Allow device hints to wire the unit numbers of devices.jhb2008-11-181-4/+20
| | | | | | | | | | | | | | | | | | | | - An "at" hint now reserves a device name. - A new BUS_HINT_DEVICE_UNIT method is added to the bus interface. When determining the unit number of a device, this method is invoked to let the bus driver specify the unit of a device given a specific devclass. This is the only way a device can be given a name reserved via an "at" hint. - Implement BUS_HINT_DEVICE_UNIT() for the acpi(4) and isa(4) bus drivers. Both of these busses implement this by comparing the resources for a given hint device with the resources enumerated by ACPI/PnPBIOS and wire a unit if the hint resources are a subset of the "real" resources. - Use bus_hinted_children() for adding hinted devices on isa(4) busses now instead of doing it by hand. - Remove the unit kludging from sio(4) as it is no longer necessary. Prodding from: peter, imp OK'd by: marcel MFC after: 1 month
* Silence detach messages if the device has marked itself quiet (u3g).n_hibma2008-11-131-1/+2
| | | | MFC after: 3 weeks
* Close, but not eliminate, a race condition. It is one that properlyimp2008-10-101-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | designed drivers would never hit, but was exposed in diving into another problem... When expanding the devclass array, free the old memory after updating the pointer to the new memory. For the following single race case, this helps: allocate new memory copy to new memory free old memory <interrupt> read pointer to freed memory update pointer to new memory Now we do allocate new memory copy to new memory update pointer to new memory free old memory Which closes this problem, but doesn't even begin to address the multicpu races, which all should be covered by Giant at the moment, but likely aren't completely. Note: reviewers were ok with this fix, but suggested the use case wasn't one we wanted to encourage. Reviewed by: jhb, scottl.
* Split out the probing magic of device_probe_and_attach intoimp2008-06-201-6/+25
| | | | | | | device_probe() so that it can be used by busses that may wish to do additional processing between probe and attach. Reviewed by: dfr@
* devctl_process_running(): Check for devsoftc.inuse == 1 instead ofrpaulo2008-05-181-1/+1
| | | | | | | | | | | devsoftc.async_proc != NULL because the latter might not be true sometimes. This way /etc/rc.suspend gets executed. Reviwed by: njl Submitted by: Mitsuru IWASAKI <iwasaki at jp.FreeBSD.org> Tested also by: Andreas Wetzel <mickey242 at gmx.net> MFC after: 1 week
* Implement a BUS_BIND_INTR() method in the bus interface to bind an IRQjhb2008-03-201-0/+31
| | | | | | | | | | | | | resource to a CPU. The default method is to pass the request up to the parent similar to BUS_CONFIG_INTR() so that all busses don't have to explicitly implement bus_bind_intr. A bus_bind_intr(9) wrapper routine similar to bus_setup/teardown_intr() is added for device drivers to use. Unbinding an interrupt is done by binding it to NOCPU. The IRQ resource must be allocated, but it can happen in any order with respect to bus_setup_intr(). Currently it is only supported on amd64 and i386 via nexus(4) methods that simply call the intr_bind() routine. Tested by: gallatin
* Tiny bit of KNF to make bus_setup_intr() look like the rest of thisimp2008-03-101-19/+18
| | | | function.
* Any driver that relies on its parent to set the devclass has no way toimp2008-03-091-0/+8
| | | | | | | | | know if has siblings that need an actual probe. Introduce a specail return value called BUS_PROBE_NOOWILDCARD. If the driver returns this, the probe is only successful for devices that have had a specific devclass set for them. Reviewed by: current@, jhb@, grehan@
* Add devctl_process_running() so that power management system driveriwasaki2008-01-271-0/+9
| | | | | | can check whether devd(8) is running. MFC after: 1 week
* When devclass_get_maxunit is passed a NULL, return -1 to indicate thatimp2007-12-191-1/+4
| | | | there's nothing allocated at all yet.
* Deal with the possibility of device_set_unit() being called when attachingpeter2007-11-301-0/+11
| | | | the associated devinfo sysctl tree.
* First in a series of changes to remove the now-unused Giant compatibilityrwatson2007-07-271-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | framework for non-MPSAFE network protocols: - Remove debug_mpsafenet variable, sysctl, and tunable. - Remove NET_NEEDS_GIANT() and associate SYSINITSs used by it to force debug.mpsafenet=0 if non-MPSAFE protocols are compiled into the kernel. - Remove logic to automatically flag interrupt handlers as non-MPSAFE if debug.mpsafenet is set for an INTR_TYPE_NET handler. - Remove logic to automatically flag netisr handlers as non-MPSAFE if debug.mpsafenet is set. - Remove references in a few subsystems, including NFS and Cronyx drivers, which keyed off debug_mpsafenet to determine various aspects of their own locking behavior. - Convert NET_LOCK_GIANT(), NET_UNLOCK_GIANT(), and NET_ASSERT_GIANT into no-op's, as their entire behavior was determined by the value in debug_mpsafenet. - Alias NET_CALLOUT_MPSAFE to CALLOUT_MPSAFE. Many remaining references to NET_.*_GIANT() and NET_CALLOUT_MPSAFE are still present in subsystems, and will be removed in followup commits. Reviewed by: bz, jhb Approved by: re (kensmith)
* fix comment typosam2007-05-231-1/+1
|
* Use NULL rather than 0 for various pointer constants.jhb2007-02-261-26/+26
|
* o break newbus api: add a new argument of type driver_filter_t topiso2007-02-231-7/+14
| | | | | | | | | | | | | bus_setup_intr() o add an int return code to all fast handlers o retire INTR_FAST/IH_FAST For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current Reviewed by: many Approved by: re@
* Add a default method for BUS_ADD_CHILD() that just callsjhb2006-09-111-0/+7
| | | | | | | | | | | | | device_add_child_ordered(). Previously, a device driver that wanted to add a new child device in its identify routine had to know if the parent driver had a custom bus_add_child method and use BUS_ADD_CHILD() in that case, otherwise use device_add_child(). Getting it wrong in either direction would result in panics or failure to add the child device. Now, BUS_ADD_CHILD() always works isolating child drivers from having to know intimate details about the parent driver. Discussed with: imp MFC after: 1 week
* add a newbus method for obtaining the bus's bus_dma_tag_t... This isjmg2006-09-031-0/+33
| | | | | | | | | | | | | required by arches like sparc64 (not yet implemented) and sun4v where there are seperate IOMMU's for each PCI bus... For all other arches, it will end up returning NULL, which makes it a no-op... Convert a few drivers (the ones we've been working w/ on sun4v) to the new convection... Eventually all drivers will need to replace the parent tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for each driver, and will require hand inspection... Reviewed by: scottl (earlier version)
* Commit the results of the typo hunt by Darren Pilgrim.yar2006-08-041-1/+1
| | | | | | | | | | This change affects documentation and comments only, no real code involved. PR: misc/101245 Submitted by: Darren Pilgrim <darren pilgrim bitfreak org> Tested by: md5(1) MFC after: 1 week
* Create bus_enumerate_hinted_children. This routine will allow driversimp2006-07-081-0/+34
| | | | | | | | | | to use the hinted child system. Bus drivers that use this need to implmenet the bus_hinted_child method, where they actually add the child to their bus, as they see fit. The bus is repsonsible for getting the attribtues for the child, adding it in the right order, etc. ISA hinting will be updated to use this method. MFC After: 3 days
* Whoops, revert accidental commit.jhb2006-06-211-19/+7
|
* Fix two comments and a style fix.jhb2006-06-211-7/+19
|
* const'ify resource_spec to note that we won't be changing anything whilejmg2006-04-201-2/+4
| | | | releasing resources... also, NULL out the resources as we free them...
* Add a devd(8) event that is sent after the system resumes. This can benjl2006-01-221-1/+13
| | | | | | | | | | | | | used by utilities to reset moused(8), for example. The syntax is: !system=kern subsystem=power type=resume Note that it would be nice to have notification of suspend, but it's more difficult since there would have to be a method of doing request/ack to userland and automatically timing out if no response. apm(4) has a similar mechanism. MFC after: 2 weeks
* When loading a driver that is a subclass of another driver don't set thejhb2006-01-201-1/+11
| | | | | | | | | | | | | devclass's parent pointer if the two drivers share the same devclass. This can happen if the drivers use the same new-bus name. For example, we currently have 3 drivers that use the name "pci": the generic PCI bus driver, the ACPI PCI bus driver, and the OpenFirmware PCI bus driver. If the ACPI PCI bus driver was defined as a subclass of the generic PCI bus driver, then without this check the "pci" devclass would point to itself as its parent and device_probe_child() would spin forever when it encountered the first PCI device that did have a matching driver. Reviewed by: dfr, imp, new-bus@
* Correct STAILQ usage in purge of resourcelist.phk2006-01-141-1/+1
| | | | Found with: Coverity Prevent(tm)
* When data passed into devctl_notify is NULL, don't print (null). Insteadimp2005-10-041-2/+6
| | | | | | | don't print anything at all. # this fixes a problem that I noticed with devd.pipe not terminating lines # with \n correctly sometimes.
* Add two convenience functions for device drivers: bus_alloc_resources()phk2005-09-241-0/+31
| | | | | | | | | | | | and bus_free_resources(). These functions take a list of resources and handle them all in one go. A flag makes it possible to mark a resource as optional. A typical device driver can save 10-30 lines of code by using these. Usage examples will follow RSN. MFC: A good idea, eventually.
* MFp4: Expose device_probe_child()imp2005-09-181-1/+1
|
* Simplify the code a bit after the bzero().imp2005-06-091-12/+3
|
* Document that the returned pointer should be freed even if the numbernjl2005-05-201-1/+1
| | | | of items returned is 0.
* If we are going tocperciva2005-05-061-0/+1
| | | | | | | | | | 1. Copy a NULL-terminated string into a fixed-length buffer, and 2. copyout that buffer to userland, we really ought to 0. Zero the entire buffer first. Security: FreeBSD-SA-05:08.kmem
* resource_list_purge: release the resources in this list, and purge theimp2005-04-121-0/+21
| | | | | | elements of this list (eg, reset it). Man page to follow
* Return the resource created/found in resource_list_add to avoid an extraimp2005-04-121-2/+3
| | | | | | | resouce_list_find in some places. Suggested by: sam Found by: Coventry Analysis tool.
* Document that devclass_get_maxunit(9) returns one greater than the currentnjl2005-04-041-0/+3
| | | | | | | highest unit. Reviewed by: dfr MFC after: 2 weeks
* Add devclass_get_drivers(9) which provides an array of pointers to drivernjl2005-04-041-0/+41
| | | | | | | | instances in a given devclass. This is useful for systems that want to call code in driver static methods, similar to device_identify(). Reviewed by: dfr MFC after: 2 weeks
* maxunit is actually one higher than the greatest currently-allocated unitnjl2005-04-031-1/+1
| | | | | | | | | in a devclass. All the other uses of maxunit are correct and this one was safe since it checks the return value of devclass_get_device(), which would always say that the highest unit device doesn't exist. Reviewed by: dfr MFC after: 3 days
* - Denote a few places where kobj class references are manipulated withoutjhb2005-03-311-1/+2
| | | | | | holding the appropriate lock. - Add a comment explaining why we bump a driver's kobj class reference when loading a module.
* Move implementation of hw.bus.rman sysctl to subr_rman.c so thatphk2005-03-241-87/+0
| | | | | | subr_bus.c doesn't need to peek inside struct resource. OK from: imp
* Use STAILQ in preference to SLIST for the resources. Insert new resourcesimp2005-03-181-7/+7
| | | | | | | | | last in the list rather than first. This makes the resouces print in the 4.x order rather than the 5.x order (eg fdc0 at 0x3f0-0x3f5,0x3f7 is 4.x, but 0x3f7,0x3f0-0x3f5 is 5.x). This also means that the pci code will once again print the resources in BAR ascending order.
* Use dynamic major number allocation.phk2005-02-271-2/+0
|
* kill dead codesam2005-02-231-7/+1
| | | | Noticed by: Coverity Prevent analysis tool
* Maxunit is inclusive so fix off-by-one in previous commit.njl2005-02-081-1/+1
|
* Update device_find_child(9) to return the first matching child if unitnjl2005-02-081-5/+15
| | | | | | is set to -1. Reviewed by: dfr, imp
* Correct a minr whitespace inconsistency introduced in revision 1.159:rwatson2005-01-291-1/+1
| | | | add a tab between #define and DF_REBID instead of a space.
* Introduce bus_free_resource. It is a convenience function which wrapsimp2005-01-191-0/+8
| | | | bus_release_resource by grabbing the rid from the resource.
* Implement device_quiesce. This method means 'you are about to beimp2004-12-311-0/+101
| | | | | | | | unloaded, cleanup, or return ebusy of that's inconvenient.' The default module hanlder for newbus will now call this when we get a MOD_QUIESCE event, but in the future may call this at other times. This shouldn't change any actual behavior until drivers start to use it.
* Add the devclass_get_count(9) function and man page. It gets a count ofnjl2004-12-081-7/+19
| | | | | | | the number of devices in a devclass and is a subset of devclass_get_devices(9). Reviewed by: imp, dfr
OpenPOWER on IntegriCloud