Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use drm_fb_helper's emulation of Linux fbdev to integrate with FreeBSD's vt(4) #243

Merged
merged 10 commits into from
Nov 26, 2023
Merged
30 changes: 26 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,26 @@ int amdgpu_device_init(struct amdgpu_device *adev,
goto release_ras_con;
}

#ifdef __FreeBSD__
/*
* After amdgpu_device_ip_init(), gmc.aper_base and gmc.aper_size are
* set, and mode_config.fb_base was initialized from gmc.aper_base.
* Therefore, we can register the fictitious memory range.
*
* This was handled in register_framebuffer() in the past, based on the
* values of info->apertures->ranges[0]. However, the `amdgpu` driver
* stopped setting them when it got rid of its specific framebuffer
* initialization to use the generic drm_fb_helper code.
*
* We can't do this in register_framebuffer() anymore because the
* values passed to register_fictitious_range() below are unavailable
* from a generic structure set by both drivers.
*/
register_fictitious_range(
adev_to_drm(adev)->mode_config.fb_base,
adev->gmc.aper_size);
#endif

amdgpu_fence_driver_hw_init(adev);

dev_info(adev->dev,
Expand Down Expand Up @@ -3876,6 +3896,12 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)

amdgpu_fbdev_fini(adev);

#ifdef __FreeBSD__
unregister_fictitious_range(
adev_to_drm(adev)->mode_config.fb_base,
adev->gmc.aper_size);
#endif

amdgpu_device_ip_fini_early(adev);

amdgpu_irq_fini_hw(adev);
Expand Down Expand Up @@ -3919,10 +3945,6 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
amdgpu_discovery_fini(adev);

kfree(adev->pci_state);

#ifdef __FreeBSD__
vt_unfreeze_main_vd();
#endif
}

/**
Expand Down
4 changes: 0 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
the helper contains a pointer to amdgpu framebuffer baseclass.
*/

#ifdef __linux__
static int
amdgpufb_open(struct fb_info *info, int user)
{
Expand All @@ -69,18 +68,15 @@ amdgpufb_release(struct fb_info *info, int user)
pm_runtime_put_autosuspend(fb_helper->dev->dev);
return 0;
}
#endif /* __linux__ */

static const struct fb_ops amdgpufb_ops = {
.owner = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
#ifdef __linux__
.fb_open = amdgpufb_open,
.fb_release = amdgpufb_release,
.fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = drm_fb_helper_cfb_copyarea,
.fb_imageblit = drm_fb_helper_cfb_imageblit,
#endif
};


Expand Down
Loading