summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hartmann <jhartmann@valinux.com>2000-09-12 20:22:28 +0000
committerJeff Hartmann <jhartmann@valinux.com>2000-09-12 20:22:28 +0000
commit9348a4f62b2bb5705ec9c49b79f240e0153080fa (patch)
tree9381c0701c614a982d5bb0496976a061684fbf9b
parent8c86b0b02c0cac99867371a52396843f1e5b854a (diff)
More debug code for Rik to take a look atmga-lock-debug-0-0-1-branch
-rw-r--r--linux-core/drmP.h12
-rw-r--r--linux-core/mga_drv.c10
-rw-r--r--linux/drmP.h12
-rw-r--r--linux/drm_heavy_kern_lock.c36
-rw-r--r--linux/mga_dma.c41
-rw-r--r--linux/mga_drv.c10
-rw-r--r--linux/mga_state.c48
7 files changed, 82 insertions, 87 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 50be9e60..c5e60313 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -855,13 +855,16 @@ static __inline__ drm_file_t *drm_find_filp_by_current_pid(drm_device_t *dev)
static __inline__ void drm_release_big_fscking_lock(drm_device_t *dev, drm_file_t *filp)
{
- if(filp->lock_depth >= 0)
+#if 1
+ if(filp->lock_depth >= 0)
spin_unlock_irqrestore(&dev->big_fscking_lock,
filp->irq_flags);
+#endif
}
static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_file_t *filp)
{
+#if 1
unsigned long flags;
if(filp->lock_depth >= 0) {
@@ -869,9 +872,11 @@ static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_fil
spin_lock_irqsave(&dev->big_fscking_lock, flags);
filp->irq_flags = flags;
}
+#endif
}
/* Enable interrupts around copy/to/from/user */
+#if 0
#define drm_copy_to_user_ret(to,from,n,retval) do {\
drm_file_t *filp = drm_find_filp_by_current_pid(dev);\
if(filp == NULL) {\
@@ -899,7 +904,10 @@ static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_fil
}\
drm_reacquire_big_fscking_lock(dev, filp);\
}while(0)
-
+#else
+#define drm_copy_to_user_ret(to,from,n,retval) copy_to_user_ret(to,from,n,retval)
+#define drm_copy_from_user_ret(to,from,n,retval) copy_from_user_ret(to,from,n,retval)
+#endif
#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* AGP/GART support (agpsupport.c) */
diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c
index 75c3af78..21a90004 100644
--- a/linux-core/mga_drv.c
+++ b/linux-core/mga_drv.c
@@ -624,11 +624,17 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|| (ioctl->auth_needed && !priv->authenticated)) {
retcode = -EACCES;
} else {
- if(ioctl->needs_hvy_lock == 1)
+ if(ioctl->needs_hvy_lock == 1) {
+ if(priv->lock_depth != -1)
+ DRM_ERROR("Lock depth is bogus before an ioctl lock\n");
drm_big_fscking_lock_filp(dev, priv);
+ }
retcode = (func)(inode, filp, cmd, arg);
- if(ioctl->needs_hvy_lock == 1)
+ if(ioctl->needs_hvy_lock == 1) {
+ if(priv->lock_depth != 0)
+ DRM_ERROR("Lock depth is bogus before an ioctl unlock\n");
drm_big_fscking_unlock_filp(dev, priv);
+ }
}
}
diff --git a/linux/drmP.h b/linux/drmP.h
index 50be9e60..c5e60313 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -855,13 +855,16 @@ static __inline__ drm_file_t *drm_find_filp_by_current_pid(drm_device_t *dev)
static __inline__ void drm_release_big_fscking_lock(drm_device_t *dev, drm_file_t *filp)
{
- if(filp->lock_depth >= 0)
+#if 1
+ if(filp->lock_depth >= 0)
spin_unlock_irqrestore(&dev->big_fscking_lock,
filp->irq_flags);
+#endif
}
static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_file_t *filp)
{
+#if 1
unsigned long flags;
if(filp->lock_depth >= 0) {
@@ -869,9 +872,11 @@ static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_fil
spin_lock_irqsave(&dev->big_fscking_lock, flags);
filp->irq_flags = flags;
}
+#endif
}
/* Enable interrupts around copy/to/from/user */
+#if 0
#define drm_copy_to_user_ret(to,from,n,retval) do {\
drm_file_t *filp = drm_find_filp_by_current_pid(dev);\
if(filp == NULL) {\
@@ -899,7 +904,10 @@ static __inline__ void drm_reacquire_big_fscking_lock(drm_device_t *dev, drm_fil
}\
drm_reacquire_big_fscking_lock(dev, filp);\
}while(0)
-
+#else
+#define drm_copy_to_user_ret(to,from,n,retval) copy_to_user_ret(to,from,n,retval)
+#define drm_copy_from_user_ret(to,from,n,retval) copy_from_user_ret(to,from,n,retval)
+#endif
#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* AGP/GART support (agpsupport.c) */
diff --git a/linux/drm_heavy_kern_lock.c b/linux/drm_heavy_kern_lock.c
index 5368c663..4736d298 100644
--- a/linux/drm_heavy_kern_lock.c
+++ b/linux/drm_heavy_kern_lock.c
@@ -10,8 +10,8 @@
/* This can NEVER be called from an interrupt */
void drm_schedule(drm_device_t *dev)
{
+#if 1
drm_file_t *filp;
-
if(in_interrupt()) {
sti();
BUG();
@@ -25,13 +25,14 @@ void drm_schedule(drm_device_t *dev)
drm_release_big_fscking_lock(dev, filp);
schedule();
drm_reacquire_big_fscking_lock(dev, filp);
+#else
+ schedule();
+#endif
}
-
-
-
void drm_schedule_timeout(drm_device_t *dev, unsigned long timeout)
{
+#if 1
drm_file_t *filp;
if(in_interrupt()) {
@@ -43,6 +44,9 @@ void drm_schedule_timeout(drm_device_t *dev, unsigned long timeout)
drm_release_big_fscking_lock(dev, filp);
schedule_timeout(timeout);
drm_reacquire_big_fscking_lock(dev, filp);
+#else
+ schedule_timeout(timeout);
+#endif
}
void drm_big_fscking_lock(drm_device_t *dev)
@@ -53,25 +57,31 @@ void drm_big_fscking_lock(drm_device_t *dev)
if(in_irq()) {
barrier();
if(!++dev->irq_lock_depth) {
+#if 1
spin_lock_irqsave(&dev->big_fscking_lock,
flags);
dev->irq_flags = flags;
+#endif
}
} else if (in_softirq()) {
barrier();
if(!++dev->bh_lock_depth) {
+#if 1
spin_lock_irqsave(&dev->big_fscking_lock,
flags);
dev->bh_flags = flags;
+#endif
}
} else {
filp = drm_find_filp_by_current_pid(dev);
if(filp == NULL) BUG();
barrier();
if(!++filp->lock_depth) {
+#if 1
spin_lock_irqsave(&dev->big_fscking_lock,
flags);
dev->irq_flags = flags;
+#endif
}
}
}
@@ -83,20 +93,32 @@ void drm_big_fscking_unlock(drm_device_t *dev)
if(in_irq()) {
barrier();
if(--dev->irq_lock_depth < 0)
+#if 1
spin_unlock_irqrestore(&dev->big_fscking_lock,
dev->irq_flags);
+#else
+ ;
+#endif
} else if (in_softirq()) {
barrier();
if(--dev->bh_lock_depth < 0)
+#if 1
spin_unlock_irqrestore(&dev->big_fscking_lock,
dev->bh_flags);
+#else
+ ;
+#endif
} else {
filp = drm_find_filp_by_current_pid(dev);
if(filp == NULL) BUG();
barrier();
if(--filp->lock_depth < 0)
+#if 1
spin_unlock_irqrestore(&dev->big_fscking_lock,
filp->irq_flags);
+#else
+ ;
+#endif
}
}
@@ -106,9 +128,11 @@ void __inline drm_big_fscking_lock_filp(drm_device_t *dev, drm_file_t *filp)
barrier();
if(!++filp->lock_depth) {
+#if 1
spin_lock_irqsave(&dev->big_fscking_lock,
flags);
dev->irq_flags = flags;
+#endif
}
}
@@ -116,6 +140,10 @@ void __inline drm_big_fscking_unlock_filp(drm_device_t *dev, drm_file_t *filp)
{
barrier();
if(--filp->lock_depth < 0)
+#if 1
spin_unlock_irqrestore(&dev->big_fscking_lock,
filp->irq_flags);
+#else
+ ;
+#endif
}
diff --git a/linux/mga_dma.c b/linux/mga_dma.c
index 863ac5a3..f221022c 100644
--- a/linux/mga_dma.c
+++ b/linux/mga_dma.c
@@ -152,9 +152,18 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned long end;
int i;
+ drm_file_t *filp = drm_find_filp_by_current_pid(dev);
+
+ if(filp == NULL) {
+ sti();
+ BUG();
+ }
+ drm_release_big_fscking_lock(dev, filp);
+
DRM_DEBUG("%s\n", __FUNCTION__);
end = jiffies + (HZ*3);
+#if 0
while(1) {
if(!test_and_set_bit(MGA_IN_DISPATCH,
&dev_priv->dispatch_status)) {
@@ -169,9 +178,9 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
}
for (i = 0 ; i < 2000 ; i++) mga_delay();
}
+#endif
end = jiffies + (HZ*3);
- DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS));
- while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
+ while((MGA_READ(MGAREG_STATUS) & 0x00030000) != 0x00020000) {
if((signed)(end - jiffies) <= 0) {
DRM_ERROR("irqs: %d wanted %d\n",
atomic_read(&dev->total_irq),
@@ -185,6 +194,7 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
out_status:
clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
out_nolock:
+ drm_reacquire_big_fscking_lock(dev, filp);
}
static void mga_reset_freelist(drm_device_t *dev)
@@ -194,6 +204,8 @@ static void mga_reset_freelist(drm_device_t *dev)
drm_mga_buf_priv_t *buf_priv;
int i;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
for (i = 0; i < dma->buf_count; i++) {
buf = dma->buflist[ i ];
buf_priv = buf->dev_private;
@@ -215,12 +227,7 @@ drm_buf_t *mga_freelist_get(drm_device_t *dev)
drm_mga_freelist_t *next;
static int failed = 0;
- DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__,
- dev_priv->tail->age, dev_priv->last_prim_age);
-
if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) {
- DRM_DEBUG("I'm waiting on the freelist!!! %d\n",
- dev_priv->last_prim_age);
add_wait_queue(&dev_priv->buf_queue, &entry);
set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
for (;;) {
@@ -388,7 +395,6 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
end = jiffies + (HZ*3);
if(sarea_priv->dirty & MGA_DMA_FLUSH) {
- DRM_DEBUG("Dma top flush\n");
while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
if((signed)(end - jiffies) <= 0) {
DRM_ERROR("irqs: %d wanted %d\n",
@@ -403,7 +409,6 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
}
sarea_priv->dirty &= ~(MGA_DMA_FLUSH);
} else {
- DRM_DEBUG("Status wait\n");
while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) {
if((signed)(end - jiffies) <= 0) {
DRM_ERROR("irqs: %d wanted %d\n",
@@ -596,16 +601,13 @@ int mga_dma_schedule(drm_device_t *dev, int locked)
!drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
atomic_inc(&dma->total_missed_lock);
clear_bit(0, &dev->dma_flag);
- DRM_DEBUG("Not locked\n");
retval = -EBUSY;
goto sch_out_wakeup;
}
- DRM_DEBUG("I'm locked\n");
if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) {
/* Fire dma buffer */
if(mga_decide_to_fire(dev)) {
- DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx);
clear_bit(MGA_BUF_FORCE_FIRE,
&dev_priv->next_prim->buffer_status);
if(dev_priv->current_prim == dev_priv->next_prim) {
@@ -617,8 +619,6 @@ int mga_dma_schedule(drm_device_t *dev, int locked)
} else {
clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
}
- } else {
- DRM_DEBUG("I can't get the dispatch lock\n");
}
if (!locked) {
@@ -640,14 +640,8 @@ sch_out_wakeup:
if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
dev_priv->tail->age < dev_priv->last_prim_age) {
clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
- DRM_DEBUG("Waking up buf queue\n");
wake_up_interruptible(&dev_priv->buf_queue);
- } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
- DRM_DEBUG("Not waking buf_queue on %d %d\n",
- atomic_read(&dev->total_irq),
- dev_priv->last_prim_age);
}
-
drm_big_fscking_unlock(dev);
return retval;
}
@@ -680,7 +674,6 @@ static void mga_dma_service(int irq, void *device, struct pt_regs *regs)
static void mga_dma_task_queue(void *device)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
mga_dma_schedule((drm_device_t *)device, 0);
}
@@ -1056,10 +1049,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
return -EINVAL;
}
- DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock.context, current->pid, dev->lock.hw_lock->lock,
- lock.flags);
-
if (lock.context < 0) {
return -EINVAL;
}
@@ -1107,13 +1096,11 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
if (lock.flags & _DRM_LOCK_QUIESCENT) {
- DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
mga_flush_queue(dev);
mga_dma_quiescent(dev);
}
}
- DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
return ret;
}
diff --git a/linux/mga_drv.c b/linux/mga_drv.c
index 75c3af78..21a90004 100644
--- a/linux/mga_drv.c
+++ b/linux/mga_drv.c
@@ -624,11 +624,17 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|| (ioctl->auth_needed && !priv->authenticated)) {
retcode = -EACCES;
} else {
- if(ioctl->needs_hvy_lock == 1)
+ if(ioctl->needs_hvy_lock == 1) {
+ if(priv->lock_depth != -1)
+ DRM_ERROR("Lock depth is bogus before an ioctl lock\n");
drm_big_fscking_lock_filp(dev, priv);
+ }
retcode = (func)(inode, filp, cmd, arg);
- if(ioctl->needs_hvy_lock == 1)
+ if(ioctl->needs_hvy_lock == 1) {
+ if(priv->lock_depth != 0)
+ DRM_ERROR("Lock depth is bogus before an ioctl unlock\n");
drm_big_fscking_unlock_filp(dev, priv);
+ }
}
}
diff --git a/linux/mga_state.c b/linux/mga_state.c
index bc303a7d..bcf9f22d 100644
--- a/linux/mga_state.c
+++ b/linux/mga_state.c
@@ -554,7 +554,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
PRIMOUTREG(MGAREG_DSTORG, destOrg);
PRIMOUTREG(MGAREG_MACCESS, 0x00000000);
- DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp);
PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp);
PRIMOUTREG(MGAREG_AR5, 64);
@@ -587,13 +586,6 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__);
- DRM_DEBUG("dispatch vertex %d addr 0x%lx, "
- "length 0x%x nbox %d dirty %x\n",
- buf->idx, address, length,
- sarea_priv->nbox, sarea_priv->dirty);
-
- DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total);
-
if (buf->used) {
/* WARNING: if you change any of the state functions verify
* these numbers (Overestimating this doesn't hurt).
@@ -607,14 +599,6 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
do {
if (i < sarea_priv->nbox) {
- DRM_DEBUG("idx %d Emit box %d/%d:"
- "%d,%d - %d,%d\n",
- buf->idx,
- i, sarea_priv->nbox,
- sarea_priv->boxes[i].x1,
- sarea_priv->boxes[i].y1,
- sarea_priv->boxes[i].x2,
- sarea_priv->boxes[i].y2);
mgaEmitClipRect(dev_priv,
&sarea_priv->boxes[i]);
@@ -654,10 +638,6 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__);
- DRM_DEBUG("dispatch indices %d addr 0x%x, "
- "start 0x%x end 0x%x nbox %d dirty %x\n",
- buf->idx, address, start, end,
- sarea_priv->nbox, sarea_priv->dirty);
if (start != end) {
/* WARNING: if you change any of the state functions verify
@@ -670,14 +650,6 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
do {
if (i < sarea_priv->nbox) {
- DRM_DEBUG("idx %d Emit box %d/%d:"
- "%d,%d - %d,%d\n",
- buf->idx,
- i, sarea_priv->nbox,
- sarea_priv->boxes[i].x1,
- sarea_priv->boxes[i].y1,
- sarea_priv->boxes[i].x2,
- sarea_priv->boxes[i].y2);
mgaEmitClipRect(dev_priv,
&sarea_priv->boxes[i]);
@@ -730,12 +702,8 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
for (i = 0; i < nbox; i++) {
unsigned int height = pbox[i].y2 - pbox[i].y1;
- DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n",
- pbox[i].x1, pbox[i].y1, pbox[i].x2,
- pbox[i].y2, flags);
if (flags & MGA_FRONT) {
- DRM_DEBUG("clear front\n");
PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_PLNWT, clear_colormask);
PRIMOUTREG(MGAREG_YDSTLEN,
@@ -750,7 +718,6 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
}
if (flags & MGA_BACK) {
- DRM_DEBUG("clear back\n");
PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_PLNWT, clear_colormask);
PRIMOUTREG(MGAREG_YDSTLEN,
@@ -765,7 +732,6 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
}
if (flags & MGA_DEPTH) {
- DRM_DEBUG("clear depth\n");
PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_PLNWT, clear_depthmask);
PRIMOUTREG(MGAREG_YDSTLEN,
@@ -822,8 +788,6 @@ static void mga_dma_dispatch_swap(drm_device_t * dev)
unsigned int h = pbox[i].y2 - pbox[i].y1;
unsigned int start = pbox[i].y1 * pixel_stride;
- DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
- pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2);
PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1);
PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1);
@@ -928,7 +892,6 @@ int mga_iload(struct inode *inode, struct file *filp,
unsigned long bus_address;
DRM_DEBUG("%s\n", __FUNCTION__);
- DRM_DEBUG("Starting Iload\n");
drm_copy_from_user_ret(&iload,
(drm_mga_clear_t *)arg, sizeof(iload), -EFAULT);
@@ -940,8 +903,6 @@ int mga_iload(struct inode *inode, struct file *filp,
buf = dma->buflist[iload.idx];
buf_priv = buf->dev_private;
bus_address = buf->bus_address;
- DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n",
- bus_address, iload.length, iload.destOrg);
if (mgaVerifyIload(dev_priv,
bus_address, iload.destOrg, iload.length)) {
@@ -985,8 +946,6 @@ int mga_vertex(struct inode *inode, struct file *filp,
return -EINVAL;
}
- DRM_DEBUG("mga_vertex\n");
-
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
@@ -1037,8 +996,6 @@ int mga_indices(struct inode *inode, struct file *filp,
return -EINVAL;
}
- DRM_DEBUG("mga_indices\n");
-
buf = dma->buflist[indices.idx];
buf_priv = buf->dev_private;
@@ -1101,9 +1058,6 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd,
(drm_dma_t *)arg, sizeof(d),
-EFAULT);
- DRM_DEBUG("%d %d: %d send, %d req\n",
- current->pid, d.context, d.send_count, d.request_count);
-
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_dma called without lock held\n");
return -EINVAL;
@@ -1133,8 +1087,6 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd,
retcode = mga_dma_get_buffers(dev, &d);
}
- DRM_DEBUG("%d returning, granted = %d\n",
- current->pid, d.granted_count);
drm_copy_to_user_ret((drm_dma_t *) arg,
&d, sizeof(d),
-EFAULT);