summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_rman.c
Commit message (Collapse)AuthorAgeFilesLines
* sysctl_rman: report shared resources to devinfoavg2009-05-191-24/+34
| | | | | | | | | | | shared uses of a resource are recorded on a sub-list hanging off a main resource object on a main resource list; without this change a shared resource (e.g. irq) is reported only once by devinfo -r/-u; with this change the resource is reported for each driver that allocates it (which is even more than what vmstat -i -a reports). Approved by: jhb (mentor)
* rman_debug should be static, so make it static.imp2009-02-031-1/+1
|
* Trivially avoid a null pointer dereference when driversmarcel2008-10-221-1/+2
| | | | | | don't set the rman description. While drivers should set it, a kernel panic is not the right behaviour when faced without one.
* Make ddb command registration dynamic so modules can extendsam2008-09-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | the command set (only so long as the module is present): o add db_command_register and db_command_unregister to add and remove commands, respectively o replace linker sets with SYSINIT's (and SYSUINIT's) that register commands o expose 3 list heads: db_cmd_table, db_show_table, and db_show_all_table for registering top-level commands, show operands, and show all operands, respectively While here also: o sort command lists o add DB_ALIAS, DB_SHOW_ALIAS, and DB_SHOW_ALL_ALIAS to add aliases for existing commands o add "show all trace" as an alias for "show alltrace" o add "show all locks" as an alias for "show alllocks" Submitted by: Guillaume Ballet <gballet@gmail.com> (original version) Reviewed by: jhb MFC after: 1 month
* Resort a few accessor routines so that they are consistently groupedjhb2008-08-251-17/+17
| | | | with 'set_foo/get_foo' adjacent to each other.
* Complete removal of restriction about overlaps to rman_manage_region:jmg2007-04-281-4/+0
| | | | | | | | remove comment and man page verbage... Document return values for rman_init and rman_manage_region.. MFC after: 1 week
* - Add a 'show rman <rm>' DDB command to dump the resources in a resourcejhb2007-04-161-0/+50
| | | | | | manager similar to 'devinfo -u'. - Add a 'show allrman' DDB command that effectively does 'show rman' on all resource managers in the system.
* Fix a case in rman_manage_region() where the resource list would get missorted.scottl2007-02-231-6/+7
| | | | | This would in turn confuse rman_reserve_resource(). This was only seen for MSI resources that can get allocated and deallocated after boot.
* Fix an edge case in rman_manage_region() where it didn't handle a resourcejhb2006-12-041-4/+7
| | | | | | | ending at ULONG_MAX properly. While here, use TAILQ_FOREACH_SAFE(). Tested by: "Stephane E. Potvin" <sepotvin at videotron-ca> MFC after: 1 week
* - Fix rman_manage_region() to be a lot more intelligent. It now checksjhb2006-09-111-3/+41
| | | | | | | | | | | for overlaps, but more importantly, it collapses adjacent free regions. This is needed to cope with BIOSen that split up ports for system devices (like IPMI controllers) across multiple system resource entries. - Now that rman_manage_region() is not so dumb, remove extra logic in the x86 nexus drivers to populate the IRQ rman that manually coalesced the regions. MFC after: 1 week
* Report the correct function name in a DPRINTF.jb2006-08-031-3/+4
|
* Add a convenience function rman_init_from_resource for initializingimp2006-06-121-0/+10
| | | | | | | a rman from a resource. Also, include _bus.h since the implementation of bus_space isn't needed here, just the definitions of the types.
* Remove the puc-specific hacks. The puc(4) driver now properly usesmarcel2006-04-281-25/+0
| | | | the rman(9) interface.
* r_spare1 and r_spare2 aren't needed. They aren't used. They can't beimp2006-04-191-2/+0
| | | | | | accessed from outside of subr_rman.c. Remove them. Reviewed by: jmg (in theory)
* Prefer NULL to 0.yongari2005-11-171-25/+29
| | | | | | | | | Add missing lock/unlock in sysctl handler. Protect accessing NULL pointer when resource allocation was failed. style(9) Reviewed by: scottl MFC after: 1 week
* Eliminate __RMAN_RESOURCE_VISIBLE hack entirely by moving the structphk2005-10-061-1/+25
| | | | resource_ to subr_rman.c where it belongs.
* puc(4) does strange things to resources in order to fool thephk2005-09-281-0/+25
| | | | | | | | | | subdrivers to hook up. It should probably be rewritten to implement a simple bus to which the sub drivers attach using some kind of hint. Until then, provide a couple of crutch functions with big warning signs so it can survive the recent changes to struct resource.
* Add rman_is_region_manager() for the benefit of an alpha hack.phk2005-09-251-0/+7
|
* Split struct resource in an external and internal part.phk2005-09-241-40/+57
| | | | | | | | | | | | | | The external part is still called 'struct resource' but the contents is now visible to drivers etc. This makes it part of the device driver ABI so it not be changed lightly. A comment to this effect is in place. The internal part is called 'struct resource_i' and contain its external counterpart as one field. Move the bus_space tag+handle into the external struct resource, this removes the need for device drivers to even know about these fields in order to use bus_space to access hardware. (More in following commit).
* If we are going tocperciva2005-05-061-0/+2
| | | | | | | | | | 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
* rman_set_device() seems to have been omitted by mistake. Implement it.imp2005-04-121-0/+6
|
* Move implementation of hw.bus.rman sysctl to subr_rman.c so thatphk2005-03-241-0/+87
| | | | | | subr_bus.c doesn't need to peek inside struct resource. OK from: imp
* Sometimes, when asked to return region A..C, we'd return A+N..C+Nimp2005-03-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of failing. When looking for a region to allocate, we used to check to see if the start address was < end. In the case where A..B is allocated already, and one wants to allocate A..C (B < C), then this test would improperly fail (which means we'd examine that region as a possible one), and we'd return the region B+1..C+(B-A+1) rather than NULL. Since C+(B-A+1) is necessarily larger than C (end argument), this is incorrect behavior for rman_reserve_resource_bound(). The fix is to exclude those regions where r->r_start + count - 1 > end rather than r->r_start > end. This bug has been in this code for a very long time. I believe that all other tests against end are correctly done. This is why sio0 generated a message about interrupts not being enabled properly for the device. When fdc had a bug that allocated from 0x3f7 to 0x3fb, sio0 was then given 0x3fc-0x404 rather than the 0x3f8-0x3ff that it wanted. Now when fdc has the same bug, sio0 fails to allocate its ports, which is the proper behavior. Since the probe failed, we never saw the messed up resources reported. I suspect that there are other places in the tree that have weird looping or other odd work arounds to try to cope with the observed weirdness this bug can introduce. These workarounds should be located and eliminated. Minor debug write fix to match the above test done as well. 'nice' by: mdodd Sponsored by: timing solutions (http://www.timing.com/)
* Fix a debugging printf. The order of start/end was inconsistant withimp2005-03-151-1/+1
| | | | | all the other start/end debugs, causing momentary confusion when the output was examined.
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Add a newline.njl2004-08-191-1/+1
|
* Add debugging to rman_manage_region() as well. This is useful since wenjl2004-08-191-0/+2
| | | | | | manage subregions in ACPI. MFC after: 3 days
* Fix the code in rman that merges adjacent unallocated resources to use ajhb2004-08-051-5/+12
| | | | | | | | | | | | | | | better check for 'adjacent'. The old code assumed that if two resources were adjacent in the linked list that they were also adjacent range wise. This is not true when a resource manager has to manage disparate regions. For example, the current interrupt code on i386/amd64 will instruct irq_rman to manage two disjoint regions: 0-1 and 3-15 for the non-APIC case. If IRQs 1 and 3 were allocated and then released, the old code would coalesce across the 1 to 3 boundary because the resources were adjacent in the linked list thus adding 2 to the area of resources that irq_rman managed as a side effect. The fix adds extra checks so that adjacent unallocated resources are only merged with the resource being freed if the start and end values of the resources also match up. The patch also consolidates the checks for adjacent resources being allocated.
* Add ability to set start/end for rmanimp2004-07-011-0/+12
|
* Hide struct resource and struct rman. You must defineimp2004-06-301-0/+1
| | | | | | __RMAN_RESOURCE_VISIBLE to see inside these now. Reviewed by: dfr, njl (not njr)
* Fix off by one error, twice.imp2004-04-121-2/+2
| | | | Submitted by: Carlos Velasco (first one), jhb (second one)
* Use __FBSDID().obrien2003-06-111-2/+3
|
* Remove unused variable(s).phk2003-05-311-2/+0
| | | | Found by: FlexeLint
* Implement rman_get_deviceimp2003-02-121-0/+6
| | | | | | # I though this was alredy implemented Pointy hat on my head shown by: peter
* Correct an off-by-one in the boundary check. Otherwise, resourcetmm2003-01-211-1/+1
| | | | | allocations would fail if the desired allocation size was equal to the boundary.
* Make the rman_{get,set}_* macros into real functions. The macrosimp2002-11-271-0/+72
| | | | | | | | | | | | | | | create an ABI that encodes offsets and sizes of structures into client drivers. The functions isolate the ABI from changes to the resource structure. Since these are used very rarely (once at startup), the speed penalty will be down in the noise. Also, add r_rid to the structure so that clients can save the 'rid' of the resource in the struct resource, plus accessor functions. Future additions to newbus will make use of this to present a simplified interface for resource specification. Approved by: re (jhb) Reviewed by: jhb, jake
* Add debug.rman_debug sysctl MIB and loader tunable instead of brokeniwasaki2002-09-051-5/+7
| | | | | RMAN_DEBUG option. This would be useful for debugging resource manager code.
* Add sanity check seeing if adjusted start address exceeds end addressiwasaki2002-08-291-0/+4
| | | | after boundary and alignment adjustment.
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-2/+2
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Add a rman_reserve_resource_bound() function that takes an additionaltmm2001-12-211-11/+35
| | | | | | argument specifying the boundary for the resource allocation. Use ulmin()/ulmax() instead of min()/max() in some places to correctly deal with the u_long resource range specifications.
* - No need for resetting values to 0 when M_ZERO flag is used.arr2001-11-101-6/+0
| | | | Approved: jhb
* Use msleep() to avoid lost wakeup's instead of doing an ineffectivejhb2001-10-261-15/+5
| | | | | | | | splhigh() before the mtx_unlock and tsleep(). The splhigh() was probably correct in the original code using simplelocks but is not correct in 5.0-current. Noticed by: Andrew Reiter <awr@FreeBSD.org>
* Malloc mutexes pre-zero'd as random garbage (including 0xdeadcode) myjhb2001-10-101-1/+1
| | | | trigget the check to make sure we don't initalize a mutex twice.
* Handle NULL struct device *sbrian2001-05-281-2/+2
|
* Change and clean the mutex lock interface.bmilekic2001-02-091-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Convert all simplelocks to mutexes and remove the simplelock implementations.jasone2001-01-241-30/+30
|
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-10/+5
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Bug fix for revision 1.14 on the replacement of CIRCLEQ with TAILQ.mckusick2000-11-151-6/+4
| | | | Submitted by: Warner Losh <imp@village.org>
* In preparation for deprecating CIRCLEQ macros in favor of TAILQmckusick2000-11-141-34/+29
| | | | | | | macros which provide the same functionality and are a bit more efficient, convert use of CIRCLEQ's in resource manager to TAILQ's. Approved by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
* Cleanup the rman_make_alignment_flags function to be much clearer and shorterimp2000-10-221-12/+10
| | | | than the prior version.
OpenPOWER on IntegriCloud