aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
Commit message (Collapse)AuthorAgeFilesLines
* sys/kern: spelling fixes in comments.Pedro F. Giffuni2016-04-291-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298819
* Add a bus_null_rescan() method that always fails with an error.John Baldwin2016-04-271-0/+13
| | | | | | | | Use this in place of kobj_error_method to disable BUS_RESCAN() on PCI drivers that do not use the "standard" scanning algorithm. Notes: svn path=/head/; revision=298712
* Add 'devctl delete' that calls device_delete_child().John Baldwin2016-04-271-0/+19
| | | | | | | | | | | | | | | | 'devctl delete' can be used to delete a device that is no longer present. As an anti-foot-shooting measure, 'delete' will not delete a device unless it's parent bus says it is no longer present. This can be overridden by passing the force ('-f') flag. Note that this command should be used with care. If a device is deleted that is actually present it can't be resurrected unless the parent bus device's driver supports rescans. Differential Revision: https://reviews.freebsd.org/D6019 Notes: svn path=/head/; revision=298709
* Add a new rescan method to the bus interface.John Baldwin2016-04-271-0/+8
| | | | | | | | | | | The BUS_RESCAN() method rescans a single bus device checking for devices that have been added or removed from the bus. A new 'rescan' command is added to devctl(8) to trigger a rescan. Differential Revision: https://reviews.freebsd.org/D6016 Notes: svn path=/head/; revision=298707
* Add a function to lookup a device_t object by name.John Baldwin2016-04-101-6/+16
| | | | | | | | | This just walks the global list of devices looking for one with the requested name. The one use case outside of devctl2's implementation is for DDB commands that wish to lookup devices by name. Notes: svn path=/head/; revision=297776
* Move pccard_safe_quote() up to subr_bus.c and rename toWarner Losh2016-03-281-0/+32
| | | | | | | devctl_safe_quote() so it can be used more generally. Notes: svn path=/head/; revision=297365
* Replace all resource occurrences of '0UL/~0UL' with '0/~0'.Justin Hibbits2016-03-031-4/+4
| | | | | | | | | | | | | | | | Summary: The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a 32-bit platform, will leave the upper 32 bits as 0. The maximum range of a resource is 0xFFF.... (all bits of the full type set). By dropping the 'ul' suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit platforms gets it to a type-independent 'unsigned max'. Reviewed By: cem Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5255 Notes: svn path=/head/; revision=296336
* Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.Justin Hibbits2016-02-201-1/+1
| | | | | | | | | | | | | | This simplifies checking for default resource range for bus_alloc_resource(), and improves readability. This is part of, and related to, the migration of rman_res_t from u_long to uintmax_t. Discussed with: jhb Suggested by: marcel Notes: svn path=/head/; revision=295832
* Fix build for i386 and arm64 after r295755Zbigniew Bodek2016-02-181-2/+2
| | | | | | | | | - Take bus_space_tag_t type into consideration when returning default, zero value. - Include missing rman.h required by ofw_pci.h Notes: svn path=/head/; revision=295762
* Introduce bus_get_bus_tag() methodZbigniew Bodek2016-02-181-0/+33
| | | | | | | | | | | | | | | | | | | | | | Provide bus_get_bus_tag() for sparc64, powerpc, arm, arm64 and mips nexus and its children in order to return a platform specific default tag. This is required to ensure generic correctness of the bus_space tag. It is especially needed for arches where child bus tag does not match the parent bus tag. This solves the problem with ppc architecture where the PCI bus tag differs from parent bus tag which is big-endian. This commit is a part of the following patch: https://reviews.freebsd.org/D4879 Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Reviewed by: jhibbits, mmel Differential Revision: https://reviews.freebsd.org/D4879 Notes: svn path=/head/; revision=295755
* Convert rman to use rman_res_t instead of u_longJustin Hibbits2016-01-271-20/+22
| | | | | | | | | | | | | | | | | | | | | | | Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075 Notes: svn path=/head/; revision=294883
* Huge cleanup of random(4) code.Mark Murray2015-06-301-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * GENERAL - Update copyright. - Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set neither to ON, which means we want Fortuna - If there is no 'device random' in the kernel, there will be NO random(4) device in the kernel, and the KERN_ARND sysctl will return nothing. With RANDOM_DUMMY there will be a random(4) that always blocks. - Repair kern.arandom (KERN_ARND sysctl). The old version went through arc4random(9) and was a bit weird. - Adjust arc4random stirring a bit - the existing code looks a little suspect. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Redo read_random(9) so as to duplicate random(4)'s read internals. This makes it a first-class citizen rather than a hack. - Move stuff out of locked regions when it does not need to be there. - Trim RANDOM_DEBUG printfs. Some are excess to requirement, some behind boot verbose. - Use SYSINIT to sequence the startup. - Fix init/deinit sysctl stuff. - Make relevant sysctls also tunables. - Add different harvesting "styles" to allow for different requirements (direct, queue, fast). - Add harvesting of FFS atime events. This needs to be checked for weighing down the FS code. - Add harvesting of slab allocator events. This needs to be checked for weighing down the allocator code. - Fix the random(9) manpage. - Loadable modules are not present for now. These will be re-engineered when the dust settles. - Use macros for locks. - Fix comments. * src/share/man/... - Update the man pages. * src/etc/... - The startup/shutdown work is done in D2924. * src/UPDATING - Add UPDATING announcement. * src/sys/dev/random/build.sh - Add copyright. - Add libz for unit tests. * src/sys/dev/random/dummy.c - Remove; no longer needed. Functionality incorporated into randomdev.*. * live_entropy_sources.c live_entropy_sources.h - Remove; content moved. - move content to randomdev.[ch] and optimise. * src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h - Remove; plugability is no longer used. Compile-time algorithm selection is the way to go. * src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h - Add early (re)boot-time randomness caching. * src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h - Remove; no longer needed. * src/sys/dev/random/uint128.h - Provide a fake uint128_t; if a real one ever arrived, we can use that instead. All that is needed here is N=0, N++, N==0, and some localised trickery is used to manufacture a 128-bit 0ULLL. * src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h - Improve unit tests; previously the testing human needed clairvoyance; now the test will do a basic check of compressibility. Clairvoyant talent is still a good idea. - This is still a long way off a proper unit test. * src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h - Improve messy union to just uint128_t. - Remove unneeded 'static struct fortuna_start_cache'. - Tighten up up arithmetic. - Provide a method to allow eternal junk to be introduced; harden it against blatant by compress/hashing. - Assert that locks are held correctly. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Turn into self-sufficient module (no longer requires randomdev_soft.[ch]) * src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h - Improve messy union to just uint128_t. - Remove unneeded 'staic struct start_cache'. - Tighten up up arithmetic. - Provide a method to allow eternal junk to be introduced; harden it against blatant by compress/hashing. - Assert that locks are held correctly. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Turn into self-sufficient module (no longer requires randomdev_soft.[ch]) - Fix some magic numbers elsewhere used as FAST and SLOW. Differential Revision: https://reviews.freebsd.org/D2025 Reviewed by: vsevolod,delphij,rwatson,trasz,jmg Approved by: so (delphij) Notes: svn path=/head/; revision=284959
* Fix handling of BUS_PROBE_NOWILDCARD in 'device_probe_child()'.Neel Natu2015-04-151-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | Device probe value of BUS_PROBE_NOWILDCARD should be treated specially only if the device has a fixed devclass. Otherwise it should be interpreted just as if the driver doesn't want to claim the device. Prior to this change a device that was not claimed explicitly by its driver would remain "attached" to the driver that returned BUS_PROBE_NOWILDCARD. This would bump up the reference on 'driver->refs' and its 'dev->ops' would point to the 'driver->ops'. When the driver is subsequently unloaded the 'dev->ops->cls' is left pointing to freed memory. This fixes an easily reproducible #GP fault caused by loading and unloading vmm.ko multiple times. Differential Revision: https://reviews.freebsd.org/D2294 Reviewed by: imp, jhb Discussed with: rstone Reported by: Leon Dang (ldang@nahannisys.com) MFC after: 2 weeks Notes: svn path=/head/; revision=281559
* Use SYSCTL_OUT_STR() to return strings.Ian Lepore2015-03-141-2/+2
| | | | | | | PR: 195668 Notes: svn path=/head/; revision=280006
* Fix SR-IOV passthrough devices to allow ppt to attachRyan Stone2015-03-101-0/+19
| | | | | | | | | | | | | | | | | | A late change to the SR-IOV infrastructure broke passthrough of VFs. device_set_devclass() was being used to try to force the ppt driver to attach to the device, but this didn't work because the DF_FIXEDCLASS flag wasn't being set on the device, so the ppt driver probe routine would not match when it returned BUS_NOWILDCARD. Fix this by adding a new device function that both sets the devclass and sets the DF_FIXEDCLASS flag, and use that to force the ppt driver to attach to VFs. Differential Revision: https://reviews.freebsd.org/D2041 Reviewed by: jhb MFC after: 3 weeks Notes: svn path=/head/; revision=279868
* Add a new device control utility for new-bus devices called devctl. ThisJohn Baldwin2015-02-061-0/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | allows the user to request administrative changes to individual devices such as attach or detaching drivers or disabling and re-enabling devices. - Add a new /dev/devctl2 character device which uses ioctls for device requests. The ioctls use a common 'struct devreq' which is somewhat similar to 'struct ifreq'. - The ioctls identify the device to operate on via a string. This string can either by the device's name, or it can be a bus-specific address. (For unattached devices, a bus address is the only way to locate a device.) Bus drivers register an eventhandler to claim unrecognized device names that the driver recognizes as a valid address. Two buses currently support addresses: ACPI recognizes any device in the ACPI namespace via its full path starting with "\" and the PCI bus driver recognizes an address specification of 'pci[<domain>:]<bus>:<slot>:<func>' (identical to the PCI selector strings supported by pciconf). - To make it easier to cut and paste, change the PnP location string in the PCI bus driver to output a full PCI selector string rather than 'slot=<slot> function=<func>'. - Add a devctl(3) interface in libdevctl which provides a wrapper around the ioctls and is the preferred interface for other userland code. - Add a devctl(8) program which is a simple wrapper around the requests supported by devctl(3). - Add a device_is_suspended() function to check DF_SUSPENDED. - Add a resource_unset_value() function that can be used to remove a hint from the kernel environment. This is used to clear a hint.<driver>.<unit>.disabled hint when re-enabling a boot-time disabled device. Reviewed by: imp (parts) Requested by: imp (changing PCI location string) Relnotes: yes Notes: svn path=/head/; revision=278320
* Expose the constants for internal new-bus device flags to userland. TheJohn Baldwin2015-02-051-9/+0
| | | | | | | | | flag value is already exposed via dv_flags, just not the meaning of the flags themselves. Use these constants to annotate devices that are disabled or suspended in devinfo output. Notes: svn path=/head/; revision=278299
* Set and clear the DF_SUSPENDED flag on the child device being manipulatedJohn Baldwin2015-02-051-2/+2
| | | | | | | rather than on the parent. Notes: svn path=/head/; revision=278296
* Trim trailing whitespace.John Baldwin2015-01-051-25/+25
| | | | Notes: svn path=/head/; revision=276725
* Revert device_getenv_int() for now as it duplicates resource_int_value().John Baldwin2014-12-031-17/+0
| | | | | | | | We should perhaps implement a device_getenv_*() and device_setenv_*() API as a convenience wrapper on top of resource_*_value() and resource_set_*(). Notes: svn path=/head/; revision=275460
* Make igb and ixgbe check tunables at probe time.Alfred Perlstein2014-11-261-0/+17
| | | | | | | | | | | | | | | This allows one to make a kernel module to tune the number of queues before the driver loads. This is needed so that a module at SI_SUB_CPU can set tunables for these drivers to take. Otherwise getenv is called too early by the TUNABLE macros. Reviewed by: smh Phabric: https://reviews.freebsd.org/D1149 Notes: svn path=/head/; revision=275136
* Add a bus_get_domain() wrapper around BUS_GET_DOMAIN(). Use this to addJohn Baldwin2014-11-241-0/+17
| | | | | | | | | | | | | | a new per-device '%domain' sysctl node that returns the NUMA domain a device is associated with if it is associated with one. Note that this API is still a WIP and might change before 11.0 actually ships. Differential Revision: https://reviews.freebsd.org/D930 Reviewed by: kib, adrian Notes: svn path=/head/; revision=274976
* This is the much-discussed major upgrade to the random(4) device, known to ↵Mark Murray2014-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | you all as /dev/random. This code has had an extensive rewrite and a good series of reviews, both by the author and other parties. This means a lot of code has been simplified. Pluggable structures for high-rate entropy generators are available, and it is most definitely not the case that /dev/random can be driven by only a hardware souce any more. This has been designed out of the device. Hardware sources are stirred into the CSPRNG (Yarrow, Fortuna) like any other entropy source. Pluggable modules may be written by third parties for additional sources. The harvesting structures and consequently the locking have been simplified. Entropy harvesting is done in a more general way (the documentation for this will follow). There is some GREAT entropy to be had in the UMA allocator, but it is disabled for now as messing with that is likely to annoy many people. The venerable (but effective) Yarrow algorithm, which is no longer supported by its authors now has an alternative, Fortuna. For now, Yarrow is retained as the default algorithm, but this may be changed using a kernel option. It is intended to make Fortuna the default algorithm for 11.0. Interested parties are encouraged to read ISBN 978-0-470-47424-2 "Cryptography Engineering" By Ferguson, Schneier and Kohno for Fortuna's gory details. Heck, read it anyway. Many thanks to Arthur Mesh who did early grunt work, and who got caught in the crossfire rather more than he deserved to. My thanks also to folks who helped me thresh this out on whiteboards and in the odd "Hallway track", or otherwise. My Nomex pants are on. Let the feedback commence! Reviewed by: trasz,des(partial),imp(partial?),rwatson(partial?) Approved by: so(des) Notes: svn path=/head/; revision=273872
* Add a bus method to fetch the VM domain for the given device/bus.Adrian Chadd2014-10-091-0/+31
| | | | | | | | | | | | | | | | | | | | | | * Add a bus_if.m method - get_domain() - returning the VM domain or ENOENT if the device isn't in a VM domain; * Add bus methods to print out the domain of the device if appropriate; * Add code in srat.c to save the PXM -> VM domain mapping that's done and expose a function to translate VM domain -> PXM; * Add ACPI and ACPI PCI methods to check if the bus has a _PXM attribute and if so map it to the VM domain; * (.. yes, this works recursively.) * Have the pci bus glue print out the device VM domain if present. Note: this is just the plumbing to start enumerating information - it doesn't at all modify behaviour. Differential Revision: D906 Reviewed by: jhb Sponsored by: Norse Corp Notes: svn path=/head/; revision=272799
* Don't panic if a resource is allocated twice. Instead, print a warning andJohn Baldwin2014-09-261-1/+4
| | | | | | | | | | fail the allocation request. Allocations of "reserved" resources such as PCI BARs already fail the request instead of panic'ing in this case. MFC after: 1 week Notes: svn path=/head/; revision=272182
* Stage one of multipass suspend/resumeJustin Hibbits2014-09-231-3/+37
| | | | | | | | | | | | | | | Summary: Add the beginnings of multipass suspend/resume, by introducing BUS_SUSPEND_CHILD/BUS_RESUME_CHILD, and move the PCI driver to this. Reviewers: jhb Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D590 Notes: svn path=/head/; revision=272013
* Clear nonblock and async on devctl close instaed of open.Mateusz Guzik2014-07-121-2/+2
| | | | | | | This is a purely cosmetic change. Notes: svn path=/head/; revision=268570
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-13/+14
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-14/+13
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* Revert r263754, re-adding support for hw.bus.devctl_disable. BreakingBrooks Davis2014-04-281-3/+37
| | | | | | | | | | | | | | | old devd's and thus hosts that get IP addresses from DHCP was too much of a POLA violation. The sysctl may be removed again after r263758 has been merged to at least stable/9 and stable/10, and releases have been cut from those branches. Discussed with: mjg Reported by: theraven, rwatson Notes: svn path=/head/; revision=265060
* Add kqueue support for devctl.David Xu2014-04-101-0/+41
| | | | | | | Reviewed by: kib,mjg Notes: svn path=/head/; revision=264310
* Fix SIGIO delivery. Use fsetown() to handle file descriptor ownerDavid Xu2014-04-041-30/+13
| | | | | | | | | | ioctl and use pgsigio() to send SIGIO. Submitted by: truckman Reviewed by: mjg Notes: svn path=/head/; revision=264114
* Document a known problem with handling the process intended to receiveMateusz Guzik2014-03-251-0/+16
| | | | | | | | | | SIGIO in /dev/devctl. Suggested by: adrian MFC after: 6 days Notes: svn path=/head/; revision=263755
* Remove long obsolete sysctl hw.bus.devctl_disable.Mateusz Guzik2014-03-251-37/+3
| | | | | | | | Suggested by: imp Relnotes: yes Notes: svn path=/head/; revision=263754
* Remove lockless check in devopen, while correct it does not make much sense.Mateusz Guzik2014-03-251-2/+0
| | | | | | | | Suggested by: imp MFC after: 6 days Notes: svn path=/head/; revision=263753
* Make /dev/devctl mpsafe.Mateusz Guzik2014-03-251-7/+15
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=263704
* Add YARROW_RNG and FORTUNA_RNG to sys/conf/options.Dag-Erling Smørgrav2013-10-081-0/+16
| | | | | | | | | | | | | Add a SYSINIT that forces a reseed during proc0 setup, which happens fairly late in the boot process. Add a RANDOM_DEBUG option which enables some debugging printf()s. Add a new RANDOM_ATTACH entropy source which harvests entropy from the get_cyclecount() delta across each call to a device attach method. Notes: svn path=/projects/random_number_generator/; revision=256138
* Allow drivers to return BUS_PROBE_NOWILDCARD from their attach routine toRyan Stone2013-08-081-3/+3
| | | | | | | | | | | match devices where the driver class was fixed but the unit number was wildcarded. This better matches the documented behaviour in DEVICE_PROBE(9). Reviewed by: imp Notes: svn path=/head/; revision=254100
* PR: 168520 170096Craig Rodrigues2013-07-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Submitted by: adrian, zec Fix multiple kernel panics when VIMAGE is enabled in the kernel. These fixes are based on patches submitted by Adrian Chadd and Marko Zec. (1) Set curthread->td_vnet to vnet0 in device_probe_and_attach() just before calling device_attach(). This fixes multiple VIMAGE related kernel panics when trying to attach Bluetooth or USB Ethernet devices because curthread->td_vnet is NULL. (2) Set curthread->td_vnet in if_detach(). This fixes kernel panics when detaching networking interfaces, especially USB Ethernet devices. (3) Use VNET_DOMAIN_SET() in ng_btsocket.c (4) In ng_unref_node() set curthread->td_vnet. This fixes kernel panics when detaching Netgraph nodes. Notes: svn path=/head/; revision=253346
* Make detaching drivers from PCI devices more robust. While here, fix aJohn Baldwin2013-06-271-0/+42
| | | | | | | | | | | | | | | | | | | bug where a PCI device would be powered down if it failed to probe, but not when its driver was detached (e.g. via kldunload). - Add a new helper method resource_list_release_active() which forcefully releases any active resources of a specified type from a resource list. - Add a bus_child_detached method for the PCI bus driver which forces any active resources to be released (and whines to the console if it finds any) and then powers the device down. - Call pci_child_detached() if we fail to probe a device when a driver is kldloaded. This isn't perfect but can avoid leaking resources from a probe() routine in the kldload case. Reviewed by: imp, brooks MFC after: 1 month Notes: svn path=/head/; revision=252315
* Fix a typo.John Baldwin2013-01-231-1/+1
| | | | Notes: svn path=/head/; revision=245845
* Provide a generic way to disable devices at boot timeEitan Adler2012-10-021-0/+7
| | | | | | | | | | | PR: kern/119202 Requested by: peterj Reviewed by: sbruno, jhb Approved by: cperciva MFC after: 1 week Notes: svn path=/head/; revision=241119
* Add a BUS_CHILD_DELETED() method that a bus can hook to allow it to cleanupJohn Baldwin2012-08-211-0/+2
| | | | | | | | | | any bus-specific state (such as ivars) when a child device is deleted. Requested by: kan MFC after: 1 month Notes: svn path=/head/; revision=239512
* Revert r239178 and implement two new functions, namelyHans Petter Selasky2012-08-151-14/+33
| | | | | | | | | | | | | | "device_free_softc()" and "device_claim_softc()", to allow USB serial drivers refcounting the softc. These functions are used to grab the softc from auto-free and to free the softc back to the correct malloc type, respectivly. Discussed with: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=239299
* Add new device method to free the automaticallyHans Petter Selasky2012-08-101-4/+14
| | | | | | | | | | | | | | | | | | allocated softc structure which is returned by device_get_softc(). This method can be used to easily implement softc refcounting. This can be desirable when the softc has memory references which are controlled by userspace handles for example. This solves the problem of blocking the caller of device_detach() for a non-deterministic time. Discussed with: kib, ed MFC after: 2 weeks Notes: svn path=/head/; revision=239178
* device_add_child: protect against child device with no driver but fixed unit ↵Andriy Gapon2012-05-251-0/+2
| | | | | | | | | | | | | | number This combination doesn't make sense, unit numbers should be hardwired only in context of a known driver. The wildcard devices should have wildcard unit numbers. Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=235978
* Allow device_busy() and device_unbusy() to be invoked while a device isJohn Baldwin2012-04-111-5/+13
| | | | | | | | | | | | | | being attached. This is implemented by adding a new DS_ATTACHING state while a device's DEVICE_ATTACH() method is being invoked. A driver is required to not fail an attach of a busy device. The device's state will be promoted to DS_BUSY rather than DS_ACTIVE() if the device was marked busy during DEVICE_ATTACH(). Reviewed by: kib MFC after: 1 week Notes: svn path=/head/; revision=234152
* Properly clear a device's devclass if DEVICE_ATTACH() fails if the deviceJohn Baldwin2012-02-281-3/+2
| | | | | | | | | | does not have a fixed devclass. Reviewed by: imp MFC after: 2 weeks Notes: svn path=/head/; revision=232265
* Clear the a device's description string anytime it's driver changes.John Baldwin2012-02-271-3/+2
| | | | | | | | | | | | | Descriptions are specific to drivers and we don't change drivers on attached devices. This fixes a few places where we were not clearing the description when detaching a driver (e.g. with device_attach() failed). While here, fix a few other nits: - Remove spurious call to remove a device's driver from devclass_driver_deleted(). device_detach() removes it already. - Fix a typo. Notes: svn path=/head/; revision=232218