From 2649103bf9c4eb471a10800f4a3161dca6249086 Mon Sep 17 00:00:00 2001 From: vehemens Date: Fri, 29 Aug 2008 13:18:54 -0400 Subject: [FreeBSD] Convert drm_driver to a pointer like linux. Signed-off-by: Robert Noland --- bsd-core/i915_drv.c | 77 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 32 deletions(-) (limited to 'bsd-core/i915_drv.c') diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index c19ef5db..d2301ddd 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -68,37 +68,37 @@ static int i915_resume(device_t nbdev) static void i915_configure(struct drm_device *dev) { - dev->driver.buf_priv_size = sizeof(drm_i915_private_t); - dev->driver.load = i915_driver_load; - dev->driver.unload = i915_driver_unload; - dev->driver.firstopen = i915_driver_firstopen; - dev->driver.preclose = i915_driver_preclose; - dev->driver.lastclose = i915_driver_lastclose; - dev->driver.device_is_agp = i915_driver_device_is_agp; - dev->driver.get_vblank_counter = i915_get_vblank_counter; - dev->driver.enable_vblank = i915_enable_vblank; - dev->driver.disable_vblank = i915_disable_vblank; - dev->driver.irq_preinstall = i915_driver_irq_preinstall; - dev->driver.irq_postinstall = i915_driver_irq_postinstall; - dev->driver.irq_uninstall = i915_driver_irq_uninstall; - dev->driver.irq_handler = i915_driver_irq_handler; - - dev->driver.ioctls = i915_ioctls; - dev->driver.max_ioctl = i915_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - dev->driver.major = DRIVER_MAJOR; - dev->driver.minor = DRIVER_MINOR; - dev->driver.patchlevel = DRIVER_PATCHLEVEL; - - dev->driver.use_agp = 1; - dev->driver.require_agp = 1; - dev->driver.use_mtrr = 1; - dev->driver.use_irq = 1; - dev->driver.use_vbl_irq = 1; - dev->driver.use_vbl_irq2 = 1; + dev->driver->buf_priv_size = sizeof(drm_i915_private_t); + dev->driver->load = i915_driver_load; + dev->driver->unload = i915_driver_unload; + dev->driver->firstopen = i915_driver_firstopen; + dev->driver->preclose = i915_driver_preclose; + dev->driver->lastclose = i915_driver_lastclose; + dev->driver->device_is_agp = i915_driver_device_is_agp; + dev->driver->get_vblank_counter = i915_get_vblank_counter; + dev->driver->enable_vblank = i915_enable_vblank; + dev->driver->disable_vblank = i915_disable_vblank; + dev->driver->irq_preinstall = i915_driver_irq_preinstall; + dev->driver->irq_postinstall = i915_driver_irq_postinstall; + dev->driver->irq_uninstall = i915_driver_irq_uninstall; + dev->driver->irq_handler = i915_driver_irq_handler; + + dev->driver->ioctls = i915_ioctls; + dev->driver->max_ioctl = i915_max_ioctl; + + dev->driver->name = DRIVER_NAME; + dev->driver->desc = DRIVER_DESC; + dev->driver->date = DRIVER_DATE; + dev->driver->major = DRIVER_MAJOR; + dev->driver->minor = DRIVER_MINOR; + dev->driver->patchlevel = DRIVER_PATCHLEVEL; + + dev->driver->use_agp = 1; + dev->driver->require_agp = 1; + dev->driver->use_mtrr = 1; + dev->driver->use_irq = 1; + dev->driver->use_vbl_irq = 1; + dev->driver->use_vbl_irq2 = 1; } #ifdef __FreeBSD__ @@ -114,17 +114,30 @@ i915_attach(device_t nbdev) struct drm_device *dev = device_get_softc(nbdev); bzero(dev, sizeof(struct drm_device)); + + dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, M_ZERO); i915_configure(dev); + return drm_attach(nbdev, i915_pciidlist); } +static int +i915_detach(device_t nbdev) +{ + struct drm_device *dev = device_get_softc(nbdev); + + free(dev->driver, M_DRM); + + return drm_detach(nbdev); +} + static device_method_t i915_methods[] = { /* Device interface */ DEVMETHOD(device_probe, i915_probe), DEVMETHOD(device_attach, i915_attach), DEVMETHOD(device_suspend, i915_suspend), DEVMETHOD(device_resume, i915_resume), - DEVMETHOD(device_detach, drm_detach), + DEVMETHOD(device_detach, i915_detach), { 0, 0 } }; -- cgit v1.2.3 From 2b278047153df729caf9e516a432b2e76398cd3a Mon Sep 17 00:00:00 2001 From: vehemens Date: Wed, 27 Aug 2008 19:11:04 -0700 Subject: [FreeBSD] Use driver features macros and flags Signed-off-by: Robert Noland --- bsd-core/i915_drv.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'bsd-core/i915_drv.c') diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index d2301ddd..8f21075d 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -68,6 +68,10 @@ static int i915_resume(device_t nbdev) static void i915_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | + DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = sizeof(drm_i915_private_t); dev->driver->load = i915_driver_load; dev->driver->unload = i915_driver_unload; @@ -92,13 +96,6 @@ static void i915_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->require_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; - dev->driver->use_vbl_irq2 = 1; } #ifdef __FreeBSD__ -- cgit v1.2.3 From ed6dd03818f2fa4dd0f2ba34dee58b09c7ff253e Mon Sep 17 00:00:00 2001 From: vehemens Date: Tue, 2 Sep 2008 02:43:19 -0700 Subject: Need M_NOWAIT for malloc. Signed-off-by: Robert Noland --- bsd-core/i915_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsd-core/i915_drv.c') diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index 8f21075d..71a8d64d 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -112,7 +112,7 @@ i915_attach(device_t nbdev) bzero(dev, sizeof(struct drm_device)); - dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, M_ZERO); + dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, M_NOWAIT | M_ZERO); i915_configure(dev); return drm_attach(nbdev, i915_pciidlist); -- cgit v1.2.3 From 828ae3f6b88b5a69a56b2961307e40ed95edea29 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Mon, 8 Sep 2008 16:40:52 -0400 Subject: [FreeBSD] We need to call drm_detach before we free dev->driver. The driver is in control of the show, so when you try and unload a module the driver detach routine is called first. It is what drives the whole unload process and so lots of panics occur if dev->driver is already free. --- bsd-core/i915_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bsd-core/i915_drv.c') diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index 71a8d64d..7e745190 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -122,10 +122,13 @@ static int i915_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t i915_methods[] = { -- cgit v1.2.3 From 973c634eaa54ee4085a72102c690bc643cb2d7a8 Mon Sep 17 00:00:00 2001 From: vehemens Date: Mon, 8 Sep 2008 22:06:09 -0700 Subject: Remove incomplete and obsolete free/net/open code. Signed-off-by: Robert Noland --- bsd-core/i915_drv.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'bsd-core/i915_drv.c') diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index 7e745190..def35f0b 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -98,7 +98,6 @@ static void i915_configure(struct drm_device *dev) dev->driver->patchlevel = DRIVER_PATCHLEVEL; } -#ifdef __FreeBSD__ static int i915_probe(device_t dev) { @@ -159,7 +158,3 @@ DRIVER_MODULE(i915, vgapci, i915_driver, drm_devclass, 0, 0); DRIVER_MODULE(i915, agp, i915_driver, drm_devclass, 0, 0); #endif MODULE_DEPEND(i915, drm, 1, 1, 1); - -#elif defined(__NetBSD__) || defined(__OpenBSD__) -CFDRIVER_DECL(i915, DV_TTY, NULL); -#endif -- cgit v1.2.3