From bd07ed2b4d7071716c09895e19849e8b04991656 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 23 Nov 2005 21:45:43 +1100 Subject: I think that if a PCI bus is a root bus, attached to a host bridge not a PCI->PCI bridge, then bus->self is allowed to be NULL. Certainly that's the case on my Pegasos, and it makes the MGA DRM driver oops... Signed-off-by: David Woodhouse Signed-off-by: Dave Airlie --- drivers/char/drm/mga_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c index 0cc7c305a7f6..1713451a5cc6 100644 --- a/drivers/char/drm/mga_drv.c +++ b/drivers/char/drm/mga_drv.c @@ -161,7 +161,7 @@ static int mga_driver_device_is_agp(drm_device_t * dev) * device. */ - if ((pdev->device == 0x0525) + if ((pdev->device == 0x0525) && pdev->bus->self && (pdev->bus->self->vendor == 0x3388) && (pdev->bus->self->device == 0x0021)) { return 0; -- cgit v1.2.3-59-g8ed1b From c41f47121d8bf44b886ef2039779dab8c1e3a25f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 23 Nov 2005 22:09:13 +1100 Subject: drm: add __GFP_COMP to the drm_alloc_pages The DRM only uses drm_alloc_pages for non-SG PCI cards using DRM. Signed-off-by: Hugh Dickins Signed-off-by: Dave Airlie --- drivers/char/drm/drm_memory.c | 2 +- drivers/char/drm/drm_memory_debug.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c index 2c74155aa84f..abef2acf99f5 100644 --- a/drivers/char/drm/drm_memory.c +++ b/drivers/char/drm/drm_memory.c @@ -95,7 +95,7 @@ unsigned long drm_alloc_pages(int order, int area) unsigned long addr; unsigned int sz; - address = __get_free_pages(GFP_KERNEL, order); + address = __get_free_pages(GFP_KERNEL|__GFP_COMP, order); if (!address) return 0; diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h index 4542353195bd..b370aca718d2 100644 --- a/drivers/char/drm/drm_memory_debug.h +++ b/drivers/char/drm/drm_memory_debug.h @@ -221,7 +221,7 @@ unsigned long DRM(alloc_pages) (int order, int area) { } spin_unlock(&DRM(mem_lock)); - address = __get_free_pages(GFP_KERNEL, order); + address = __get_free_pages(GFP_KERNEL|__GFP_COMP, order); if (!address) { spin_lock(&DRM(mem_lock)); ++DRM(mem_stats)[area].fail_count; -- cgit v1.2.3-59-g8ed1b From 7655f493b74f3048c02458bc32cd0b144f7b394f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 23 Nov 2005 22:12:59 +1100 Subject: drm: move is_pci to the end of the structure We memset the structure across opens except for the flags. The correct fix is more intrusive but this should fix a problem with bad iounmaps seen on AGP radeons acting like PCI ones. Signed-off-by: Dave Airlie --- drivers/char/drm/radeon_drv.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 120ee5a8ebcc..7bda7e33d2bd 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h @@ -214,8 +214,6 @@ typedef struct drm_radeon_private { int microcode_version; - int is_pci; - struct { u32 boxes; int freelist_timeouts; @@ -275,6 +273,7 @@ typedef struct drm_radeon_private { /* starting from here on, data is preserved accross an open */ uint32_t flags; /* see radeon_chip_flags */ + int is_pci; } drm_radeon_private_t; typedef struct drm_radeon_buf_priv { -- cgit v1.2.3-59-g8ed1b From cf65f1623dd005ddfb1cbba20af3423a6c638dbe Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 24 Nov 2005 21:41:14 +1100 Subject: drm: fix quiescent locking A fix for a locking bug which is triggered when a client tries to lock with flag DMA_QUIESCENT (typically the X server), but gets interrupted by a signal. The locking IOCTL should then return an error, but if DMA_QUIESCENT succeeds it returns 0, and the client falsely thinks it has the lock. In addition The client waits for DMA_QUISCENT and possibly DMA_READY without having the lock. From: Thomas Hellstrom Signed-off-by: Dave Airlie --- drivers/char/drm/drm_lock.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c index b276ae8a6633..b48a595d54ec 100644 --- a/drivers/char/drm/drm_lock.c +++ b/drivers/char/drm/drm_lock.c @@ -104,6 +104,10 @@ int drm_lock(struct inode *inode, struct file *filp, __set_current_state(TASK_RUNNING); remove_wait_queue(&dev->lock.lock_queue, &entry); + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + if (ret) + return ret; + sigemptyset(&dev->sigmask); sigaddset(&dev->sigmask, SIGSTOP); sigaddset(&dev->sigmask, SIGTSTP); @@ -116,8 +120,12 @@ int drm_lock(struct inode *inode, struct file *filp, if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY)) dev->driver->dma_ready(dev); - if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) - return dev->driver->dma_quiescent(dev); + if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) { + if (dev->driver->dma_quiescent(dev)) { + DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context); + return DRM_ERR(EBUSY); + } + } /* dev->driver->kernel_context_switch isn't used by any of the x86 * drivers but is used by the Sparc driver. @@ -128,9 +136,7 @@ int drm_lock(struct inode *inode, struct file *filp, dev->driver->kernel_context_switch(dev, dev->last_context, lock.context); } - DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); - - return ret; + return 0; } /** -- cgit v1.2.3-59-g8ed1b From c801147c5a103eec864afee348c4ee3fdb0f380c Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Wed, 30 Nov 2005 15:32:59 +0100 Subject: [PATCH] SiS DRM: Fix possible NULL dereference This fixes a NULL pointer reference in DRM. The SiS driver tries to allocate a big chunk of memory, but the return value is never checked. Reported in Novell bugzilla #132271: https://bugzilla.novell.com/show_bug.cgi?id=132271 Signed-off-by: Takashi Iwai Signed-off-by: Linus Torvalds --- drivers/char/drm/drm_context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c index bdd168d88f49..bd958d69a2ac 100644 --- a/drivers/char/drm/drm_context.c +++ b/drivers/char/drm/drm_context.c @@ -432,7 +432,10 @@ int drm_addctx(struct inode *inode, struct file *filp, if (ctx.handle != DRM_KERNEL_CONTEXT) { if (dev->driver->context_ctor) - dev->driver->context_ctor(dev, ctx.handle); + if (!dev->driver->context_ctor(dev, ctx.handle)) { + DRM_DEBUG( "Running out of ctxs or memory.\n"); + return -ENOMEM; + } } ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST); -- cgit v1.2.3-59-g8ed1b From 47807ce381acc34a7ffee2b42e35e96c0f322e52 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 13 Dec 2005 04:18:41 +0000 Subject: [drm] fix radeon aperture issue Ben noticed that on certain cards we've landed the AGP space on top of the second aperture instead of after it.. Which messes things up a lot on those machines. This just moves the gart further out, a more correct fix is in the works from Ben for after 2.6.15. Signed-off-by: Dave Airlie CC: Ben Herrenschmidt Signed-off-by: Linus Torvalds --- drivers/char/drm/radeon_cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 03839ea31092..9f2b4efd0c7a 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -1522,7 +1522,7 @@ static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) dev_priv->gart_size = init->gart_size; dev_priv->gart_vm_start = dev_priv->fb_location - + RADEON_READ(RADEON_CONFIG_APER_SIZE); + + RADEON_READ(RADEON_CONFIG_APER_SIZE) * 2; #if __OS_HAS_AGP if (!dev_priv->is_pci) -- cgit v1.2.3-59-g8ed1b From 281ab031a8c9e5b593142eb4ec59a87faae8676a Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 16 Dec 2005 16:52:22 +1100 Subject: [PATCH] radeon drm: fix agp aperture map offset This finally fixes the radeon memory mapping bug that was incorrectly fixed by the previous patch. This time, we use the actual vram size as the size to calculate how far to move the AGP aperture from the framebuffer in card's memory space. If there are still issues with this patch, they are due to bugs in the X driver that I'm working on fixing too. Signed-off-by: Benjamin Herrenschmidt Cc: Mark M. Hoffman Cc: Paul Mackerras Signed-off-by: Linus Torvalds --- drivers/char/drm/radeon_cp.c | 9 +++++++-- drivers/char/drm/radeon_drv.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 9f2b4efd0c7a..95ae9e0892ac 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -1312,6 +1312,8 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) { drm_radeon_private_t *dev_priv = dev->dev_private;; + unsigned int mem_size; + DRM_DEBUG("\n"); dev_priv->is_pci = init->is_pci; @@ -1521,8 +1523,11 @@ static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) + dev_priv->fb_location) >> 10)); dev_priv->gart_size = init->gart_size; - dev_priv->gart_vm_start = dev_priv->fb_location - + RADEON_READ(RADEON_CONFIG_APER_SIZE) * 2; + + mem_size = RADEON_READ(RADEON_CONFIG_MEMSIZE); + if (mem_size == 0) + mem_size = 0x800000; + dev_priv->gart_vm_start = dev_priv->fb_location + mem_size; #if __OS_HAS_AGP if (!dev_priv->is_pci) diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 7bda7e33d2bd..d92ccee3e54c 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h @@ -379,6 +379,7 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, # define RADEON_PLL_WR_EN (1 << 7) #define RADEON_CLOCK_CNTL_INDEX 0x0008 #define RADEON_CONFIG_APER_SIZE 0x0108 +#define RADEON_CONFIG_MEMSIZE 0x00f8 #define RADEON_CRTC_OFFSET 0x0224 #define RADEON_CRTC_OFFSET_CNTL 0x0228 # define RADEON_CRTC_TILE_EN (1 << 15) -- cgit v1.2.3-59-g8ed1b From ee219e5e7c12b742243a080e2d8d288a48a32e44 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 17 Dec 2005 23:20:55 +0100 Subject: [PATCH] radeon drm: fix compilation breakage with gcc 2.95.3 Fix a typo which breaks radeon drm compilation with gcc 2.95.3. The offending line was added back in 2.6.11-rc3, but was harmless back then. A recent addition nearby changed it into a compilation breaker: commit 281ab031a8c9e5b593142eb4ec59a87faae8676a. The doubled semi-colon ends up being an empty instruction, and the variable declaration thus ends up being in the middle of "code". Signed-off-by: Jean Delvare Cc: Benjamin Herrenschmidt Cc: Mark M. Hoffman Cc: Paul Mackerras Signed-off-by: Linus Torvalds --- drivers/char/drm/radeon_cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 95ae9e0892ac..501e557cbc86 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -1311,7 +1311,7 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) { - drm_radeon_private_t *dev_priv = dev->dev_private;; + drm_radeon_private_t *dev_priv = dev->dev_private; unsigned int mem_size; DRM_DEBUG("\n"); -- cgit v1.2.3-59-g8ed1b From 67dbb4ea33731415fe09c62149a34f472719ac1d Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 27 Dec 2005 12:49:33 +1100 Subject: [PATCH] Fix more radeon GART start calculation cases As reported by Jules Villard and some others, the recent GART aperture start reconfiguration causes problems on some setups. What I _think_ might be happening is that the X server is also trying to muck around with the card memory map and is forcing it back into a wrong setting that also happens to no longer match what the DRM wants to do and blows up. There are bugs all over the place in that code (and still some bugs in the DRM as well anyway). This patch attempts to avoid that by using the largest of the 2 values, which I think will cause it to behave as it used to for you and will still fix the problem with machines that have an aperture size smaller than the video memory. Acked-by: Jules Villard Signed-off-by: Linus Torvalds --- drivers/char/drm/radeon_cp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 501e557cbc86..b517ae515801 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -1312,7 +1312,7 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) { drm_radeon_private_t *dev_priv = dev->dev_private; - unsigned int mem_size; + unsigned int mem_size, aper_size; DRM_DEBUG("\n"); @@ -1527,7 +1527,9 @@ static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) mem_size = RADEON_READ(RADEON_CONFIG_MEMSIZE); if (mem_size == 0) mem_size = 0x800000; - dev_priv->gart_vm_start = dev_priv->fb_location + mem_size; + aper_size = max(RADEON_READ(RADEON_CONFIG_APER_SIZE), mem_size); + + dev_priv->gart_vm_start = dev_priv->fb_location + aper_size; #if __OS_HAS_AGP if (!dev_priv->is_pci) -- cgit v1.2.3-59-g8ed1b From 392c14beaca2ee85a98d0c6b453501be67423a20 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 29 Dec 2005 13:01:54 -0800 Subject: Revert radeon AGP aperture offset changes This reverts the series of commits 67dbb4ea33731415fe09c62149a34f472719ac1d 281ab031a8c9e5b593142eb4ec59a87faae8676a 47807ce381acc34a7ffee2b42e35e96c0f322e52 that changed the GART VM start offset. It fixed some machines, but seems to continually interact badly with some X versions. Quoth Ben Herrenschmidt: "So I think at this point, the best is that we keep the old bogus code that at least is consistent with the bug in the server. I'm working on a big patch to X that reworks the memory map stuff completely and fixes those issues on the server side, I'll do a DRM patch matching this X fix as well so that the memory map is only ever set in one place and with what I hope is a correct algorithm..." Signed-off-by: Linus Torvalds --- drivers/char/drm/radeon_cp.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/char/drm') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index b517ae515801..342302d46743 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -1312,8 +1312,6 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) { drm_radeon_private_t *dev_priv = dev->dev_private; - unsigned int mem_size, aper_size; - DRM_DEBUG("\n"); dev_priv->is_pci = init->is_pci; @@ -1523,13 +1521,8 @@ static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) + dev_priv->fb_location) >> 10)); dev_priv->gart_size = init->gart_size; - - mem_size = RADEON_READ(RADEON_CONFIG_MEMSIZE); - if (mem_size == 0) - mem_size = 0x800000; - aper_size = max(RADEON_READ(RADEON_CONFIG_APER_SIZE), mem_size); - - dev_priv->gart_vm_start = dev_priv->fb_location + aper_size; + dev_priv->gart_vm_start = dev_priv->fb_location + + RADEON_READ(RADEON_CONFIG_APER_SIZE); #if __OS_HAS_AGP if (!dev_priv->is_pci) -- cgit v1.2.3-59-g8ed1b