Initial port of savage to FreeBSD for the AGP and !ShadowStatus case. Adds

drm_mtrr_{add,del} for handling the MTRR setup. Still has a LOR issue
    with DRM_VERIFYAREA_READ/DRM_COPY_FROM_USER_UNCHECKED in savage_bci.c
    -- this won't work with the fine-grained locking in use, and just doing
    a single copyin to a temporary will probably work fine. Also note that
    the module leaks approximately 4 kb on unload.
main
Eric Anholt 2005-11-08 20:25:00 +00:00
parent 2c6308fe54
commit a10d8178e3
8 changed files with 47 additions and 30 deletions

View File

@ -55,7 +55,7 @@ SHAREDFILES= drm.h \
via_verifier.h \ via_verifier.h \
via_video.c via_video.c
SUBDIR = drm mach64 mga r128 radeon sis tdfx # via i915 SUBDIR = drm mach64 mga r128 radeon savage sis tdfx # via i915
CLEANFILES+= ${SHAREDFILES} CLEANFILES+= ${SHAREDFILES}

View File

@ -843,7 +843,7 @@ void drm_free(void *pt, size_t size, int area);
void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map); void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map);
void drm_ioremapfree(drm_local_map_t *map); void drm_ioremapfree(drm_local_map_t *map);
int drm_mtrr_add(unsigned long offset, size_t size, int flags); int drm_mtrr_add(unsigned long offset, size_t size, int flags);
int drm_mtrr_del(unsigned long offset, size_t size, int flags); int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
int drm_context_switch(drm_device_t *dev, int old, int new); int drm_context_switch(drm_device_t *dev, int old, int new);
int drm_context_switch_complete(drm_device_t *dev, int new); int drm_context_switch_complete(drm_device_t *dev, int new);
@ -880,6 +880,7 @@ int drm_dma_setup(drm_device_t *dev);
void drm_dma_takedown(drm_device_t *dev); void drm_dma_takedown(drm_device_t *dev);
void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf); void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp); void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp);
#define drm_core_reclaim_buffers drm_reclaim_buffers
/* IRQ support (drm_irq.c) */ /* IRQ support (drm_irq.c) */
int drm_irq_install(drm_device_t *dev); int drm_irq_install(drm_device_t *dev);

View File

@ -297,7 +297,7 @@ void drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
if (map->mtrr) { if (map->mtrr) {
int __unused retcode; int __unused retcode;
retcode = drm_mtrr_del(map->offset, map->size, retcode = drm_mtrr_del(0, map->offset, map->size,
DRM_MTRR_WC); DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
} }

View File

@ -576,7 +576,7 @@ static void drm_unload(drm_device_t *dev)
if (dev->agp && dev->agp->mtrr) { if (dev->agp && dev->agp->mtrr) {
int __unused retcode; int __unused retcode;
retcode = drm_mtrr_del(dev->agp->info.ai_aperture_base, retcode = drm_mtrr_del(0, dev->agp->info.ai_aperture_base,
dev->agp->info.ai_aperture_size, DRM_MTRR_WC); dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d", retcode); DRM_DEBUG("mtrr_del = %d", retcode);
} }

View File

@ -113,7 +113,7 @@ drm_mtrr_add(unsigned long offset, size_t size, int flags)
} }
int int
drm_mtrr_del(unsigned long offset, size_t size, int flags) drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
{ {
int act; int act;
struct mem_range_desc mrdesc; struct mem_range_desc mrdesc;

View File

@ -43,15 +43,15 @@ extern int savage_max_ioctl;
static void savage_configure(drm_device_t *dev) static void savage_configure(drm_device_t *dev)
{ {
dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t); dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t);
dev->load = savage_driver_load; dev->driver.load = savage_driver_load;
dev->firstopen = savage_driver_firstopen; dev->driver.firstopen = savage_driver_firstopen;
dev->lastclose = savage_driver_lastclose; dev->driver.lastclose = savage_driver_lastclose;
dev->unload = savage_driver_unload; dev->driver.unload = savage_driver_unload;
dev->reclaim_buffers = savage_reclaim_buffers; dev->driver.reclaim_buffers_locked = savage_reclaim_buffers;
dev->dma_ioctl = savage_bci_buffers; dev->driver.dma_ioctl = savage_bci_buffers;
dev->ioctls = savage_ioctls; dev->driver.ioctls = savage_ioctls;
dev->max_ioctl = savage_max_ioctl; dev->driver.max_ioctl = savage_max_ioctl;
dev->driver.name = DRIVER_NAME; dev->driver.name = DRIVER_NAME;
dev->driver.desc = DRIVER_DESC; dev->driver.desc = DRIVER_DESC;
@ -60,10 +60,10 @@ static void savage_configure(drm_device_t *dev)
dev->driver.minor = DRIVER_MINOR; dev->driver.minor = DRIVER_MINOR;
dev->driver.patchlevel = DRIVER_PATCHLEVEL; dev->driver.patchlevel = DRIVER_PATCHLEVEL;
dev->use_agp = 1; dev->driver.use_agp = 1;
dev->use_mtrr = 1; dev->driver.use_mtrr = 1;
dev->use_pci_dma = 1; dev->driver.use_pci_dma = 1;
dev->use_dma = 1; dev->driver.use_dma = 1;
} }
#ifdef __FreeBSD__ #ifdef __FreeBSD__

View File

@ -763,6 +763,21 @@ static inline int drm_core_has_MTRR(struct drm_device *dev)
{ {
return drm_core_check_feature(dev, DRIVER_USE_MTRR); return drm_core_check_feature(dev, DRIVER_USE_MTRR);
} }
#define DRM_MTRR_WC MTRR_TYPE_WRCOMB
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
unsigned int flags)
{
return mtrr_add(offset, size, flags, 1);
}
static inline int drm_mtrr_del(int handle, unsigned long offset,
unsigned long size, unsigned int flags)
{
return mtrr_del(handle, offset, size);
}
#else #else
#define drm_core_has_MTRR(dev) (0) #define drm_core_has_MTRR(dev) (0)
#endif #endif

View File

@ -585,19 +585,19 @@ int savage_driver_firstopen(drm_device_t *dev)
* MTRRs. */ * MTRRs. */
dev_priv->mtrr[0].base = fb_base; dev_priv->mtrr[0].base = fb_base;
dev_priv->mtrr[0].size = 0x01000000; dev_priv->mtrr[0].size = 0x01000000;
dev_priv->mtrr[0].handle = mtrr_add( dev_priv->mtrr[0].handle = drm_mtrr_add(
dev_priv->mtrr[0].base, dev_priv->mtrr[0].size, dev_priv->mtrr[0].base, dev_priv->mtrr[0].size,
MTRR_TYPE_WRCOMB, 1); DRM_MTRR_WC);
dev_priv->mtrr[1].base = fb_base+0x02000000; dev_priv->mtrr[1].base = fb_base+0x02000000;
dev_priv->mtrr[1].size = 0x02000000; dev_priv->mtrr[1].size = 0x02000000;
dev_priv->mtrr[1].handle = mtrr_add( dev_priv->mtrr[1].handle = drm_mtrr_add(
dev_priv->mtrr[1].base, dev_priv->mtrr[1].size, dev_priv->mtrr[1].base, dev_priv->mtrr[1].size,
MTRR_TYPE_WRCOMB, 1); DRM_MTRR_WC);
dev_priv->mtrr[2].base = fb_base+0x04000000; dev_priv->mtrr[2].base = fb_base+0x04000000;
dev_priv->mtrr[2].size = 0x04000000; dev_priv->mtrr[2].size = 0x04000000;
dev_priv->mtrr[2].handle = mtrr_add( dev_priv->mtrr[2].handle = drm_mtrr_add(
dev_priv->mtrr[2].base, dev_priv->mtrr[2].size, dev_priv->mtrr[2].base, dev_priv->mtrr[2].size,
MTRR_TYPE_WRCOMB, 1); DRM_MTRR_WC);
} else { } else {
DRM_ERROR("strange pci_resource_len %08lx\n", DRM_ERROR("strange pci_resource_len %08lx\n",
drm_get_resource_len(dev, 0)); drm_get_resource_len(dev, 0));
@ -616,9 +616,9 @@ int savage_driver_firstopen(drm_device_t *dev)
* aperture. */ * aperture. */
dev_priv->mtrr[0].base = fb_base; dev_priv->mtrr[0].base = fb_base;
dev_priv->mtrr[0].size = 0x08000000; dev_priv->mtrr[0].size = 0x08000000;
dev_priv->mtrr[0].handle = mtrr_add( dev_priv->mtrr[0].handle = drm_mtrr_add(
dev_priv->mtrr[0].base, dev_priv->mtrr[0].size, dev_priv->mtrr[0].base, dev_priv->mtrr[0].size,
MTRR_TYPE_WRCOMB, 1); DRM_MTRR_WC);
} else { } else {
DRM_ERROR("strange pci_resource_len %08lx\n", DRM_ERROR("strange pci_resource_len %08lx\n",
drm_get_resource_len(dev, 1)); drm_get_resource_len(dev, 1));
@ -662,9 +662,10 @@ void savage_driver_lastclose(drm_device_t *dev)
for (i = 0; i < 3; ++i) for (i = 0; i < 3; ++i)
if (dev_priv->mtrr[i].handle >= 0) if (dev_priv->mtrr[i].handle >= 0)
mtrr_del(dev_priv->mtrr[i].handle, drm_mtrr_del(dev_priv->mtrr[i].handle,
dev_priv->mtrr[i].base, dev_priv->mtrr[i].base,
dev_priv->mtrr[i].size); dev_priv->mtrr[i].size,
DRM_MTRR_WC);
} }
int savage_driver_unload(drm_device_t *dev) int savage_driver_unload(drm_device_t *dev)
@ -961,8 +962,8 @@ static int savage_bci_event_emit(DRM_IOCTL_ARGS)
event.count = savage_bci_emit_event(dev_priv, event.flags); event.count = savage_bci_emit_event(dev_priv, event.flags);
event.count |= dev_priv->event_wrap << 16; event.count |= dev_priv->event_wrap << 16;
DRM_COPY_TO_USER_IOCTL(&((drm_savage_event_emit_t __user *)data)->count, DRM_COPY_TO_USER_IOCTL((drm_savage_event_emit_t __user *)data,
event.count, sizeof(event.count)); event, sizeof(event));
return 0; return 0;
} }