- normalize netbsd drm_mtrr_del() with freebsd, removing a few #if's

- make the mtrr code do nothing on non-x86
This commit is contained in:
mrg 2009-09-02 01:36:41 +00:00
parent 2d22194137
commit 6769a80c80
5 changed files with 19 additions and 21 deletions

View File

@ -75,8 +75,10 @@ struct drm_file;
#endif
#include <machine/pmap.h>
#include <machine/bus.h>
#if defined(__i386__) || defined(__x86_64__)
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#endif
#include <sys/endian.h>
#include <sys/mman.h>
#if defined( __FreeBSD__)
@ -94,7 +96,9 @@ struct drm_file;
#include <sys/selinfo.h>
#include <sys/bus.h>
#elif defined(__NetBSD__)
#if defined(__i386__) || defined(__x86_64__)
#include <machine/mtrr.h>
#endif
#include <sys/vnode.h>
#include <sys/select.h>
#include <sys/device.h>
@ -293,7 +297,11 @@ enum {
#define PAGE_ALIGN(addr) ALIGN(addr)
#define DRM_SUSER(p) (kauth_cred_getsvuid((p)->p_cred) == 0)
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
#ifdef MTRR_TYPE_WC
#define DRM_MTRR_WC MTRR_TYPE_WC
#else
#define DRM_MTRR_WC 0
#endif
#define jiffies hardclock_ticks
#define DRM_MAXUNITS 128
@ -968,13 +976,8 @@ void drm_mem_uninit(void);
void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
void drm_ioremapfree(drm_local_map_t *map);
#if defined(__FreeBSD__)
int drm_mtrr_add(unsigned long offset, size_t size, int flags);
int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
#elif defined(__NetBSD__)
int drm_mtrr_add(unsigned long offset, size_t size, int flags);
int drm_mtrr_del(unsigned long offset, size_t size, int flags);
#endif
int drm_context_switch(struct drm_device *dev, int old, int new);
int drm_context_switch_complete(struct drm_device *dev, int new);

View File

@ -323,13 +323,8 @@ void drm_rmmap(struct drm_device *dev, drm_local_map_t *map)
case _DRM_FRAME_BUFFER:
if (map->mtrr) {
int __unused retcode;
#if defined(__FreeBSD__)
retcode = drm_mtrr_del(0, map->offset, map->size,
DRM_MTRR_WC);
#elif defined(__NetBSD__)
retcode = drm_mtrr_del(map->offset, map->size,
DRM_MTRR_WC);
#endif
DRM_DEBUG("mtrr_del = %d\n", retcode);
}
break;

View File

@ -385,7 +385,7 @@ drm_attach(device_t kdev, struct pci_attach_args *pa, drm_pci_id_list_t *idlist)
dev->pci_map_data[unit].flags |= BUS_SPACE_MAP_LINEAR;
DRM_DEBUG("pci resource %d: type=%d, base=%lx, size=%zx, flags=%x\n",
unit, dev->pci_map_data[unit].maptype,
dev->pci_map_data[unit].base,
(unsigned long)dev->pci_map_data[unit].base,
dev->pci_map_data[unit].size,
dev->pci_map_data[unit].flags);
}
@ -710,10 +710,7 @@ static void drm_unload(struct drm_device *dev)
if (dev->agp && dev->agp->mtrr) {
int __unused retcode;
retcode = drm_mtrr_del(
#if defined(__FreeBSD__)
0,
#endif
retcode = drm_mtrr_del(0,
dev->agp->info.ai_aperture_base,
dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d", retcode);

View File

@ -245,6 +245,7 @@ drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
int
drm_mtrr_add(unsigned long offset, size_t size, int flags)
{
#ifdef MTRR_GETSET_KERNEL
struct mtrr mtrrmap;
int one = 1;
@ -253,11 +254,15 @@ drm_mtrr_add(unsigned long offset, size_t size, int flags)
mtrrmap.type = flags;
mtrrmap.flags = MTRR_VALID;
return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
#else
return 0;
#endif
}
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)
{
#ifdef MTRR_GETSET_KERNEL
struct mtrr mtrrmap;
int one = 1;
@ -266,5 +271,8 @@ drm_mtrr_del(unsigned long offset, size_t size, int flags)
mtrrmap.type = flags;
mtrrmap.flags = 0;
return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
#else
return 0;
#endif
}
#endif

View File

@ -661,14 +661,9 @@ void savage_driver_lastclose(struct drm_device *dev)
for (i = 0; i < 3; ++i)
if (dev_priv->mtrr[i].handle >= 0)
#if defined(__FreeBSD__)
drm_mtrr_del(dev_priv->mtrr[i].handle,
dev_priv->mtrr[i].base,
dev_priv->mtrr[i].size, DRM_MTRR_WC);
#elif defined(__NetBSD__)
drm_mtrr_del(dev_priv->mtrr[i].base,
dev_priv->mtrr[i].size, DRM_MTRR_WC);
#endif
}
int savage_driver_unload(struct drm_device *dev)