Page MenuHomeFreeBSD

INTRNG generalization step 2 - extending struct resource
ClosedPublic

Authored by skra on May 29 2016, 3:51 PM.

Details

Summary

Interrupts are described by compound data in modern SOCs and a single number is no more enough. However, newbus API is only oriented to a single number. And so are almost all (if not all) bus drivers as they use struct resource_list API or some modification of that. In fact, there is nothing wrong about a single number, but we need such a number to be connected to data describing associated interrupt (resource). And this data should be accessible by bus drivers in a convenient way.

In INTRNG generalization step 1 (D5730), we created own storage for such data associated with a global scope interrupt number as a temporary solution. This was/is both orthogonal and local solution to this problem. Further, as data is associated with a driver (not with an interrupt), the solution is not correct. Now, we would like to make newbus like solution. And we would like to do that by extending bus drivers, not by reworking them. This change is about that.

The idea is that there may be bus drivers which cannot call bus_set_resource() on their child drivers in time when they are added as the information needed for that is not available at this time. Thus bus_extend_resource() method is introduced which is called internally during bus_alloc_resource() call. This function allows a device parent to do what bus_set_resource() does, but in time when a child driver is being attached. Further, this function may return data which describes the resource. And this data is stored in this resource to be available later.

This is exactly the situation in OFW (FDT) case. An OFW bus driver can read a description of an interrupt for its child driver, but it's not able to convert it to an interrupt number as it does not understand the description. It's not even able to save this description for later use. Only an interrupt controller understands the description which belongs to it, but it may not be attached at this time.

As mainline release is coming, the idea is implemented only for interrupt resources and only in INTRNG case now. And r_virtual member of struct resource_i is used to store the data associated with an interrupt. It should be safe for resources with SYS_RES_IRQ type.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

skra retitled this revision from to INTRNG generalization step 2 - extending struct resource.May 29 2016, 3:51 PM
skra updated this object.
skra edited the test plan for this revision. (Show Details)
skra added reviewers: imp, jhb.
skra set the repository for this revision to rS FreeBSD src repository.
skra updated this revision to Diff 17074.
emaste added a subscriber: emaste.Jun 3 2016, 8:34 PM
This revision was automatically updated to reflect the committed changes.