From 22ec8ebb17d959486e4a865b17115e609eb688ee Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Aug 2005 23:27:19 +0000 Subject: - Don't try to allocate mappings of less than a PAGE_SIZE in MGA DMA code. - Comment out the "is this mapping/bufs in allocated AGP" bits in BSD because they break mga (which uses AGP allocation that doesn't track entries). It's not a security issue when we still have the related ioctls marked root-only. - Apply some power-of-two alignment restrictions to hopefully avoid some panicing in bad cases of drm_pci_alloc() on FreeBSD. - Add verbosity to some error handling that I found useful while debugging. --- bsd-core/drm_pci.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bsd-core/drm_pci.c') diff --git a/bsd-core/drm_pci.c b/bsd-core/drm_pci.c index 0f431dd6..a33f5f9c 100644 --- a/bsd-core/drm_pci.c +++ b/bsd-core/drm_pci.c @@ -58,6 +58,13 @@ drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr) drm_dma_handle_t *dmah; int ret; + /* Need power-of-two alignment, so fail the allocation if it isn't. */ + if ((align & (align - 1)) != 0) { + DRM_ERROR("drm_pci_alloc with non-power-of-two alignment %d\n", + (int)align); + return NULL; + } + dmah = malloc(sizeof(drm_dma_handle_t), M_DRM, M_ZERO | M_NOWAIT); if (dmah == NULL) return NULL; -- cgit v1.2.3