remove rid pointer (but not rid)...

M. Warner Losh imp at bsdimp.com
Wed Apr 19 22:58:52 UTC 2006


In message: <20060419220401.GO38619 at funkthat.com>
            John-Mark Gurney <gurney_j at resnet.uoregon.edu> writes:
: I was looking at our interface, and realized that since we now have
: rman_get_rid, that passing in a rid pointer to bus_alloc_resource is
: out dated... you can get the new updated rid directly from the resource
: returned...

More precisely, you need to pass the rid into bus_alloc_resource.
What is no longer needed is to get the modified rid value back.  While
in theory with the current API the rid could change, a quick audit of
the tree I just did shows that no one currently changes the rid.

: This will benifit bus_alloc_resources, as we can constify the _spec
: parameter, to make driver writing simpler...

This is good.

: We can also reduce the use of the type parameter by including it as
: part of the resource, and then eliminate that parameter from the
: release, free cases...
: 
: I have briefly discussed this w/ jhb, phk and imp, and they agree that
: this should be fixed...
:
: My new proposed prototypes:
: # this is the bus_if.m:
: static struct resource *bus_alloc_resource(device_t dev, device_t child,
: int type, int rid, u_long start, u_long end, u_long count, u_int flags)

'const int *rid' is another alternative here, that might be less invasive.

: from bus.h:
: int bus_alloc_resources(device_t dev, const struct resource_spec *rs, struct resource 
: **res);
: void bus_release_resources(device_t dev, const struct resource_spec *rs, struct resource **res);
: struct resource *bus_alloc_resource(device_t dev, int type, int rid, u_long start, u_long end, u_long count, u_int flags);
: int bus_activate_resource(device_t dev, struct resource *r);
: int bus_deactivate_resource(device_t dev, struct resource *r);
: int bus_release_resource(device_t dev, struct resource *r);
: int bus_free_resource(device_t dev, struct resource *r);
: 
: we'll add a couple more functions:
: int rman_get_restype(struct resource *);
: void rman_set_restype(struct resource *, int);
: 
: and of course add the appropriate field to resource_i...

This will, of course, be a big undertaking in the tree.  There are
1216 instances of the string 'alloc_resource'  Every single one of
them will need to change in some way.  This will make porting to older
versions of FreeBSD more difficult, since you'll need ifdefs for the
passing of this parameter.  Moreover, each of these changes isn't
going to be mechanical.  There's a number of drivers that assume that
rid will be modified and carefully save it against future need (the
release), so fixes in this area need to be done carefully.  While most
of those drivers could benefit from the newer bus_alloc_resources()
API, testing becomes problematic.

We should also make sure that all the override functions for
bus_alloc_resource declare their functions as a bus_alloc_resource_t.
Only the ones in sparc64-land do today.

Warner


More information about the freebsd-arch mailing list