diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 679700dd136c..d87d18c89e06 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4243,11 +4243,12 @@ int amdgpu_device_init(struct amdgpu_device *adev, * 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. + * To keep doing this in register_framebuffer() the values are passed + * to register_fictitious_range() in additional FreeBSD-specific fields + * of drm_driver structure. */ - register_fictitious_range(adev->gmc.aper_base, adev->gmc.aper_size); + adev_to_drm(adev)->aperture_base = adev->gmc.aper_base; + adev_to_drm(adev)->aperture_size = adev->gmc.aper_size; #endif amdgpu_fence_driver_hw_init(adev); @@ -4460,10 +4461,6 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) /* disable ras feature must before hw fini */ amdgpu_ras_pre_fini(adev); -#ifdef __FreeBSD__ - unregister_fictitious_range(adev->gmc.aper_base, adev->gmc.aper_size); -#endif - amdgpu_ttm_set_buffer_funcs_status(adev, false); amdgpu_device_ip_fini_early(adev); diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 249b47c5b321..7dbfc7f3721b 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -594,7 +594,9 @@ static void drm_dev_init_release(struct drm_device *dev, void *res) drm_fs_inode_free(dev->anon_inode); #endif +#ifdef __linux__ put_device(dev->dev); +#endif /* Prevent use-after-free in drm_managed_release when debugging is * enabled. Slightly awkward, but can't really be helped. */ dev->dev = NULL; @@ -620,7 +622,11 @@ static int drm_dev_init(struct drm_device *dev, return -EINVAL; kref_init(&dev->ref); +#ifdef __linux__ dev->dev = get_device(parent); +#elif defined (__FreeBSD__) + dev->dev = parent; +#endif dev->driver = driver; INIT_LIST_HEAD(&dev->managed.resources); diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 2d1d3f57956d..14de360a685c 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1896,15 +1896,16 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) if (!drm_leak_fbdev_smem) info->flags |= FBINFO_HIDE_SMEM_START; -#ifdef __FreeBSD__ - info->fbio.fb_priv = fb_helper; -#endif - /* Need to drop locks to avoid recursive deadlock in * register_framebuffer. This is ok because the only thing left to do is * register the fbdev emulation instance in kernel_fb_helper_list. */ mutex_unlock(&fb_helper->lock); +#ifdef __FreeBSD__ + info->fb_bsddev = dev->dev->bsddev; + info->aperture_base = dev->aperture_base; + info->aperture_size = dev->aperture_size; +#endif ret = register_framebuffer(info); if (ret < 0) return ret; diff --git a/drivers/gpu/drm/drm_os_freebsd.c b/drivers/gpu/drm/drm_os_freebsd.c index 4a2278055404..cf05e35df9c0 100644 --- a/drivers/gpu/drm/drm_os_freebsd.c +++ b/drivers/gpu/drm/drm_os_freebsd.c @@ -1,29 +1,16 @@ +#include +#include +#include -#include -__FBSDID("$FreeBSD$"); +#include +#undef cdev #include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#undef fb_info -#undef cdev +#include "vt_drmfb.h" /* skip_ddb */ MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures"); @@ -31,7 +18,6 @@ SYSCTL_NODE(_dev, OID_AUTO, drm, CTLFLAG_RW, 0, "DRM args (compat)"); SYSCTL_LONG(_dev_drm, OID_AUTO, __drm_debug, CTLFLAG_RWTUN, &__drm_debug, 0, "drm debug flags (compat)"); SYSCTL_NODE(_hw, OID_AUTO, dri, CTLFLAG_RW, 0, "DRI args"); SYSCTL_LONG(_hw_dri, OID_AUTO, __drm_debug, CTLFLAG_RWTUN, &__drm_debug, 0, "drm debug flags"); -int skip_ddb; SYSCTL_INT(_dev_drm, OID_AUTO, skip_ddb, CTLFLAG_RWTUN, &skip_ddb, 0, "go straight to dumping core (compat)"); SYSCTL_INT(_hw_dri, OID_AUTO, skip_ddb, CTLFLAG_RWTUN, &skip_ddb, 0, "go straight to dumping core"); #if defined(DRM_DEBUG_LOG_ALL) @@ -77,40 +63,6 @@ sysctl_pci_id(SYSCTL_HANDLER_ARGS) return (sysctl_handle_string(oidp, buf, sizeof(buf), req)); } -int -register_fictitious_range(vm_paddr_t base, size_t size) -{ - int ret; - struct apertures_struct *ap; - - MPASS(base != 0); - MPASS(size != 0); - - ap = alloc_apertures(1); - ap->ranges[0].base = base; - ap->ranges[0].size = size; - vt_freeze_main_vd(ap); - kfree(ap); - - ret = vm_phys_fictitious_reg_range(base, base + size, -#ifdef VM_MEMATTR_WRITE_COMBINING - VM_MEMATTR_WRITE_COMBINING -#else - VM_MEMATTR_UNCACHEABLE -#endif - ); - MPASS(ret == 0); - - return (ret); -} - -void -unregister_fictitious_range(vm_paddr_t base, size_t size) -{ - vm_phys_fictitious_unreg_range(base, base + size); - vt_unfreeze_main_vd(); -} - /* Framebuffer related code */ int @@ -179,13 +131,6 @@ MODULE_VERSION(drmn, 2); #ifdef CONFIG_AGP MODULE_DEPEND(drmn, agp, 1, 1, 1); #endif -DRIVER_MODULE(iicbus, drmn, iicbus_driver, NULL, NULL); -DRIVER_MODULE(acpi_iicbus, drmn, acpi_iicbus_driver, NULL, NULL); -MODULE_DEPEND(drmn, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); -MODULE_DEPEND(drmn, iic, 1, 1, 1); -MODULE_DEPEND(drmn, iicbb, IICBB_MINVER, IICBB_PREFVER, IICBB_MAXVER); -MODULE_DEPEND(drmn, pci, 1, 1, 1); -MODULE_DEPEND(drmn, mem, 1, 1, 1); MODULE_DEPEND(drmn, linuxkpi, 1, 1, 1); MODULE_DEPEND(drmn, linuxkpi_video, 1, 1, 1); MODULE_DEPEND(drmn, dmabuf, 1, 1, 1); diff --git a/drivers/gpu/drm/drm_os_freebsd.h b/drivers/gpu/drm/drm_os_freebsd.h index 4426a3af4a14..d58681411ef3 100644 --- a/drivers/gpu/drm/drm_os_freebsd.h +++ b/drivers/gpu/drm/drm_os_freebsd.h @@ -3,15 +3,11 @@ * OS abstraction macros. */ -#include -__FBSDID("$FreeBSD$"); - #ifndef _DRM_OS_FREEBSD_H_ #define _DRM_OS_FREEBSD_H_ -#include -#include -#include +#include +#include #include #include @@ -25,35 +21,13 @@ __FBSDID("$FreeBSD$"); #define EREMOTEIO EIO #define KTR_DRM KTR_DEV -#define KTR_DRM_REG KTR_SPARE3 -MALLOC_DECLARE(DRM_MEM_DRIVER); +struct drm_minor; +struct device; -extern int skip_ddb; +MALLOC_DECLARE(DRM_MEM_DRIVER); -struct drm_minor; int drm_dev_alias(struct device *dev, struct drm_minor *minor, const char *minor_str); void cancel_reset_debug_log(void); -void vt_freeze_main_vd(struct apertures_struct *a); -void vt_unfreeze_main_vd(void); - -int register_fictitious_range(vm_paddr_t start, vm_paddr_t end); -void unregister_fictitious_range(vm_paddr_t start, vm_paddr_t end); - -#if 0 -struct linux_fb_info; -static inline void vga_switcheroo_unregister_client(struct pci_dev *pdev) {} -static inline int vga_switcheroo_register_client(struct pci_dev *pdev, - const struct vga_switcheroo_client_ops *ops) { return 0; } -static inline void vga_switcheroo_client_fb_set(struct pci_dev *pdev, struct linux_fb_info *info) {} -static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; } -static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev, - const struct vga_switcheroo_client_ops *ops, - int id, bool active) { return 0; } -static inline void vga_switcheroo_unregister_handler(void) {} -static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } -static inline int vga_switcheroo_get_client_state(struct pci_dev *pdev) { return VGA_SWITCHEROO_ON; } -#endif - #endif /* _DRM_OS_FREEBSD_H_ */ diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c index cde5baf99e50..16b155acd7e5 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -239,11 +239,12 @@ static int intelfb_create(struct drm_fb_helper *helper, * 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. + * To keep doing this in register_framebuffer() the values are passed + * to register_fictitious_range() in additional FreeBSD-specific fields + * of drm_driver structure. */ - register_fictitious_range(info->fix.smem_start, info->fix.smem_len); + dev->aperture_base = info->fix.smem_start; + dev->aperture_size = info->fix.smem_len; #endif drm_fb_helper_fill_info(info, &ifbdev->helper, sizes); @@ -297,12 +298,6 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev) * trying to rectify all the possible error paths leading here. */ -#ifdef __FreeBSD__ - unregister_fictitious_range( - ifbdev->helper.info->fix.smem_start, - ifbdev->helper.info->fix.smem_len); -#endif - drm_fb_helper_fini(&ifbdev->helper); if (ifbdev->vma) diff --git a/drivers/gpu/drm/linux_fb.c b/drivers/gpu/drm/linux_fb.c index 2aad76ab1540..331256c973aa 100644 --- a/drivers/gpu/drm/linux_fb.c +++ b/drivers/gpu/drm/linux_fb.c @@ -24,11 +24,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - -#undef fb_info - #include #include #include @@ -41,11 +36,11 @@ __FBSDID("$FreeBSD$"); #include #include "vt_drmfb.h" -#include +#include +#include + #include #include