diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 28586e46c604..202dd6e4dde2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4387,11 +4387,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(ddev, 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); @@ -4604,10 +4605,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_to_drm(adev), 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_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index da9449b37291..acd0da34cf2f 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -46,11 +46,6 @@ #include "drm_internal.h" #include "drm_crtc_internal.h" -#ifdef __FreeBSD__ -#define register_framebuffer linux_register_framebuffer -#define unregister_framebuffer linux_unregister_framebuffer -#endif - static bool drm_fbdev_emulation = true; module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600); MODULE_PARM_DESC(fbdev_emulation, @@ -1900,15 +1895,17 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) info = fb_helper->info; info->var.pixclock = 0; -#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_fbdev_ttm.c b/drivers/gpu/drm/drm_fbdev_ttm.c index 48e276a331e2..45021990218f 100644 --- a/drivers/gpu/drm/drm_fbdev_ttm.c +++ b/drivers/gpu/drm/drm_fbdev_ttm.c @@ -46,9 +46,7 @@ static void drm_fbdev_ttm_fb_destroy(struct fb_info *info) if (!fb_helper->dev) return; -#ifdef __linux__ fb_deferred_io_cleanup(info); -#endif drm_fb_helper_fini(fb_helper); vfree(shadow); drm_client_framebuffer_delete(fb_helper->buffer); diff --git a/drivers/gpu/drm/drm_os_freebsd.c b/drivers/gpu/drm/drm_os_freebsd.c index b7f6bba44010..6662cbcf8696 100644 --- a/drivers/gpu/drm/drm_os_freebsd.c +++ b/drivers/gpu/drm/drm_os_freebsd.c @@ -1,40 +1,25 @@ +#include +#include +#include -#include -__FBSDID("$FreeBSD$"); +#include +#undef cdev +#include /* linuxkpi_skip_ddb */ #include #include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#undef fb_info -#undef cdev - MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures"); 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"); +SYSCTL_INT(_dev_drm, OID_AUTO, skip_ddb, CTLFLAG_RWTUN, &linuxkpi_skip_ddb, 0, "go straight to dumping core (compat)"); +SYSCTL_INT(_hw_dri, OID_AUTO, skip_ddb, CTLFLAG_RWTUN, &linuxkpi_skip_ddb, 0, "go straight to dumping core"); #if defined(DRM_DEBUG_LOG_ALL) int drm_debug_persist = 1; #else @@ -78,44 +63,6 @@ sysctl_pci_id(SYSCTL_HANDLER_ARGS) return (sysctl_handle_string(oidp, buf, sizeof(buf), req)); } -int -register_fictitious_range(struct drm_device *ddev, 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); - - ddev->fictitious_range_registered = true; - - return (ret); -} - -void -unregister_fictitious_range(struct drm_device *ddev, vm_paddr_t base, size_t size) -{ - if (ddev->fictitious_range_registered) { - vm_phys_fictitious_unreg_range(base, base + size); - vt_unfreeze_main_vd(); - } -} - /* Framebuffer related code */ int @@ -182,13 +129,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 3ff742cad2bf..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,36 +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); - -struct drm_device; -int register_fictitious_range(struct drm_device *ddev, vm_paddr_t start, vm_paddr_t end); -void unregister_fictitious_range(struct drm_device *ddev, 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 f5bc2850cf58..56e5aa98b0cb 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -140,13 +140,6 @@ static void intel_fbdev_fb_destroy(struct fb_info *info) struct drm_fb_helper *fb_helper = info->par; struct intel_fbdev *ifbdev = container_of(fb_helper, struct intel_fbdev, helper); -#ifdef __FreeBSD__ - unregister_fictitious_range( - fb_helper->dev, - ifbdev->helper.info->fix.smem_start, - ifbdev->helper.info->fix.smem_len); -#endif - drm_fb_helper_fini(&ifbdev->helper); /* @@ -270,11 +263,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(dev, 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); diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c b/drivers/gpu/drm/radeon/radeon_fbdev.c index 5ec0447cd666..5e7803b6d6cb 100644 --- a/drivers/gpu/drm/radeon/radeon_fbdev.c +++ b/drivers/gpu/drm/radeon/radeon_fbdev.c @@ -177,11 +177,6 @@ static void radeon_fbdev_fb_destroy(struct fb_info *info) struct drm_framebuffer *fb = fb_helper->fb; struct drm_gem_object *gobj = drm_gem_fb_get_obj(fb, 0); -#ifdef __FreeBSD__ - struct radeon_device *rdev = fb_helper->dev->dev_private; - unregister_fictitious_range(fb_helper->dev, rdev->mc.aper_base, rdev->mc.aper_size); -#endif - drm_fb_helper_fini(fb_helper); drm_framebuffer_unregister_private(fb); @@ -284,11 +279,12 @@ static int radeon_fbdev_fb_helper_fb_probe(struct drm_fb_helper *fb_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(fb_helper->dev, rdev->mc.aper_base, rdev->mc.aper_size); + rdev->ddev.aperture_base = rdev->mc.aper_base; + rdev->ddev.aperture_size = rdev->mc.aper_size; #endif /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ diff --git a/drivers/gpu/drm/vt_drmfb.h b/drivers/gpu/drm/vt_drmfb.h deleted file mode 100644 index f054883f71f4..000000000000 --- a/drivers/gpu/drm/vt_drmfb.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2013 The FreeBSD Foundation - * Copyright (c) 2023 Jean-Sébastien Pédron - * - * This initial software `sys/dev/vt/hw/vt_fb.h` was developed by Aleksandr - * Rybalko under sponsorship from the FreeBSD Foundation. - * This file is a copy of the initial file and is modified by Jean-Sébastien - * Pédron. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _DEV_VT_HW_FB_VT_DRMFB_H_ -#define _DEV_VT_HW_FB_VT_DRMFB_H_ -/* Generic framebuffer interface call vt_drmfb_attach to init VT(9) */ -int vt_drmfb_attach(struct fb_info *info); -void vt_drmfb_resume(struct vt_device *vd); -void vt_drmfb_suspend(struct vt_device *vd); -int vt_drmfb_detach(struct fb_info *info); - -#endif /* _DEV_VT_HW_FB_VT_DRMFB_H_ */ diff --git a/drivers/video/aperture.c b/drivers/video/linux_aperture.c similarity index 99% rename from drivers/video/aperture.c rename to drivers/video/linux_aperture.c index 6a88dd8b64af..54173de08008 100644 --- a/drivers/video/aperture.c +++ b/drivers/video/linux_aperture.c @@ -244,6 +244,7 @@ int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, } EXPORT_SYMBOL(devm_aperture_acquire_for_platform_device); +#ifdef __linux__ static void aperture_detach_devices(resource_size_t base, resource_size_t size) { resource_size_t end = base + size; @@ -293,9 +294,7 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si * ask for this, so let's assume that a real driver for the display * was already probed and prevent sysfb to register devices later. */ -#ifdef __linux__ sysfb_disable(NULL); -#endif aperture_detach_devices(base, size); @@ -330,11 +329,7 @@ int __aperture_remove_legacy_vga_devices(struct pci_dev *pdev) aperture_detach_devices(VGA_FB_PHYS_BASE, VGA_FB_PHYS_SIZE); /* VGA textmode console */ -#ifdef __linux__ return vga_remove_vgacon(pdev); -#elif defined(__FreeBSD__) - return 0; -#endif } EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices); @@ -355,9 +350,7 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na resource_size_t base, size; int bar, ret = 0; -#ifdef __linux__ sysfb_disable(&pdev->dev); -#endif for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) @@ -379,4 +372,5 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na return ret; } +#endif EXPORT_SYMBOL(aperture_remove_conflicting_pci_devices); diff --git a/drivers/video/cmdline.c b/drivers/video/linux_cmdline.c similarity index 100% rename from drivers/video/cmdline.c rename to drivers/video/linux_cmdline.c diff --git a/drivers/gpu/drm/linux_fb.c b/drivers/video/linux_fb.c similarity index 72% rename from drivers/gpu/drm/linux_fb.c rename to drivers/video/linux_fb.c index 10d34554ae23..e37b65dc07ac 100644 --- a/drivers/gpu/drm/linux_fb.c +++ b/drivers/video/linux_fb.c @@ -24,28 +24,23 @@ * */ -#include -__FBSDID("$FreeBSD$"); - -#undef fb_info - #include -#include #include +#include #include #include +#include #include #include -#include #include -#include "vt_drmfb.h" -#include +#include +#include + +#include #include #include