summaryrefslogtreecommitdiff
path: root/sys/kern/subr_rman.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix an edge case in rman_manage_region() where it didn't handle a resourceJohn Baldwin2006-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 Notes: svn path=/head/; revision=164881
* - Fix rman_manage_region() to be a lot more intelligent. It now checksJohn Baldwin2006-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 Notes: svn path=/head/; revision=162224
* Report the correct function name in a DPRINTF.John Birrell2006-08-031-3/+4
| | | | Notes: svn path=/head/; revision=160958
* Add a convenience function rman_init_from_resource for initializingWarner Losh2006-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. Notes: svn path=/head/; revision=159536
* Remove the puc-specific hacks. The puc(4) driver now properly usesMarcel Moolenaar2006-04-281-25/+0
| | | | | | | the rman(9) interface. Notes: svn path=/head/; revision=158125
* r_spare1 and r_spare2 aren't needed. They aren't used. They can't beWarner Losh2006-04-191-2/+0
| | | | | | | | | accessed from outside of subr_rman.c. Remove them. Reviewed by: jmg (in theory) Notes: svn path=/head/; revision=157886
* Prefer NULL to 0.Pyun YongHyeon2005-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 Notes: svn path=/head/; revision=152543
* Eliminate __RMAN_RESOURCE_VISIBLE hack entirely by moving the structPoul-Henning Kamp2005-10-061-1/+25
| | | | | | | resource_ to subr_rman.c where it belongs. Notes: svn path=/head/; revision=151037
* puc(4) does strange things to resources in order to fool thePoul-Henning Kamp2005-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. Notes: svn path=/head/; revision=150698
* Add rman_is_region_manager() for the benefit of an alpha hack.Poul-Henning Kamp2005-09-251-0/+7
| | | | Notes: svn path=/head/; revision=150547
* Split struct resource in an external and internal part.Poul-Henning Kamp2005-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). Notes: svn path=/head/; revision=150523
* If we are going toColin Percival2005-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 Notes: svn path=/head/; revision=145953
* rman_set_device() seems to have been omitted by mistake. Implement it.Warner Losh2005-04-121-0/+6
| | | | Notes: svn path=/head/; revision=144932
* Move implementation of hw.bus.rman sysctl to subr_rman.c so thatPoul-Henning Kamp2005-03-241-0/+87
| | | | | | | | | subr_bus.c doesn't need to peek inside struct resource. OK from: imp Notes: svn path=/head/; revision=144071
* Sometimes, when asked to return region A..C, we'd return A+N..C+NWarner Losh2005-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/) Notes: svn path=/head/; revision=143665
* Fix a debugging printf. The order of start/end was inconsistant withWarner Losh2005-03-151-1/+1
| | | | | | | | all the other start/end debugs, causing momentary confusion when the output was examined. Notes: svn path=/head/; revision=143664
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139804
* Add a newline.Nate Lawson2004-08-191-1/+1
| | | | Notes: svn path=/head/; revision=134040
* Add debugging to rman_manage_region() as well. This is useful since weNate Lawson2004-08-191-0/+2
| | | | | | | | | manage subregions in ACPI. MFC after: 3 days Notes: svn path=/head/; revision=134021
* Fix the code in rman that merges adjacent unallocated resources to use aJohn Baldwin2004-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. Notes: svn path=/head/; revision=133177
* Add ability to set start/end for rmanWarner Losh2004-07-011-0/+12
| | | | Notes: svn path=/head/; revision=131414
* Hide struct resource and struct rman. You must defineWarner Losh2004-06-301-0/+1
| | | | | | | | | __RMAN_RESOURCE_VISIBLE to see inside these now. Reviewed by: dfr, njl (not njr) Notes: svn path=/head/; revision=131344
* Fix off by one error, twice.Warner Losh2004-04-121-2/+2
| | | | | | | Submitted by: Carlos Velasco (first one), jhb (second one) Notes: svn path=/head/; revision=128172
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116182
* Remove unused variable(s).Poul-Henning Kamp2003-05-311-2/+0
| | | | | | | Found by: FlexeLint Notes: svn path=/head/; revision=115549
* Implement rman_get_deviceWarner Losh2003-02-121-0/+6
| | | | | | | | | # I though this was alredy implemented Pointy hat on my head shown by: peter Notes: svn path=/head/; revision=110753
* Correct an off-by-one in the boundary check. Otherwise, resourceThomas Moestl2003-01-211-1/+1
| | | | | | | | allocations would fail if the desired allocation size was equal to the boundary. Notes: svn path=/head/; revision=109646
* Make the rman_{get,set}_* macros into real functions. The macrosWarner Losh2002-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 Notes: svn path=/head/; revision=107296
* Add debug.rman_debug sysctl MIB and loader tunable instead of brokenMitsuru IWASAKI2002-09-051-5/+7
| | | | | | | | RMAN_DEBUG option. This would be useful for debugging resource manager code. Notes: svn path=/head/; revision=102962
* Add sanity check seeing if adjusted start address exceeds end addressMitsuru IWASAKI2002-08-291-0/+4
| | | | | | | after boundary and alignment adjustment. Notes: svn path=/head/; revision=102572
* Change callers of mtx_init() to pass in an appropriate lock type name. InJohn Baldwin2002-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 Notes: svn path=/head/; revision=93818
* Add a rman_reserve_resource_bound() function that takes an additionalThomas Moestl2001-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. Notes: svn path=/head/; revision=88372
* - No need for resetting values to 0 when M_ZERO flag is used.Andrew R. Reiter2001-11-101-6/+0
| | | | | | | Approved: jhb Notes: svn path=/head/; revision=86243
* Use msleep() to avoid lost wakeup's instead of doing an ineffectiveJohn Baldwin2001-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> Notes: svn path=/head/; revision=85519
* Malloc mutexes pre-zero'd as random garbage (including 0xdeadcode) myJohn Baldwin2001-10-101-1/+1
| | | | | | | trigget the check to make sure we don't initalize a mutex twice. Notes: svn path=/head/; revision=84781
* Handle NULL struct device *sBrian Somers2001-05-281-2/+2
| | | | Notes: svn path=/head/; revision=77288
* Change and clean the mutex lock interface.Bosko Milekic2001-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) Notes: svn path=/head/; revision=72200
* Convert all simplelocks to mutexes and remove the simplelock implementations.Jason Evans2001-01-241-30/+30
| | | | Notes: svn path=/head/; revision=71576
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-10/+5
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* Bug fix for revision 1.14 on the replacement of CIRCLEQ with TAILQ.Kirk McKusick2000-11-151-6/+4
| | | | | | | Submitted by: Warner Losh <imp@village.org> Notes: svn path=/head/; revision=68764
* In preparation for deprecating CIRCLEQ macros in favor of TAILQKirk McKusick2000-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> Notes: svn path=/head/; revision=68727
* Cleanup the rman_make_alignment_flags function to be much clearer and shorterWarner Losh2000-10-221-12/+10
| | | | | | | than the prior version. Notes: svn path=/head/; revision=67425
* Implement resource alignment as discussed in arch@ a long time ago.Warner Losh2000-10-171-1/+23
| | | | | | | | | | This was implemented by Shigeru YAMAMOTO-san and Jonathan Chen. I've cleaned them up somewhat and they seem to work well enough to boot current (but given current's state it can be hard to tell). Doug Rabson also reviewed the design and signed off on it. Notes: svn path=/head/; revision=67261
* Replace all the ifdef debugging spaghetti with a single ifdef andPaul Richards2000-05-031-40/+22
| | | | | | | a macro so that it is easier to read the flow of the code. Notes: svn path=/head/; revision=59910
* Commit the remaining part of PR14914:Poul-Henning Kamp1999-11-161-16/+15
| | | | | | | | | | | | | | Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914 Notes: svn path=/head/; revision=53225
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Make sure that we record the flags in all cases.Doug Rabson1999-06-261-2/+2
| | | | | | | | Submitted by: Bernd Walter <ticso@cicely.de> PR: kern/12399 Notes: svn path=/head/; revision=48235
* Bring the 'new-bus' to the i386. This extensively changes the way thePeter Wemm1999-04-161-9/+30
| | | | | | | | | | | | | | | | | | | | | i386 platform boots, it is no longer ISA-centric, and is fully dynamic. Most old drivers compile and run without modification via 'compatability shims' to enable a smoother transition. eisa, isapnp and pccard* are not yet using the new resource manager. Once fully converted, all drivers will be loadable, including PCI and ISA. (Some other changes appear to have snuck in, including a port of Soren's ATA driver to the Alpha. Soren, back this out if you need to.) This is a checkpoint of work-in-progress, but is quite functional. The bulk of the work was done over the last few years by Doug Rabson and Garrett Wollman. Approved by: core Notes: svn path=/head/; revision=45720
* Staticize.Eivind Eklund1999-04-111-2/+2
| | | | Notes: svn path=/head/; revision=45569
* Fix a bug which prevented more than two clients from sharing a resource.Doug Rabson1999-03-291-2/+2
| | | | Notes: svn path=/head/; revision=45106