Cleanup, turned off debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12651 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_IO_RESOURCES
|
//#define TRACE_IO_RESOURCES
|
||||||
#ifdef TRACE_IO_RESOURCES
|
#ifdef TRACE_IO_RESOURCES
|
||||||
# define TRACE(x) dprintf x
|
# define TRACE(x) dprintf x
|
||||||
#else
|
#else
|
||||||
@@ -58,7 +58,7 @@ static void unregister_colliding_node_range(io_resource_info *list,
|
|||||||
io_resource_info *resource);
|
io_resource_info *resource);
|
||||||
|
|
||||||
|
|
||||||
// validate I/O resource data
|
/** validate I/O resource data */
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
validate_io_resource(io_resource *src)
|
validate_io_resource(io_resource *src)
|
||||||
@@ -90,7 +90,7 @@ validate_io_resource(io_resource *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// allocate info structure for I/O resources
|
/** Allocate info structure for I/O resources */
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
alloc_io_resource_info(io_resource *src, io_resource_info **dest_out)
|
alloc_io_resource_info(io_resource *src, io_resource_info **dest_out)
|
||||||
@@ -114,9 +114,10 @@ alloc_io_resource_info(io_resource *src, io_resource_info **dest_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// acquire I/O range;
|
/** Acquire I/O range; returns B_WOULD_BLOCK on collision with
|
||||||
// returns B_WOULD_BLOCK on collision with temporary allocation
|
* temporary allocation.
|
||||||
// node_lock must be hold
|
* gNodeLock must be held
|
||||||
|
*/
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
acquire_range(io_resource_info **list, io_resource_info *resource)
|
acquire_range(io_resource_info **list, io_resource_info *resource)
|
||||||
@@ -175,7 +176,7 @@ acquire_range(io_resource_info **list, io_resource_info *resource)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// free I/O resource info
|
/** Free I/O resource info */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_io_resource_info(io_resource_info *resource)
|
free_io_resource_info(io_resource_info *resource)
|
||||||
@@ -191,7 +192,7 @@ free_io_resource_info(io_resource_info *resource)
|
|||||||
* appropriate resource list (i.e. mem/port/channel) plus
|
* appropriate resource list (i.e. mem/port/channel) plus
|
||||||
* all colliding resources (including ours) are marked blocked;
|
* all colliding resources (including ours) are marked blocked;
|
||||||
* returns B_WOULD_BLOCK on collision with temporary allocation;
|
* returns B_WOULD_BLOCK on collision with temporary allocation;
|
||||||
* gNodeLock must be hold.
|
* gNodeLock must be held.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
@@ -240,8 +241,9 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// release I/O resource
|
/** Release I/O resource.
|
||||||
// node_lock must be hold
|
* gNodeLock must be held
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_io_resource(io_resource_info *resource)
|
release_io_resource(io_resource_info *resource)
|
||||||
@@ -264,11 +266,12 @@ release_io_resource(io_resource_info *resource)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// release I/O range, which can be I/O memory, ports and ISA DMA channels
|
/** Release I/O range, which can be I/O memory, ports and ISA DMA channels
|
||||||
// up_to - up to but not including colliding range to be released
|
* up_to - up to but not including colliding range to be released
|
||||||
// (NULL for normal release, not-NULL if used during failed allocation)
|
* (NULL for normal release, not-NULL if used during failed allocation)
|
||||||
// blocked users get notified;
|
* blocked users get notified;
|
||||||
// node_lock must be hold
|
* gNodeLock must be held
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_range(io_resource_info **list, io_resource_info *resource, io_resource_info *up_to)
|
release_range(io_resource_info **list, io_resource_info *resource, io_resource_info *up_to)
|
||||||
@@ -309,13 +312,16 @@ release_range(io_resource_info **list, io_resource_info *resource, io_resource_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// wait until someone freed some resource or
|
/** Wait until someone freed some resource or
|
||||||
// allocated some resource permanently;
|
* allocated some resource permanently.
|
||||||
// node_lock must be hold
|
* gNodeLock must be held.
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wait_for_resources(void)
|
wait_for_resources(void)
|
||||||
{
|
{
|
||||||
|
TRACE(("wait_for_resources()\n"));
|
||||||
|
|
||||||
++pnp_resource_wait_count;
|
++pnp_resource_wait_count;
|
||||||
|
|
||||||
// we have to release while waiting
|
// we have to release while waiting
|
||||||
@@ -323,15 +329,14 @@ wait_for_resources(void)
|
|||||||
|
|
||||||
acquire_sem(pnp_resource_wait_sem);
|
acquire_sem(pnp_resource_wait_sem);
|
||||||
|
|
||||||
TRACE(("retrying resource allocation"));
|
|
||||||
|
|
||||||
benaphore_unlock(&gNodeLock);
|
benaphore_unlock(&gNodeLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// try to acquire list of resources.
|
/** Try to acquire list of resources.
|
||||||
// returns B_WOULD_BLOCK on collision with temporary allocation
|
* returns B_WOULD_BLOCK on collision with temporary allocation.
|
||||||
// node_lock must be hold
|
* gNodeLock must be held.
|
||||||
|
*/
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
try_acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
try_acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
||||||
@@ -363,11 +368,12 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// acquire I/O resources.
|
/** Acquire I/O resources.
|
||||||
// node_lock must be hold
|
* gNodeLock must be held.
|
||||||
|
*/
|
||||||
|
|
||||||
static
|
static status_t
|
||||||
status_t acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
||||||
{
|
{
|
||||||
// try allocation until we either got all resources or
|
// try allocation until we either got all resources or
|
||||||
// detected a collision with a loaded device node
|
// detected a collision with a loaded device node
|
||||||
@@ -386,14 +392,14 @@ status_t acquire_io_resources(io_resource *resources, io_resource_handle *handle
|
|||||||
wait_for_resources();
|
wait_for_resources();
|
||||||
} else {
|
} else {
|
||||||
// collided with loaded node - no point waiting for the node
|
// collided with loaded node - no point waiting for the node
|
||||||
TRACE(("Giving up because collision with loaded device node\n"));
|
TRACE(("acquire_io_resouces(): Collision with loaded device node\n"));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// unregister devices that collide with one of our I/O resources
|
/** Unregister devices that collide with one of our I/O resources */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unregister_colliding_nodes(const io_resource_handle *resources)
|
unregister_colliding_nodes(const io_resource_handle *resources)
|
||||||
@@ -416,7 +422,7 @@ unregister_colliding_nodes(const io_resource_handle *resources)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** unregister device nodes that collide with I/O resource */
|
/** Unregister device nodes that collide with I/O resource */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unregister_colliding_node_range(io_resource_info *list, io_resource_info *resource)
|
unregister_colliding_node_range(io_resource_info *list, io_resource_info *resource)
|
||||||
@@ -439,7 +445,7 @@ unregister_colliding_node_range(io_resource_info *list, io_resource_info *resour
|
|||||||
if (owner == NULL)
|
if (owner == NULL)
|
||||||
panic("Transfer of I/O resources from temporary to device node collided with other temporary allocation");
|
panic("Transfer of I/O resources from temporary to device node collided with other temporary allocation");
|
||||||
|
|
||||||
TRACE(("Deleting colliding node %p\n", owner));
|
TRACE(("Deleting colliding device node %p\n", owner));
|
||||||
|
|
||||||
// make sure node still exists after we'll have released lock
|
// make sure node still exists after we'll have released lock
|
||||||
++owner->ref_count;
|
++owner->ref_count;
|
||||||
@@ -462,8 +468,8 @@ unregister_colliding_node_range(io_resource_info *list, io_resource_info *resour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** unblock other temporary allocations so they can retry
|
/** Unblock other temporary allocations so they can retry.
|
||||||
* gNodeLock must be hold
|
* gNodeLock must be held.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -481,8 +487,8 @@ unblock_temporary_allocation(void)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/** transfer temporary I/O resources to device node;
|
/** Transfer temporary I/O resources to device node;
|
||||||
* colliding devices are unregistered
|
* colliding devices are unregistered.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -513,9 +519,9 @@ dm_assign_io_resources(device_node_info *node, const io_resource_handle *resourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** release I/O resources of a device node and set list to NULL;
|
/** Release I/O resources of a device node and set list to NULL;
|
||||||
* users previously blocked by our resource alloction are notified;
|
* users previously blocked by our resource alloction are notified;
|
||||||
* gNodeLock must be hold
|
* gNodeLock must be held.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -546,17 +552,17 @@ dm_release_node_resources(device_node_info *node)
|
|||||||
status_t
|
status_t
|
||||||
dm_acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
dm_acquire_io_resources(io_resource *resources, io_resource_handle *handles)
|
||||||
{
|
{
|
||||||
status_t res;
|
status_t status;
|
||||||
|
|
||||||
TRACE(("pnp_acquire_io_resources()\n"));
|
TRACE(("dm_acquire_io_resources()\n"));
|
||||||
|
|
||||||
benaphore_lock(&gNodeLock);
|
benaphore_lock(&gNodeLock);
|
||||||
res = acquire_io_resources(resources, handles);
|
status = acquire_io_resources(resources, handles);
|
||||||
benaphore_unlock(&gNodeLock);
|
benaphore_unlock(&gNodeLock);
|
||||||
|
|
||||||
TRACE(("done (%s)", strerror(res)));
|
TRACE((" done (%s)", strerror(status)));
|
||||||
|
|
||||||
return res;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user