Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/drm_fb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
67 changes: 6 additions & 61 deletions drivers/gpu/drm/drm_os_freebsd.c
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/reboot.h>

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <linux/cdev.h>
#undef cdev

#include <drm/drm_file.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_print.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_os_freebsd.h>

#include <sys/types.h>
#include <sys/bus.h>
#include <dev/agp/agpreg.h>
#include <dev/pci/pcireg.h>
#include <sys/reboot.h>
#include <sys/fbio.h>
#include <dev/vt/vt.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>

#include <vm/vm_phys.h>

#include <linux/cdev.h>
#include <linux/fb.h>
#undef fb_info
#undef cdev
#include "vt_drmfb.h" /* skip_ddb */

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");
#if defined(DRM_DEBUG_LOG_ALL)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
36 changes: 5 additions & 31 deletions drivers/gpu/drm/drm_os_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
* OS abstraction macros.
*/

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#ifndef _DRM_OS_FREEBSD_H_
#define _DRM_OS_FREEBSD_H_

#include <sys/fbio.h>
#include <sys/priv.h>
#include <sys/smp.h>
#include <sys/param.h>
#include <sys/bus.h>

#include <linux/mod_devicetable.h>
#include <linux/fb.h>
Expand All @@ -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_ */
15 changes: 5 additions & 10 deletions drivers/gpu/drm/i915/display/intel_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
Loading