summaryrefslogtreecommitdiff
path: root/shared-core
AgeCommit message (Collapse)Author
2006-05-18add consts to radeon microcode.Dave Airlie
From: tilman
2006-04-23Fix from Benh for ppc r300 scratchDave Airlie
2006-04-20check for __FreeBSD_kernel__ (bug 3810)Brian Paul
2006-04-18Err, use "ifndef" rather than "if !", to avoid compiler warning.Eric Anholt
2006-04-18Use __LP64__ instead of checking the linux-specific BITS_PER_LONG.Eric Anholt
2006-04-09Revert a change that accidentally went in with whitespace changes fromEric Anholt
Linux, which broke on FreeBSD. DRM_COPY_*_IOCTL checks for the size parameter matching the ioctl's command size there, since the copin/out happened earlier.
2006-04-08Compile fixes for FreeBSD.Eric Anholt
2006-04-05coverity bugfix from the kernelDave Airlie
2006-03-25radeon fix up the PCI ids for new memory map like the kernel one.. notDave Airlie
perfect but should be very safe... align some other kernel bits i810 align with kernel
2006-03-20Bump driver date to reflect airlied's last fix.Adam Jackson
2006-03-19make some functions static in via driverDave Airlie
2006-03-17Add missing pci ids for new radeons (most but not all are pcie, r420,Roland Scheidegger
rv380, rv410), with the exception of the rs400 igps. Hopefully they no longer lock up with new ddx, but no guarantees... (bug #5413)
2006-03-08Fix bug I reintroducedDave Airlie
2006-03-08fix some use before NULL checkDave Airlie
2006-03-07ia64 support for r300_scratch. (not tested)Aapo Tahkola
2006-03-06Add general-purpose packet for manipulating scratch registers (r300)Aapo Tahkola
2006-02-25Add all radeon pci ids known by ddx, but only r350/rv350 and below (newRoland Scheidegger
chips may be problematic). Leave the existing entries for new chips in though. Remove ids not known by ddx (secondary ids, non-existant,...). Correct some entries (name/family). Make the radeon family enum look more alike the ddx/dri versions. See #5413
2006-02-19missed a piece of benh patchDave Airlie
2006-02-18fix brace placementDave Airlie
2006-02-18clear i915 interrupts sources on server exitDave Airlie
2006-02-18add proper checking for bitblt multiDave Airlie
2006-02-18add benh's memory management patchDave Airlie
2006-02-18major realigment of DRM CVS with kernel code, makes integration much easierDave Airlie
2006-02-17via: Change via_drm.h versioning scheme after lenghty discussion onThomas Hellstrom
unichrome-users.
2006-02-09Update the hardware breadcrumb in the sarea on irq reception so thatKeith Whitwell
clients can avoid an ioctl waiting on fences that have already been received. Would be even better if the hardware did the update itself.
2006-01-24fix an error message typo Unkown -> UnknownAlan Hourihane
2006-01-24other part of revertAlan Hourihane
2006-01-24put back some of Dave's code related to vblank support - accidentallyAlan Hourihane
reverted.
2006-01-23Fix CMDBUFFER path, add heap destroy and flesh out sarea for rotationAlan Hourihane
(Tungsten Graphics)
2006-01-20Add support for texture cache flushes (R300_TX_CNTL)Aapo Tahkola
2006-01-20Sync from r300_reg.h from Mesa.Aapo Tahkola
2006-01-19add Intel i945GM supportAlan Hourihane
2006-01-12via: direction bug in get_user_pages call in via_dmablit.c fixed. BumpedThomas Hellstrom
minor since this causes the via DDX to fail with vlc video player.
2006-01-06via: Version via_drm.h Alter the drm_via_dmablit_t IOCTL arg.Thomas Hellstrom
2006-01-06via: Last commit really required a bump of minor. Fix.Thomas Hellstrom
2006-01-06via: Combine PCI DMA transfers with stride==width (Idea from LucThomas Hellstrom
Verhaegen). A somewhat saner PCI DMA transfer size check. Fix some typos. Bump patchlevel.
2006-01-02make max minor more rationalDave Airlie
2006-01-02The radeon DRM wasn't passing sparse checking in the kernel, this fixes itDave Airlie
by adding a new kernel internal cmd buffer type, that has no userspace members, and passes it around.
2006-01-02whitespace cleanup/aligment with kernelDave Airlie
2006-01-02some fixes from linux kernelDave Airlie
2006-01-02complete fix for historic attributionDave Airlie
2006-01-02complete fix for attributionDave Airlie
2006-01-02Realign via driver with changes in Linux kernel (mainly whitespace)Dave Airlie
2005-12-29add radeon card type get param so userspace can avoid walking PCIDave Airlie
2005-12-28Add vblank support to i915 DRM..Dave Airlie
2005-12-28step back one reported bugs against that patchDave Airlie
2005-12-16fix radeon memory mapping from Ben HerrenschmidtDave Airlie
2005-12-16Lindent some via filesDave Airlie
2005-12-05add texrect support for r300Dave Airlie
2005-12-02Add RV410 X700PRO PCI IDEric Anholt
Submitted by: Adam K Kirchhoff <adamk@voicenet.com>
OUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include "drmP.h" #include "drm_sarea.h" #include <linux/poll.h> static int drm_open_helper(struct inode *inode, struct file *filp, struct drm_device * dev); static int drm_setup(struct drm_device * dev) { int i; int ret; if (dev->driver->firstopen) { ret = dev->driver->firstopen(dev); if (ret != 0) return ret; } atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) && !drm_core_check_feature(dev, DRIVER_MODESET)) { dev->buf_use = 0; atomic_set(&dev->buf_alloc, 0); i = drm_dma_setup(dev); if (i < 0) return i; } for (i = 0; i < ARRAY_SIZE(dev->counts); i++) atomic_set(&dev->counts[i], 0); dev->sigdata.lock = NULL; dev->queue_count = 0; dev->queue_reserved = 0; dev->queue_slots = 0; dev->queuelist = NULL; dev->context_flag = 0; dev->interrupt_flag = 0; dev->dma_flag = 0; dev->last_context = 0; dev->last_switch = 0; dev->last_checked = 0; init_waitqueue_head(&dev->context_wait); dev->if_version = 0; dev->ctx_start = 0; dev->lck_start = 0; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); DRM_DEBUG("\n"); /* * The kernel's context could be created here, but is now created * in drm_dma_enqueue. This is more resource-efficient for * hardware that does not do DMA, but may mean that * drm_select_queue fails between the time the interrupt is * initialized and the time the queues are initialized. */ return 0; } /** * Open file. * * \param inode device inode * \param filp file pointer. * \return zero on success or a negative number on failure. * * Searches the DRM device with the same minor number, calls open_helper(), and * increments the device open count. If the open count was previous at zero, * i.e., it's the first that the device is open, then calls setup(). */ int drm_open(struct inode *inode, struct file *filp) { struct drm_device *dev = NULL; int minor_id = iminor(inode); struct drm_minor *minor; int retcode = 0; minor = idr_find(&drm_minors_idr, minor_id); if (!minor) return -ENODEV; if (!(dev = minor->dev)) return -ENODEV; retcode = drm_open_helper(inode, filp, dev); if (!retcode) { atomic_inc(&dev->counts[_DRM_STAT_OPENS]); spin_lock(&dev->count_lock); if (!dev->open_count++) { spin_unlock(&dev->count_lock); retcode = drm_setup(dev); goto out; } spin_unlock(&dev->count_lock); } out: mutex_lock(&dev->struct_mutex); BUG_ON((dev->dev_mapping != NULL) && (dev->dev_mapping != inode->i_mapping)); if (dev->dev_mapping == NULL) dev->dev_mapping = inode->i_mapping; mutex_unlock(&dev->struct_mutex); return retcode; } EXPORT_SYMBOL(drm_open); /** * File \c open operation. * * \param inode device inode. * \param filp file pointer. * * Puts the dev->fops corresponding to the device minor number into * \p filp, call the \c open method, and restore the file operations. */ int drm_stub_open(struct inode *inode, struct file *filp) { struct drm_device *dev = NULL; struct drm_minor *minor; int minor_id = iminor(inode); int err = -ENODEV; const struct file_operations *old_fops; DRM_DEBUG("\n"); minor = idr_find(&drm_minors_idr, minor_id); if (!minor) return -ENODEV; if (!(dev = minor->dev)) return -ENODEV; old_fops = filp->f_op; filp->f_op = fops_get(&dev->driver->fops); if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) { fops_put(filp->f_op); filp->f_op = fops_get(old_fops); } fops_put(old_fops); return err; } /** * Check whether DRI will run on this CPU. * * \return non-zero if the DRI will run on this CPU, or zero otherwise. */ static int drm_cpu_valid(void) { #if defined(__i386__) if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ #endif #if defined(__sparc__) && !defined(__sparc_v9__) return 0; /* No cmpxchg before v9 sparc. */ #endif return 1; } /** * Called whenever a process opens /dev/drm. * * \param inode device inode. * \param filp file pointer. * \param dev device. * \return zero on success or a negative number on failure. * * Creates and initializes a drm_file structure for the file private data in \p * filp and add it into the double linked list in \p dev. */ static int drm_open_helper(struct inode *inode, struct file *filp, struct drm_device * dev) { int minor_id = iminor(inode); struct drm_file *priv; int ret; if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ if (!drm_cpu_valid()) return -EINVAL; DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor_id); priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); if (!priv) return -ENOMEM; memset(priv, 0, sizeof(*priv)); filp->private_data = priv; priv->filp = filp; priv->uid = current->euid; priv->pid = current->pid; priv->minor = idr_find(&drm_minors_idr, minor_id); priv->ioctl_count = 0; /* for compatibility root is always authenticated */ priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; INIT_LIST_HEAD(&priv->lhead); INIT_LIST_HEAD(&priv->fbs); if (dev->driver->driver_features & DRIVER_GEM) drm_gem_open(dev, priv); if (dev->driver->open) { ret = dev->driver->open(dev, priv); if (ret < 0) goto out_free; } /* if there is no current master make this fd it */ mutex_lock(&dev->struct_mutex); if (!priv->minor->master) { /* create a new master */ priv->minor->master = drm_master_create(priv->minor); if (!priv->minor->master) { ret = -ENOMEM; goto out_free; } priv->is_master = 1; /* take another reference for the copy in the local file priv */ priv->master = drm_master_get(priv->minor->master); priv->authenticated = 1; mutex_unlock(&dev->struct_mutex); if (dev->driver->master_create) { ret = dev->driver->master_create(dev, priv->master); if (ret) { mutex_lock(&dev->struct_mutex); /* drop both references if this fails */ drm_master_put(&priv->minor->master); drm_master_put(&priv->master); mutex_unlock(&dev->struct_mutex); goto out_free; } } } else { /* get a reference to the master */ priv->master = drm_master_get(priv->minor->master); mutex_unlock(&dev->struct_mutex); } mutex_lock(&dev->struct_mutex); list_add(&priv->lhead, &dev->filelist); mutex_unlock(&dev->struct_mutex); #ifdef __alpha__ /* * Default the hose */ if (!dev->hose) { struct pci_dev *pci_dev; pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL); if (pci_dev) { dev->hose = pci_dev->sysdata; pci_dev_put(pci_dev); } if (!dev->hose) { struct pci_bus *b = pci_bus_b(pci_root_buses.next); if (b) dev->hose = b->sysdata; } } #endif return 0; out_free: drm_free(priv, sizeof(*priv), DRM_MEM_FILES); filp->private_data = NULL; return ret; } /** No-op. */ int drm_fasync(int fd, struct file *filp, int on) { struct drm_file *priv = filp->private_data; struct drm_device *dev = priv->minor->dev; int retcode; DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, (long)old_encode_dev(priv->minor->device)); retcode = fasync_helper(fd, filp, on, &dev->buf_async); if (retcode < 0) return retcode; return 0; } EXPORT_SYMBOL(drm_fasync); /** * Release file. * * \param inode device inode * \param file_priv DRM file private. * \return zero on success or a negative number on failure. * * If the hardware lock is held then free it, and take it again for the kernel * context since it's necessary to reclaim buffers. Unlink the file private * data from its list and free it. Decreases the open count and if it reaches * zero calls drm_lastclose(). */ int drm_release(struct inode *inode, struct file *filp) { struct drm_file *file_priv = filp->private_data; struct drm_device *dev = file_priv->minor->dev; int retcode = 0; lock_kernel(); DRM_DEBUG("open_count = %d\n", dev->open_count); if (dev->driver->preclose) dev->driver->preclose(dev, file_priv); /* ======================================================== * Begin inline drm_release */ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", current->pid, (long)old_encode_dev(file_priv->minor->device), dev->open_count); /* if the master has gone away we can't do anything with the lock */ if (file_priv->minor->master) { if (dev->driver->reclaim_buffers_locked && file_priv->master->lock.hw_lock) { if (drm_i_have_hw_lock(dev, file_priv)) { dev->driver->reclaim_buffers_locked(dev, file_priv); } else { unsigned long _end=jiffies + 3*DRM_HZ; int locked = 0; drm_idlelock_take(&file_priv->master->lock); /* * Wait for a while. */ do{ spin_lock_bh(&file_priv->master->lock.spinlock); locked = file_priv->master->lock.idle_has_lock; spin_unlock_bh(&file_priv->master->lock.spinlock); if (locked) break; schedule(); } while (!time_after_eq(jiffies, _end)); if (!locked) { DRM_ERROR("reclaim_buffers_locked() deadlock. Please rework this\n" "\tdriver to use reclaim_buffers_idlelocked() instead.\n" "\tI will go on reclaiming the buffers anyway.\n"); } dev->driver->reclaim_buffers_locked(dev, file_priv); drm_idlelock_release(&file_priv->master->lock); } } if (dev->driver->reclaim_buffers_idlelocked && file_priv->master->lock.hw_lock) { drm_idlelock_take(&file_priv->master->lock); dev->driver->reclaim_buffers_idlelocked(dev, file_priv); drm_idlelock_release(&file_priv->master->lock); } if (drm_i_have_hw_lock(dev, file_priv)) { DRM_DEBUG("File %p released, freeing lock for context %d\n", filp, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); drm_lock_free(&file_priv->master->lock, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); } if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) && !dev->driver->reclaim_buffers_locked) { dev->driver->reclaim_buffers(dev, file_priv); } } if (dev->driver->driver_features & DRIVER_GEM) drm_gem_release(dev, file_priv); drm_fasync(-1, filp, 0); mutex_lock(&dev->ctxlist_mutex); if (!list_empty(&dev->ctxlist)) { struct drm_ctx_list *pos, *n; list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { if (pos->tag == file_priv && pos->handle != DRM_KERNEL_CONTEXT) { if (dev->driver->context_dtor) dev->driver->context_dtor(dev, pos->handle); drm_ctxbitmap_free(dev, pos->handle); list_del(&pos->head); drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); --dev->ctx_count; } } } mutex_unlock(&dev->ctxlist_mutex); if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_fb_release(filp); mutex_lock(&dev->struct_mutex); if (file_priv->is_master) { struct drm_file *temp; list_for_each_entry(temp, &dev->filelist, lhead) { if ((temp->master == file_priv->master) && (temp != file_priv)) temp->authenticated = 0; } if (file_priv->minor->master == file_priv->master) { /* drop the reference held my the minor */ drm_master_put(&file_priv->minor->master); } } /* drop the reference held my the file priv */ drm_master_put(&file_priv->master); file_priv->is_master = 0; list_del(&file_priv->lhead); mutex_unlock(&dev->struct_mutex); if (dev->driver->postclose) dev->driver->postclose(dev, file_priv); drm_free(file_priv, sizeof(*file_priv), DRM_MEM_FILES); /* ======================================================== * End inline drm_release */ atomic_inc(&dev->counts[_DRM_STAT_CLOSES]); spin_lock(&dev->count_lock); if (!--dev->open_count) { if (atomic_read(&dev->ioctl_count)) { DRM_ERROR("Device busy: %d\n", atomic_read(&dev->ioctl_count)); spin_unlock(&dev->count_lock); unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); unlock_kernel(); return drm_lastclose(dev); } spin_unlock(&dev->count_lock); unlock_kernel(); return retcode; } EXPORT_SYMBOL(drm_release); /** No-op. */ /* This is to deal with older X servers that believe 0 means data is * available which is not the correct return for a poll function. * This cannot be fixed until the Xserver is fixed. Xserver will need * to set a newer interface version to avoid breaking older Xservers. * Without fixing the Xserver you get: "WaitForSomething(): select: errno=22" * http://freedesktop.org/bugzilla/show_bug.cgi?id=1505 if you try * to return the correct response. */ unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait) { /* return (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM); */ return 0; } EXPORT_SYMBOL(drm_poll);