Page MenuHomeFreeBSD

bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHOD
AcceptedPublic

Authored by jhb on Tue, Oct 28, 5:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 2, 8:05 AM
Unknown Object (File)
Sun, Nov 2, 8:04 AM
Unknown Object (File)
Sun, Nov 2, 3:47 AM
Unknown Object (File)
Sat, Nov 1, 1:59 PM
Unknown Object (File)
Wed, Oct 29, 7:53 AM
Unknown Object (File)
Wed, Oct 29, 7:03 AM
Unknown Object (File)
Wed, Oct 29, 2:51 AM
Unknown Object (File)
Wed, Oct 29, 1:14 AM

Details

Reviewers
imp
andrew
manu
Summary

The wrapper functions such as bus_alloc_resource_any() still support
passing the rid by value or pointer, but the underlying implementation
now passes by value.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68171
Build 65054: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Tue, Oct 28, 5:17 PM

This will need a __FreeBSD_version bump, and I know that at least drm-kmod will need an #if test based on that as it has an internal call to BUS_ALLOC_RESOURCE (not one of the wrapper functions) that needs to be patched after this.

Woof!
But likely good. Nobody ever changed / adjusted the RIDs...

This revision is now accepted and ready to land.Tue, Oct 28, 10:39 PM
In D53402#1219730, @jhb wrote:

This will need a __FreeBSD_version bump, and I know that at least drm-kmod will need an #if test based on that as it has an internal call to BUS_ALLOC_RESOURCE (not one of the wrapper functions) that needs to be patched after this.

I wonder if that FreeBSD specific code could actually be handled inside LinuxKPI as the #ifdef for pci_bus_alloc_resource() doesn't seem too complicated. That way at least the FreeBSD-specific code migrates into LinuxKPI and out of drm-kmod and that could be done upfront and once the all branches and the ports are updated this one can go in. Just asking. I am on the road so haven't done much due diligens.

In D53402#1220105, @bz wrote:
In D53402#1219730, @jhb wrote:

This will need a __FreeBSD_version bump, and I know that at least drm-kmod will need an #if test based on that as it has an internal call to BUS_ALLOC_RESOURCE (not one of the wrapper functions) that needs to be patched after this.

I wonder if that FreeBSD specific code could actually be handled inside LinuxKPI as the #ifdef for pci_bus_alloc_resource() doesn't seem too complicated. That way at least the FreeBSD-specific code migrates into LinuxKPI and out of drm-kmod and that could be done upfront and once the all branches and the ports are updated this one can go in. Just asking. I am on the road so haven't done much due diligens.

I do not think it can. It isn't part of LinuxKPI per se, but has to do with vgpci0 being a pseudo-bus.

@manu This change causes a build breakage in drm-kmod that I have worked around locally with the patch below. I plan to bump __FreeBSD_version when committing this, and just want to coordinate on the fix as I won't know the new version number until I actually push the change.

diff --git a/drivers/gpu/drm/i915/intel_freebsd.c b/drivers/gpu/drm/i915/intel_freebsd.c
index 3a8a3b9fa5..37bf3a7c62 100644
--- a/drivers/gpu/drm/i915/intel_freebsd.c
+++ b/drivers/gpu/drm/i915/intel_freebsd.c
@@ -58,7 +58,7 @@ bsd_intel_pci_bus_alloc_mem(device_t dev, int *rid, uintmax_t size,
 
        vga = device_get_parent(dev);
        res = BUS_ALLOC_RESOURCE(device_get_parent(vga), dev, SYS_RES_MEMORY,
-           rid, 0, ~0UL, size, RF_ACTIVE | RF_SHAREABLE);
+           *rid, 0, ~0UL, size, RF_ACTIVE | RF_SHAREABLE);
        if (res != NULL) {
                *start = rman_get_start(res);
                *end = rman_get_end(res);
 

I also don't know if you want to fix this differently in your tree.