From: Jon Smirl <jonsmirl@gmail.com>
To: Keith Whitwell <keith@tungstengraphics.com>
Cc: Christoph Hellwig <hch@infradead.org>,
dri-devel <dri-devel@lists.sourceforge.net>,
Xserver development <xorg@freedesktop.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: New DRM driver model - gets rid of DRM() macros!
Date: Thu, 30 Sep 2004 14:10:48 -0400 [thread overview]
Message-ID: <9e473391040930111029879e62@mail.gmail.com> (raw)
In-Reply-To: <415ABA34.9080608@tungstengraphics.com>
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
Patch removes DRM flush, poll, read functions. It leave the fops entry
null so that the OS default function will be used.
The fops table is converted to be one per driver instead of a global.
This fixes the module open ref count problem. It also simplifies
i810/830 by allow them to directly patch their mmap function into the
fops table.
I spent two days looking for a bug in DRM with multiple drivers under
X. I don't think DRM has problems. I see now that X also fails if two
older DRM drivers are loaded. The first problem seems to be the X's
DRM lock refcount varibale is a static. That won't work for two DRM
drivers.
--
Jon Smirl
jonsmirl@gmail.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: open.patch --]
[-- Type: text/x-patch; name="open.patch", Size: 14070 bytes --]
===== linux-core/drmP.h 1.2 vs edited =====
--- 1.2/linux-core/drmP.h 2004-09-28 18:26:13 -04:00
+++ edited/linux-core/drmP.h 2004-09-30 13:34:40 -04:00
@@ -523,11 +523,6 @@
struct drm_device;
struct drm_driver_fn {
- u32 driver_features;
- int dev_priv_size;
- int permanent_maps;
- drm_ioctl_desc_t *ioctls;
- int num_ioctls;
int (*preinit)(struct drm_device *, unsigned long flags);
void (*prerelease)(struct drm_device *, struct file *filp);
void (*pretakedown)(struct drm_device *);
@@ -558,6 +553,13 @@
unsigned long (*get_reg_ofs)(struct drm_device *dev);
void (*set_version)(struct drm_device *dev, drm_set_version_t *sv);
int (*version)(drm_version_t *version);
+/* variables */
+ u32 driver_features;
+ int dev_priv_size;
+ int permanent_maps;
+ drm_ioctl_desc_t *ioctls;
+ int num_ioctls;
+ struct file_operations fops;
};
@@ -691,8 +693,6 @@
drm_sigdata_t sigdata; /**< For block_all_signals */
sigset_t sigmask;
- struct file_operations *fops; /**< file operations */
-
struct drm_driver_fn *fn_tbl;
drm_local_map_t *agp_buffer_map;
} drm_device_t;
@@ -757,13 +757,11 @@
extern int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev,
const struct pci_device_id *ent, struct drm_driver_fn *driver_fn);
extern int drm_fb_loaded;
-extern struct file_operations drm_fops;
/* Device support (drm_fops.h) */
extern int drm_open_helper(struct inode *inode, struct file *filp,
drm_device_t *dev);
-extern int drm_flush(struct file *filp);
-extern int drm_fasync(int fd, struct file *filp, int on);
+extern int drm_fasync(int fd, struct file *filp, int on);
/* Mapping support (drm_vm.h) */
extern void drm_vm_open(struct vm_area_struct *vma);
@@ -772,8 +770,6 @@
extern int drm_mmap_dma(struct file *filp,
struct vm_area_struct *vma);
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
-extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
-extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off);
/* Memory management support (drm_memory.h) */
#include "drm_memory.h"
===== linux-core/drm_drv.c 1.2 vs edited =====
--- 1.2/linux-core/drm_drv.c 2004-09-28 18:26:13 -04:00
+++ edited/linux-core/drm_drv.c 2004-09-30 13:34:40 -04:00
@@ -76,18 +76,6 @@
int drm_fb_loaded = 0;
-struct file_operations drm_fops = {
- .owner = THIS_MODULE,
- .open = drm_open,
- .flush = drm_flush,
- .release = drm_release,
- .ioctl = drm_ioctl,
- .mmap = drm_mmap,
- .fasync = drm_fasync,
- .poll = drm_poll,
- .read = drm_read,
-};
-
/** Ioctl table */
drm_ioctl_desc_t drm_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 },
@@ -384,7 +372,6 @@
sema_init( &dev->ctxlist_sem, 1 );
dev->name = DRIVER_NAME;
- dev->fops = &drm_fops;
dev->pdev = pdev;
#ifdef __alpha__
@@ -630,7 +617,7 @@
minor = &drm_minors[i];
dev = minor->dev;
DRM_DEBUG("fb loaded release minor %d\n", dev->minor);
- if ((minor->class == DRM_MINOR_PRIMARY) && (dev->fops == &drm_fops)) {
+ if (minor->class == DRM_MINOR_PRIMARY) {
/* release the pci driver */
if (dev->pdev)
pci_dev_put(dev->pdev);
===== linux-core/drm_fops.c 1.1 vs edited =====
--- 1.1/linux-core/drm_fops.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/drm_fops.c 2004-09-30 13:56:18 -04:00
@@ -116,18 +116,6 @@
}
/** No-op. */
-int drm_flush(struct file *filp)
-{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
-
- DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
- current->pid, (long)old_encode_dev(dev->device), dev->open_count);
- return 0;
-}
-EXPORT_SYMBOL(drm_flush);
-
-/** No-op. */
int drm_fasync(int fd, struct file *filp, int on)
{
drm_file_t *priv = filp->private_data;
@@ -140,16 +128,3 @@
return 0;
}
EXPORT_SYMBOL(drm_fasync);
-
-/** No-op. */
-unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
-{
- return 0;
-}
-
-
-/** No-op. */
-ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off)
-{
- return 0;
-}
===== linux-core/drm_stub.c 1.1 vs edited =====
--- 1.1/linux-core/drm_stub.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/drm_stub.c 2004-09-30 13:13:25 -04:00
@@ -77,7 +77,7 @@
return -ENODEV;
old_fops = filp->f_op;
- filp->f_op = fops_get(dev->fops);
+ filp->f_op = fops_get(&dev->fn_tbl->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);
===== linux-core/drm_vm.c 1.1 vs edited =====
--- 1.1/linux-core/drm_vm.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/drm_vm.c 2004-09-30 13:17:13 -04:00
@@ -670,3 +670,4 @@
drm_vm_open(vma);
return 0;
}
+EXPORT_SYMBOL(drm_mmap);
===== linux-core/ffb_drv.c 1.1 vs edited =====
--- 1.1/linux-core/ffb_drv.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/ffb_drv.c 2004-09-30 13:34:41 -04:00
@@ -321,6 +321,14 @@
.reclaim_buffers = drm_core_reclaim_buffers,
.postinit = postinit,
.version = version,
+ fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/i810_dma.c 1.1 vs edited =====
--- 1.1/linux-core/i810_dma.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/i810_dma.c 2004-09-30 13:19:46 -04:00
@@ -109,15 +109,6 @@
return 0;
}
-static struct file_operations i810_buffer_fops = {
- .open = drm_open,
- .flush = drm_flush,
- .release = drm_release,
- .ioctl = drm_ioctl,
- .mmap = i810_mmap_buffers,
- .fasync = drm_fasync,
-};
-
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
@@ -151,22 +142,19 @@
drm_device_t *dev = priv->dev;
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
drm_i810_private_t *dev_priv = dev->dev_private;
- struct file_operations *old_fops;
int retcode = 0;
if (buf_priv->currently_mapped == I810_BUF_MAPPED)
return -EINVAL;
down_write( ¤t->mm->mmap_sem );
- old_fops = filp->f_op;
- filp->f_op = &i810_buffer_fops;
dev_priv->mmap_buffer = buf;
buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
PROT_READ|PROT_WRITE,
MAP_SHARED,
buf->bus_address);
dev_priv->mmap_buffer = NULL;
- filp->f_op = old_fops;
+
if ((unsigned long)buf_priv->virtual > -1024UL) {
/* Real error */
DRM_ERROR("mmap error\n");
===== linux-core/i810_drv.c 1.1 vs edited =====
--- 1.1/linux-core/i810_drv.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/i810_drv.c 2004-09-30 13:34:40 -04:00
@@ -107,6 +107,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = i810_mmap_buffers,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/i830_dma.c 1.1 vs edited =====
--- 1.1/linux-core/i830_dma.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/i830_dma.c 2004-09-30 13:20:41 -04:00
@@ -110,15 +110,6 @@
return 0;
}
-static struct file_operations i830_buffer_fops = {
- .open = drm_open,
- .flush = drm_flush,
- .release = drm_release,
- .ioctl = drm_ioctl,
- .mmap = i830_mmap_buffers,
- .fasync = drm_fasync,
-};
-
int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
@@ -152,20 +143,17 @@
drm_device_t *dev = priv->dev;
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
drm_i830_private_t *dev_priv = dev->dev_private;
- struct file_operations *old_fops;
unsigned long virtual;
int retcode = 0;
if(buf_priv->currently_mapped == I830_BUF_MAPPED) return -EINVAL;
down_write( ¤t->mm->mmap_sem );
- old_fops = filp->f_op;
- filp->f_op = &i830_buffer_fops;
dev_priv->mmap_buffer = buf;
virtual = do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE,
MAP_SHARED, buf->bus_address);
dev_priv->mmap_buffer = NULL;
- filp->f_op = old_fops;
+
if (IS_ERR((void *)virtual)) { /* ugh */
/* Real error */
DRM_ERROR("mmap error\n");
===== linux-core/i830_drv.c 1.1 vs edited =====
--- 1.1/linux-core/i830_drv.c 2004-09-28 13:03:33 -04:00
+++ edited/linux-core/i830_drv.c 2004-09-30 13:34:40 -04:00
@@ -116,6 +116,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = i830_mmap_buffers,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/i915_drv.c 1.1 vs edited =====
--- 1.1/linux-core/i915_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/i915_drv.c 2004-09-30 13:34:40 -04:00
@@ -83,6 +83,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/mach64_drv.c 1.1 vs edited =====
--- 1.1/linux-core/mach64_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/mach64_drv.c 2004-09-30 13:34:40 -04:00
@@ -99,6 +99,14 @@
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = mach64_dma_buffers,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/mga_drv.c 1.1 vs edited =====
--- 1.1/linux-core/mga_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/mga_drv.c 2004-09-30 13:34:40 -04:00
@@ -103,6 +103,14 @@
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = mga_dma_buffers,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/r128_drv.c 1.1 vs edited =====
--- 1.1/linux-core/r128_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/r128_drv.c 2004-09-30 13:34:40 -04:00
@@ -113,6 +113,14 @@
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = r128_cce_buffers,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/radeon_drv.c 1.1 vs edited =====
--- 1.1/linux-core/radeon_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/radeon_drv.c 2004-09-30 13:34:40 -04:00
@@ -154,6 +154,14 @@
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = radeon_cp_buffers,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/savage_drv.c 1.1 vs edited =====
--- 1.1/linux-core/savage_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/savage_drv.c 2004-09-30 13:34:41 -04:00
@@ -292,6 +292,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/sis_drv.c 1.1 vs edited =====
--- 1.1/linux-core/sis_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/sis_drv.c 2004-09-30 13:34:41 -04:00
@@ -83,6 +83,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== linux-core/tdfx_drv.c 1.1 vs edited =====
--- 1.1/linux-core/tdfx_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/linux-core/tdfx_drv.c 2004-09-30 13:34:41 -04:00
@@ -74,6 +74,14 @@
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
===== shared-core/via_drv.c 1.1 vs edited =====
--- 1.1/shared-core/via_drv.c 2004-09-28 13:03:34 -04:00
+++ edited/shared-core/via_drv.c 2004-09-30 13:34:41 -04:00
@@ -99,6 +99,14 @@
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .fasync = drm_fasync,
+ },
};
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
next prev parent reply other threads:[~2004-09-30 18:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-28 15:54 New DRM driver model - gets rid of DRM() macros! Jon Smirl
2004-09-28 16:56 ` Ian Romanick
2004-09-28 17:28 ` Jon Smirl
2004-09-28 19:35 ` Helge Hafting
2004-09-28 23:10 ` Dave Airlie
2004-09-29 1:27 ` Jon Smirl
2004-09-29 2:11 ` Dave Airlie
2004-09-29 5:25 ` Jon Smirl
2004-09-29 12:37 ` Christoph Hellwig
2004-09-29 11:59 ` Alan Cox
2004-09-29 13:16 ` Dave Airlie
2004-09-29 13:29 ` Keith Whitwell
2004-09-29 13:31 ` Christoph Hellwig
2004-09-29 13:35 ` Keith Whitwell
2004-09-29 14:12 ` Keith Whitwell
2004-09-29 14:16 ` Christoph Hellwig
2004-09-29 14:27 ` Keith Whitwell
2004-09-29 14:39 ` Keith Whitwell
2004-09-29 19:16 ` Keith Packard
2004-09-30 18:10 ` Jon Smirl [this message]
2004-09-29 13:41 ` Dave Airlie
2004-10-01 5:15 ` Jon Smirl
2004-09-29 14:25 ` Keith Whitwell
2004-09-30 0:00 ` Eric Anholt
2004-09-29 21:52 ` Felix Kühling
2004-09-29 21:02 ` Alan Cox
2004-09-29 23:25 ` Jon Smirl
[not found] ` <20041006133714.GA26860@localdomain>
[not found] ` <9e47339104100609307307f8ea@mail.gmail.com>
[not found] ` <20041006211922.GA5167@localdomain>
2004-10-06 21:46 ` Code status (Was: New DRM driver model - gets rid of DRM() macros!) Ian Romanick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e473391040930111029879e62@mail.gmail.com \
--to=jonsmirl@gmail.com \
--cc=dri-devel@lists.sourceforge.net \
--cc=hch@infradead.org \
--cc=keith@tungstengraphics.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xorg@freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox