Skip to contentSkip to conversation

New DRM driver model - gets rid of DRM() macros!

DISCUSSION Jon Smirl 11 participants 28 messages Sep 28, 2004 – Oct 6, 2004 3 messages not in the archive

lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

I've checked two new directories into DRM CVS for Linux 2.6 - linux-core, shared-core. This code implements a new model for DRM where DRM is split into a core piece and personality modules that share the core. The major reason for doing this is that it allows me to remove all of the DRM() macros; something that is causing lot's of complaints from the Linux kernel people.

cvs -z3 -d:pserver:[email protected]:/cvs/dri co drm

The patch for this is quite large, 500K, and it will mess up the Linux 2.4/BSD DRM builds since it removes the DRM() macro. Instead of doing this as a patch I made the new CVS directories.

I've checked radeon and r128 and they work. Everything else should work except ffb, please check the other drivers and let me know. I've probably made some typos with a edit this large.

ffb should work in principle but since I don't own one or a Sparc machine so I can't compile the driver. I suspect ffb has compiler errors but the are easily fixed just by copying similar code from one of the working modules. Please send patches.

The API between the core and personalities doesn't look to be all that huge. With work I'd guess that 10% of the entry points could be eliminated. After another year of development we might be able to specify a stable core API.

What are everyone's thoughts on this? There is no technical reason it can't be implemented on Linux 2.4/BSD, although I don't see any reason to do it for 2.4.

Any ideas on how to generate a unique identifier for the core? It probably should be regenerated by the Makefile whenever the core changes. Personalities would have to match the core identifier. This would stop people from loading binary modules that don't match the core.

After sometime testing and fixing obvious problems I'll generate a patch for the 2.6 kernel and lkml.

[root@smirl linux-2.6]# lsmod | more
Module                  Size  Used by
tdfx                    2816  0
sis                    10176  0
mga                    56704  0
i915                   16896  0
via                    19428  0
savage                  3840  0
r128                   44672  0
radeon                 70272  0
drm                    59684  8 tdfx,sis,mga,i915,via,savage,r128,radeon

The core provides these entry points....

[root@smirl linux-2.6]# grep EXPORT_SYMBOL * drm_bufs.c:EXPORT_SYMBOL(drm_order); drm_bufs.c:EXPORT_SYMBOL(drm_initmap); drm_dma.c:EXPORT_SYMBOL(drm_core_reclaim_buffers); drm_drv.c:EXPORT_SYMBOL(drm_cleanup_pci); drm_drv.c:EXPORT_SYMBOL(drm_init); drm_drv.c:EXPORT_SYMBOL(drm_exit); drm_drv.c:EXPORT_SYMBOL(drm_open); drm_drv.c:EXPORT_SYMBOL(drm_release); drm_drv.c:EXPORT_SYMBOL(drm_ioctl); drm_fops.c:EXPORT_SYMBOL(drm_flush); drm_fops.c:EXPORT_SYMBOL(drm_fasync); drm_init.c:EXPORT_SYMBOL(drm_flags); drm_irq.c:EXPORT_SYMBOL(drm_irq_uninstall); drm_irq.c:EXPORT_SYMBOL(drm_vbl_send_signals); drm_memory.c:EXPORT_SYMBOL(drm_calloc); drm_pci.c:EXPORT_SYMBOL(drm_pci_alloc); drm_pci.c:EXPORT_SYMBOL(drm_pci_free); drm_stub.c:EXPORT_SYMBOL(drm_probe); drm_vm.c:EXPORT_SYMBOL(drm_core_get_map_ofs); drm_vm.c:EXPORT_SYMBOL(drm_core_get_reg_ofs);

Drivers provide these callbacks......

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 *);
       int (*postcleanup)(struct drm_device *);
       int (*presetup)(struct drm_device *);
       int (*postsetup)(struct drm_device *);
       int (*dma_ioctl)( DRM_IOCTL_ARGS );
       /* these are opposites at the moment */
       int (*open_helper)(struct drm_device *, drm_file_t *);
       void (*free_filp_priv)(struct drm_device *, drm_file_t *);

       void (*release)(struct drm_device *, struct file *filp);
       void (*dma_ready)(struct drm_device *);
       int (*dma_quiescent)(struct drm_device *);
       int (*context_ctor)(struct drm_device *dev, int context);
       int (*context_dtor)(struct drm_device *dev, int context);
       int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
       int (*kernel_context_switch_unlock)(struct drm_device *dev);
       int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
/* these have to be filled in */
       int (*postinit)(struct drm_device *, unsigned long flags);
       irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
       void (*irq_preinstall)(struct drm_device *dev);
       void (*irq_postinstall)(struct drm_device *dev);
       void (*irq_uninstall)(struct drm_device *dev);
       void (*reclaim_buffers)(struct file *filp);
       unsigned long (*get_map_ofs)(drm_map_t *map);
       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);
};
Signature · 2 lines
Jon Smirl
[email protected]
#1 lore raw

Jon Smirl wrote:

I /should/ be able to look at the code changes sometime this week. In the mean time, here are some initial comments...

Quoted 3 lines

What are everyone's thoughts on this? There is no technical reason it can't be implemented on Linux 2.4/BSD, although I don't see any reason to do it for 2.4.

I'm of two minds about this. On the one hand, I agree with you. 2.4 is in maintainence mode, and making a big change like this to the graphics driver system is outside that scope. On the other hand, if the 2.4 and the 2.6 code bases diverge too much, bugs fixed on the 2.6 side are less likely to be fixed on the 2.4 side. Moreover, with more divergence between the two, each gets less coverage. I could really go either way on it.

Quoted 5 lines

Any ideas on how to generate a unique identifier for the core? It probably should be regenerated by the Makefile whenever the core changes. Personalities would have to match the core identifier. This would stop people from loading binary modules that don't match the core.

I guess we'd want something like 'drm_core_version_<version number>'. Each layered driver would just have to reference the matching symbol. One neat thing about doing this is that we could theoretically make core modules that support multiple versions of the interal API and export a drm_core_version_* symbol for each.

I have only one problem with this type of setup. If the user has a version mismatch, it's not trivially obvious why they aren't getting direct rendering. There are already a number of ways a user can get "stuck" like this, and this adds another one. It's not a new problem, but it is one that needs to be addressed.

Quoted 14 lines

After sometime testing and fixing obvious problems I'll generate a patch for the 2.6 kernel and lkml.

[root@smirl linux-2.6]# lsmod | more
Module                  Size  Used by
tdfx                    2816  0
sis                    10176  0
mga                    56704  0
i915                   16896  0
via                    19428  0
savage                  3840  0
r128                   44672  0
radeon                 70272  0
drm                    59684  8 tdfx,sis,mga,i915,via,savage,r128,radeon

Anyone have a PCI card so that we can test actually using more than one at a time? In the mean time, I think just having them all load at once and one of them work is good enough.

author
#2 lore raw
Quoted 3 lines · Ian Romanick

Anyone have a PCI card so that we can test actually using more than one at a time? In the mean time, I think just having them all load at once and one of them work is good enough.

It would be best if everyone tested each card individually right now, both PCI and AGP versions should work.

I think I know of a couple places where it might break if multiple cards are used simultaneously. All static variables in the core are suspect and need to be individually checked. There are less than 20 so it shouldn't take too long. Of course any help with this is appreciated.

Another thing that isn't written is splitting the module parameters between the core and personalities. I'll also switch syntax from 2.4 style to 2.6 style. When finished each module with have a debug=1 parameter and the core will also have a cards_limit which defaults to 16.

This version also includes minor number reuse so hotplugging a card in/out won't exhaust the DRM minors.

Signature · 2 lines
Jon Smirl
[email protected]
#3 lore raw
In reply to Ian Romanick
Quoted 2 lines · Ian Romanick

Jon Smirl wrote:

[...]

Quoted 15 lines
Quoted 14 lines

After sometime testing and fixing obvious problems I'll generate a patch for the 2.6 kernel and lkml.

[root@smirl linux-2.6]# lsmod | more
Module                  Size  Used by
tdfx                    2816  0
sis                    10176  0
mga                    56704  0
i915                   16896  0
via                    19428  0
savage                  3840  0
r128                   44672  0
radeon                 70272  0
drm                    59684  8 tdfx,sis,mga,i915,via,savage,r128,radeon
Quoted 3 lines

Anyone have a PCI card so that we can test actually using more than one at a time? In the mean time, I think just having them all load at once and one of them work is good enough.

I have a radeon9200SE pci card, and a matrox G550 agp card. I can try when that 2.6 patch becomes available.

Helge Hafting

#4 lore raw
In reply to Jon Smirl

As with Ian, I'm trying to grab the time to review this over the next day or two, I have one or two worries but as I haven't read over the code I'll wait until I'm ready to dedicate some proper time to it ..

Dave.

Quoted 117 lines · Jon Smirl

I've checked two new directories into DRM CVS for Linux 2.6 - linux-core, shared-core. This code implements a new model for DRM where DRM is split into a core piece and personality modules that share the core. The major reason for doing this is that it allows me to remove all of the DRM() macros; something that is causing lot's of complaints from the Linux kernel people.

cvs -z3 -d:pserver:[email protected]:/cvs/dri co drm

The patch for this is quite large, 500K, and it will mess up the Linux 2.4/BSD DRM builds since it removes the DRM() macro. Instead of doing this as a patch I made the new CVS directories.

I've checked radeon and r128 and they work. Everything else should work except ffb, please check the other drivers and let me know. I've probably made some typos with a edit this large.

ffb should work in principle but since I don't own one or a Sparc machine so I can't compile the driver. I suspect ffb has compiler errors but the are easily fixed just by copying similar code from one of the working modules. Please send patches.

The API between the core and personalities doesn't look to be all that huge. With work I'd guess that 10% of the entry points could be eliminated. After another year of development we might be able to specify a stable core API.

What are everyone's thoughts on this? There is no technical reason it can't be implemented on Linux 2.4/BSD, although I don't see any reason to do it for 2.4.

Any ideas on how to generate a unique identifier for the core? It probably should be regenerated by the Makefile whenever the core changes. Personalities would have to match the core identifier. This would stop people from loading binary modules that don't match the core.

After sometime testing and fixing obvious problems I'll generate a patch for the 2.6 kernel and lkml.

[root@smirl linux-2.6]# lsmod | more
Module                  Size  Used by
tdfx                    2816  0
sis                    10176  0
mga                    56704  0
i915                   16896  0
via                    19428  0
savage                  3840  0
r128                   44672  0
radeon                 70272  0
drm                    59684  8 tdfx,sis,mga,i915,via,savage,r128,radeon

The core provides these entry points....

[root@smirl linux-2.6]# grep EXPORT_SYMBOL * drm_bufs.c:EXPORT_SYMBOL(drm_order); drm_bufs.c:EXPORT_SYMBOL(drm_initmap); drm_dma.c:EXPORT_SYMBOL(drm_core_reclaim_buffers); drm_drv.c:EXPORT_SYMBOL(drm_cleanup_pci); drm_drv.c:EXPORT_SYMBOL(drm_init); drm_drv.c:EXPORT_SYMBOL(drm_exit); drm_drv.c:EXPORT_SYMBOL(drm_open); drm_drv.c:EXPORT_SYMBOL(drm_release); drm_drv.c:EXPORT_SYMBOL(drm_ioctl); drm_fops.c:EXPORT_SYMBOL(drm_flush); drm_fops.c:EXPORT_SYMBOL(drm_fasync); drm_init.c:EXPORT_SYMBOL(drm_flags); drm_irq.c:EXPORT_SYMBOL(drm_irq_uninstall); drm_irq.c:EXPORT_SYMBOL(drm_vbl_send_signals); drm_memory.c:EXPORT_SYMBOL(drm_calloc); drm_pci.c:EXPORT_SYMBOL(drm_pci_alloc); drm_pci.c:EXPORT_SYMBOL(drm_pci_free); drm_stub.c:EXPORT_SYMBOL(drm_probe); drm_vm.c:EXPORT_SYMBOL(drm_core_get_map_ofs); drm_vm.c:EXPORT_SYMBOL(drm_core_get_reg_ofs);

Drivers provide these callbacks......

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 *);
       int (*postcleanup)(struct drm_device *);
       int (*presetup)(struct drm_device *);
       int (*postsetup)(struct drm_device *);
       int (*dma_ioctl)( DRM_IOCTL_ARGS );
       /* these are opposites at the moment */
       int (*open_helper)(struct drm_device *, drm_file_t *);
       void (*free_filp_priv)(struct drm_device *, drm_file_t *);

       void (*release)(struct drm_device *, struct file *filp);
       void (*dma_ready)(struct drm_device *);
       int (*dma_quiescent)(struct drm_device *);
       int (*context_ctor)(struct drm_device *dev, int context);
       int (*context_dtor)(struct drm_device *dev, int context);
       int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
       int (*kernel_context_switch_unlock)(struct drm_device *dev);
       int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
/* these have to be filled in */
       int (*postinit)(struct drm_device *, unsigned long flags);
       irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
       void (*irq_preinstall)(struct drm_device *dev);
       void (*irq_postinstall)(struct drm_device *dev);
       void (*irq_uninstall)(struct drm_device *dev);
       void (*reclaim_buffers)(struct file *filp);
       unsigned long (*get_map_ofs)(drm_map_t *map);
       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);
};
Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DECstation / Linux VAX / ILUG person
author
#5 lore raw

Single card seems to be working currently. I still can't get multiple cards going yet. Second card tries to get the context without holding the lock and errors out.

I'll keep working on it tonight and tomorrow. I'm past the obvious bug stage now and into the ones where I stare at it for five hours before I figure out what is wrong.

Still need someone with a Sparc machine to fix the ffb compile.

Quoted 3 lines · Dave Airlie

As with Ian, I'm trying to grab the time to review this over the next day or two, I have one or two worries but as I haven't read over the code I'll wait until I'm ready to dedicate some proper time to it ..

Signature · 2 lines
Jon Smirl
[email protected]
#6 lore raw
Quoted 2 lines

Still need someone with a Sparc machine to fix the ffb compile.

I've got a cross compiler installed at home for just this purpose .. I'll work on it this evening..

Dave.

Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DECstation / Linux VAX / ILUG person
author
#7 lore raw

I've found the problem with multiple drivers, it's in the mapping code. When drivers close their handles they are deleting permanent maps that don't belong to them. I'll fix it tomorrow.

Signature · 2 lines
Jon Smirl
[email protected]
#8 lore raw
In reply to Jon Smirl
Quoted 6 lines · Jon Smirl

I've checked two new directories into DRM CVS for Linux 2.6 - linux-core, shared-core. This code implements a new model for DRM where DRM is split into a core piece and personality modules that share the core. The major reason for doing this is that it allows me to remove all of the DRM() macros; something that is causing lot's of complaints from the Linux kernel people.

I gave it a quick look and it looks great so far.

Some ideas that would be nice improvements still (not that some may be inherited from the old drm code, I just looked at the CVS checkout):

- once we have Alan's idea of the graphics core implemented drm_init() should go awaw
- drm_probe (and it's call to drm_fill_in_dev) looks a little fishy, what about doing the full ->probe callback in each driver where it can do basic hw setup, dealing with pci and calls back into the drm core for minor number allocation and common structure allocations. This would get rid of the ->preinit and ->postinit hooks.
- isn't drm_order just a copy of get_order()?
- any chance to use proper kernel-doc comments instead of the bastdized and hard to read version you have currently?
- the coding style is a little strange, like spurious whitespaces inside braces, maybe you could run it through scripts/Lindent
- care to use linux/lists.h instead of opencoded lists, e.g. in dev->file_last/dev->file_first or dev->vmalist
- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read
- why do you use DRM_COPY_FROM_USER_IOCTL in Linux-specific code?
- drm__mem_info should be converted to fs/seq_file.c functions
- dito for functions in drm_proc.c

#9 lore raw
Quoted 2 lines · Christoph Hellwig

- once we have Alan's idea of the graphics core implemented drm_init() should go awaw

Last I heard Dave Airlie had that working having fixed my bugs.

#10 lore raw

I have the basics working alright, my only issue was with getting proper sysfs with it, I'll dig up my latest version and post it, I've also got a ported DRM for it,

at the moment it was doing something like /sys/devices/vga00 /sys/devices/vga01 one for each user of the card (multi-card would look really ugly) whereas what we probably want is a directory per card along the lines of
/sys/device/vga0

                  /vga1

and then links 0->x for each registered driver or maybe even links like common, dri , fb0 (make the names meaningful as they do have one...)

Dave.

Quoted 14 lines · Alan Cox
Quoted 2 lines · Christoph Hellwig

- once we have Alan's idea of the graphics core implemented drm_init() should go awaw

Last I heard Dave Airlie had that working having fixed my bugs.

_______________________________________________
xorg mailing list
[email protected]
http://freedesktop.org/mailman/listinfo/xorg

#11 lore raw
In reply to Christoph Hellwig
Quoted 3 lines · Christoph Hellwig

- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read

Pretty sure you couldn't get away with null for these in 2.4, at least.

Keith

#12 lore raw
Quoted 7 lines · Keith Whitwell
Quoted 3 lines · Christoph Hellwig

- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read

Pretty sure you couldn't get away with null for these in 2.4, at least.

Umm, of course you could. There's only a hanfull instance defining a ->flush at all. Similarly all file_ops for regular files and many char devices don't have ->poll. no ->read is pretty rare but 2.4 chæcks it aswell.

#13 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · Keith Whitwell
Quoted 3 lines · Christoph Hellwig

- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read

Quoted 7 lines
Quoted 1 line

Pretty sure you couldn't get away with null for these in 2.4, at least.

Umm, of course you could. There's only a hanfull instance defining a ->flush at all. Similarly all file_ops for regular files and many char devices don't have ->poll. no ->read is pretty rare but 2.4 chæcks it aswell.

I tried it, led to crashes (panics, I guess) & the change had to be reverted.
On reverting the crashes stopped. This was for poll and read:

revision 1.12
date: 2003-04-23 23:42:28 +0000; author: keithw; state: Exp; lines: +13 -0 Install dummy/noop read & poll fops unless the driver has replacements.
----------------------------
revision 1.11
date: 2003-04-22 08:06:13 +0000; author: keithw; state: Exp; lines: +0 -94 remove DRM read, poll and write_string

I didn't do any more investigation & the behaviour may well be different nowadays.

Keith

#20 lore raw
In reply to Christoph Hellwig
Quoted 7 lines

- once we have Alan's idea of the graphics core implemented drm_init() should go awaw
- drm_probe (and it's call to drm_fill_in_dev) looks a little fishy, what about doing the full ->probe callback in each driver where it can do basic hw setup, dealing with pci and calls back into the drm core for minor number allocation and common structure allocations.

We have mentioned this but 90% of the work done by the drivers would be common, we might do it the otherway I suppose have a driver probe that calls a function in the core,

Quoted 4 lines

This would get rid of the ->preinit and ->postinit hooks.
- isn't drm_order just a copy of get_order()?
- any chance to use proper kernel-doc comments instead of the bastdized and hard to read version you have currently?

I think we have doxygen comments in there at the moment - the Mesa/DRI documentation is done with doxygen...

Quoted 2 lines

- the coding style is a little strange, like spurious whitespaces inside braces, maybe you could run it through scripts/Lindent

there are a fair few of these in there in the kernel, it could probably do with a Lindent at some stage over the whole thing...

Quoted 8 lines

- care to use linux/lists.h instead of opencoded lists, e.g. in dev->file_last/dev->file_first or dev->vmalist
- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read
- why do you use DRM_COPY_FROM_USER_IOCTL in Linux-specific code?
- drm__mem_info should be converted to fs/seq_file.c functions
- dito for functions in drm_proc.c

I think I can apply a lot of these to the current kernel code so I'll probably just start doing patches up for these sort of issues separately....

I'll get time to create a bitkeeper tree taking Jons changes ready for merging to Andrew at least, and maybe Linus for 2.6.10.

Dave.

#14 lore raw
In reply to Keith Whitwell
Quoted 16 lines · Keith Whitwell
Quoted 14 lines · Christoph Hellwig
Quoted 9 lines · Keith Whitwell
Quoted 3 lines · Christoph Hellwig

- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read

Pretty sure you couldn't get away with null for these in 2.4, at least.

Quoted 7 lines
Quoted 4 lines

Umm, of course you could. There's only a hanfull instance defining a ->flush at all. Similarly all file_ops for regular files and many char devices don't have ->poll. no ->read is pretty rare but 2.4 chæcks it aswell.

I tried it, led to crashes (panics, I guess) & the change had to be reverted. On reverting the crashes stopped. This was for poll and read:

Thinking about it, it may not have been a problem of crashing, but rather that
the behaviour visible from a program attempting to read (or poll) was
different with noop versions of these functions to NULL versions, and that was causing problems. This is 18 months ago, so yes, I'm being vague.

The X server does look at this file descriptor, which is where the problem would have arisen, but only the gamma & maybe ffb drivers do anything with it.

Keith

#15 lore raw
Quoted 7 lines · Keith Whitwell

Thinking about it, it may not have been a problem of crashing, but rather that
the behaviour visible from a program attempting to read (or poll) was
different with noop versions of these functions to NULL versions, and that was causing problems. This is 18 months ago, so yes, I'm being vague.

The X server does look at this file descriptor, which is where the problem would have arisen, but only the gamma & maybe ffb drivers do anything with it.

Indeed, for read you're returning 0 now instead of the -EINVAL from common code when no ->read is present. I'd say the current drm behaviour is a bug, but if X drivers rely on it.

Similar in poll your return 0 now while the generic code return (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) for fds without ->poll, and again I'd say current drm behaviour could be considered a bug.

for ->flush there's no behaviour change of not supplying it.

#22 lore raw
In reply to Jon Smirl
Quoted 15 lines · Jon Smirl

Drivers provide these callbacks......

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 *);
       int (*postcleanup)(struct drm_device *);
       int (*presetup)(struct drm_device *);
Quoted 8 lines
       int (*postsetup)(struct drm_device *);
       int (*dma_ioctl)( DRM_IOCTL_ARGS );
       /* these are opposites at the moment */
       int (*open_helper)(struct drm_device *, drm_file_t *);
       void (*free_filp_priv)(struct drm_device *, drm_file_t *);

       void (*release)(struct drm_device *, struct file *filp);
       void (*dma_ready)(struct drm_device *);

Is this used by any driver?

Quoted 6 lines
       int (*dma_quiescent)(struct drm_device *);

       int (*context_ctor)(struct drm_device *dev, int context);
       int (*context_dtor)(struct drm_device *dev, int context);
       int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
       int (*kernel_context_switch_unlock)(struct drm_device *dev);

The whole context thing in the kernel is pretty much cruft. The gamma module used to rely on it, maybe the ffb module if that still exists? It would be good to see this disappear.

Though the drivers don't rely on it, I don't know if the server-side code persists in setting it up regardless, which might make it hard to get rid of.

Quoted 3 lines
       int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
/* these have to be filled in */
       int (*postinit)(struct drm_device *, unsigned long flags);

Maybe move this up with the other init/cleanup functions so that they are visibly grouped? Can the large number of init/cleanup functions be rationalized in some way?

Quoted 6 lines
       irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
       void (*irq_preinstall)(struct drm_device *dev);
       void (*irq_postinstall)(struct drm_device *dev);
       void (*irq_uninstall)(struct drm_device *dev);

       void (*reclaim_buffers)(struct file *filp);

Maybe rename this to dma_reclaim_buffers() to make clear what code it is associated with?

Quoted 6 lines
       unsigned long (*get_map_ofs)(drm_map_t *map);
       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);
};
#17 lore raw
In reply to Keith Whitwell
Quoted 10 lines · Keith Whitwell
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Keith Whitwell

Thinking about it, it may not have been a problem of crashing, but rather that the behaviour visible from a program attempting to read (or poll) was different with noop versions of these functions to NULL versions, and that was causing problems. This is 18 months ago, so yes, I'm being vague.

The X server does look at this file descriptor, which is where the problem would have arisen, but only the gamma & maybe ffb drivers do anything with it.

Quoted 6 lines
Quoted 3 lines

Indeed, for read you're returning 0 now instead of the -EINVAL from common code when no ->read is present. I'd say the current drm behaviour is a bug, but if X drivers rely on it.

I'd agree, but it's a widely distributed bug. I guess we can fix it in the X server, but even better would be to rip out the code as it's fundamentally misguided, based on a wierd idea that the kernel would somehow ask the X server to perform a context switch between two userspace clients...

The piece of the puzzle you're missing is that the read() function really did used to do something, and was relied upon.

If you want to go right back to prehistory, the drm was originally designed as a "core + personality" system, where the core supported a number of different context switching mechanisms to cover a variety of hardware cases. The gamma driver exercised one path, but everything since then has been a lot more simplistic, assuming that the hardware state is lost if another context has been active.

Hardware often has the capacity to hold multiple active contexts or to perform fast hardware context save & restore. None of the DRI drivers have attempted to take advantage of that - optimization continues to focus on the single-client scenario.

A future X-on-GL world where regular applications are presumably doing direct rendering will change that assumption...

Keith

#16 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Keith Whitwell

Thinking about it, it may not have been a problem of crashing, but rather that
the behaviour visible from a program attempting to read (or poll) was
different with noop versions of these functions to NULL versions, and that was causing problems. This is 18 months ago, so yes, I'm being vague.

Quoted 6 lines
Quoted 1 line

The X server does look at this file descriptor, which is where the problem would have arisen, but only the gamma & maybe ffb drivers do anything with it.

Indeed, for read you're returning 0 now instead of the -EINVAL from common code when no ->read is present. I'd say the current drm behaviour is a bug, but if X drivers rely on it.

I'd agree, but it's a widely distributed bug. I guess we can fix it in the X server, but even better would be to rip out the code as it's fundamentally misguided, based on a wierd idea that the kernel would somehow ask the X server to perform a context switch between two userspace clients...

Keith

#18 lore raw
In reply to Keith Whitwell
Quoted 2 lines · Keith Whitwell

A future X-on-GL world where regular applications are presumably doing direct rendering will change that assumption...

I'm not planning on eliminating the X protocol in this environment, so unless cairo really takes off and applications start coding to cairo-on-GL instead of cairo-on-X-on-GL, then we'll have about the same number of contexts, although the X context will be more rational than it currently is.

-keith

#24 lore raw
In reply to Jon Smirl
Quoted 6 lines · On Tue, 28 Sep 2004 11:54:35 -0400 Jon Smirl <[email protected]> wrote:

I've checked two new directories into DRM CVS for Linux 2.6 - linux-core, shared-core. This code implements a new model for DRM where DRM is split into a core piece and personality modules that share the core. The major reason for doing this is that it allows me to remove all of the DRM() macros; something that is causing lot's of complaints from the Linux kernel people.

A single savage works just fine. This is lsmod output with X running:

Module                  Size  Used by
savage                  3520  0
drm                    62500  3 savage

Is it normal that the savage module looks unused? I can actually rmmod the savage module while X is running. After that direct rending fails with some error message about permissions ... reloading savage didn't help (of course, because X wouldn't reinitialize it). A bit later the box locked up. Is this 0 usage count and the ability to rmmod the module while X is running specific to the savage driver or do other drivers show the same behaviour?

Some questions about future driver development: So the new linux-core and shared-core are the place to do new driver development? If this is correct then it will be for 2.6 kernels only, right? I suppose there would some back-porting effort involved in getting a future savage driver to work with 2.4 again (like adding back all the DRM() macros).

Quoted 1 line

[snip]

Quoted 3 lines
Signature · 2 lines
Jon Smirl
[email protected]
| Felix Kühling <[email protected]>                     http://fxk.de.vu |
| PGP Fingerprint: 6A3C 9566 5B30 DDED 73C3  B152 151C 5CC1 D888 E595 |
#25 lore raw
Quoted 5 lines · Felix Kühling
Module                  Size  Used by
savage                  3520  0
drm                    62500  3 savage

Is it normal that the savage module looks unused?

looks like a bug. If the drm layer provides the file_operations for the device node then the locking done automatically locks the wrong module. Thats easy to fix with try_module_get() and module_put()

author
#26 lore raw
In reply to Felix Kühling
Quoted 7 lines · Felix Kühling

Is it normal that the savage module looks unused? I can actually rmmod the savage module while X is running. After that direct rending fails with some error message about permissions ... reloading savage didn't help (of course, because X wouldn't reinitialize it). A bit later the box locked up. Is this 0 usage count and the ability to rmmod the module while X is running specific to the savage driver or do other drivers show the same behaviour?

This is a bug, open is marking the wrong module in use.

Quoted 5 lines

Some questions about future driver development: So the new linux-core and shared-core are the place to do new driver development? If this is correct then it will be for 2.6 kernels only, right? I suppose there would some back-porting effort involved in getting a future savage driver to work with 2.4 again (like adding back all the DRM() macros).

There is no real difference between the code in the linux directory and linux-core except for the removal of the DRM macros and the associated restructuring needed to make everything work. When we get linux-core working without problems, it's not there yet, it could become the future 2.6 platform if everyone agrees. The impact of the linux-core changes are minimal on the board specific code.

For 2.4 there is a choice: continue using the linux directory or backport linux-core to 2.4. I don't know how much effort everyone wants to put into backporting new driver development to 2.4. There are several possible choices:

1) leave 2.4 alone and stop working on it, 2.4 stays in the linux directory
2) declare the DRM version in the linux-2.4 the final version and only submit bug patches via the kernel process.
3) backport linux-core to 2.4 and so that everything will build on both OS's. Some 2.6 kernel changes are starting to make this a very cluttered option.
4) Make parallel changes to the 2.4 and 2.6 versions.
5) other combinations of these

The removal of the DRM macros from files in the shared directory means that things can't be shared again unless 2.4/BSD also move the the core model. I have no strong opinions on what to do about 2.4. I'll go along with whatever the crowd picks.

Signature · 2 lines
Jon Smirl
[email protected]
#23 lore raw
In reply to Keith Whitwell
Quoted 34 lines · Keith Whitwell
Quoted 15 lines · Jon Smirl

Drivers provide these callbacks......

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 *);
       int (*postcleanup)(struct drm_device *);
       int (*presetup)(struct drm_device *);
Quoted 8 lines
       int (*postsetup)(struct drm_device *);
       int (*dma_ioctl)( DRM_IOCTL_ARGS );
       /* these are opposites at the moment */
       int (*open_helper)(struct drm_device *, drm_file_t *);
       void (*free_filp_priv)(struct drm_device *, drm_file_t *);

       void (*release)(struct drm_device *, struct file *filp);
       void (*dma_ready)(struct drm_device *);

Is this used by any driver?

Quoted 6 lines
       int (*dma_quiescent)(struct drm_device *);

       int (*context_ctor)(struct drm_device *dev, int context);
       int (*context_dtor)(struct drm_device *dev, int context);
       int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
       int (*kernel_context_switch_unlock)(struct drm_device *dev);
Quoted 6 lines

The whole context thing in the kernel is pretty much cruft. The gamma module used to rely on it, maybe the ffb module if that still exists? It would be good to see this disappear.

Though the drivers don't rely on it, I don't know if the server-side code persists in setting it up regardless, which might make it hard to get rid of.

SiS relies on context ctor/dtor (dtor only, when I'm done) for its kernel memory manager.

Signature · 2 lines
Eric Anholt                                [email protected]          
http://people.freebsd.org/~anholt/         [email protected]
author
#19 lore raw
In reply to Keith Whitwell

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.

Signature · 2 lines
Jon Smirl
[email protected]

===== linux-core/drmP.h 1.2 vs edited =====

linux-core/drmP.h +8 -12
@@ -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 =====

linux-core/drm_drv.c +1 -14
@@ -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 =====

linux-core/drm_fops.c +0 -25
@@ -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 =====

linux-core/drm_stub.c +1 -1
@@ -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 =====

linux-core/drm_vm.c +1 -0
@@ -670,3 +670,4 @@
 	drm_vm_open(vma);
 	return 0;
 }
+EXPORT_SYMBOL(drm_mmap);

===== linux-core/ffb_drv.c 1.1 vs edited =====

linux-core/ffb_drv.c +8 -0
@@ -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 =====

linux-core/i810_dma.c +1 -13
@@ -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( &current->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 =====

linux-core/i810_drv.c +8 -0
@@ -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 =====

linux-core/i830_dma.c +1 -13
@@ -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( &current->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 =====

linux-core/i830_drv.c +8 -0
@@ -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 =====

linux-core/i915_drv.c +8 -0
@@ -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 =====

linux-core/mach64_drv.c +8 -0
@@ -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 =====

linux-core/mga_drv.c +8 -0
@@ -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 =====

linux-core/r128_drv.c +8 -0
@@ -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 =====

linux-core/radeon_drv.c +8 -0
@@ -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 =====

linux-core/savage_drv.c +8 -0
@@ -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 =====

linux-core/sis_drv.c +8 -0
@@ -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 =====

linux-core/tdfx_drv.c +8 -0
@@ -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 =====

shared-core/via_drv.c +8 -0
@@ -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)
author
#21 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

Some ideas that would be nice improvements still (not that some may be inherited from the old drm code, I just looked at the CVS checkout):

- once we have Alan's idea of the graphics core implemented drm_init() should go awaw
- drm_probe (and it's call to drm_fill_in_dev) looks a little fishy, what about doing the full ->probe callback in each driver where it can do basic hw setup, dealing with pci and calls back into the drm core for minor number allocation and common structure allocations. This would get rid of the ->preinit and ->postinit hooks.

This has to stay the way it currently is because of the stealth mode code

Quoted 1 line

- isn't drm_order just a copy of get_order()?

switched to get_order

Quoted 2 lines

- any chance to use proper kernel-doc comments instead of the bastdized and hard to read version you have currently?

doc people don't want to switch

Quoted 2 lines

- the coding style is a little strange, like spurious whitespaces inside braces, maybe you could run it through scripts/Lindent

ran most of it through Lindent. check out CVS for results.

Quoted 2 lines

- care to use linux/lists.h instead of opencoded lists, e.g. in dev->file_last/dev->file_first or dev->vmalist

There are about 20 open coded lists. I started to fix some of these but the code involved can be touchy and it's already well tested. It would be better to wait on these until someone is working on the code involved. I don't want to introduce bugs because I don't understand the code 100%.

Quoted 3 lines

- drm_flush is a noop. a NULL ->flush does the same thing, just easier
- dito or ->poll
- dito for ->read

Changed these to use kernel defaults.

Quoted 1 line

- why do you use DRM_COPY_FROM_USER_IOCTL in Linux-specific code?

That can probably be fixed. I believe it is because it is hiding a 2.4/2.6 change.

Quoted 2 lines

- drm__mem_info should be converted to fs/seq_file.c functions
- dito for functions in drm_proc.c

I started to do this to but I didn't want to disrupt know working code. These may get rewritten for sysfs.

Quoted 1 line
Signature · 2 lines
Jon Smirl
[email protected]
#30 lore raw

Re: Code status (Was: New DRM driver model - gets rid of DRM() macros!)

In reply to a message not in the archive
Quoted 5 lines · José Fonseca

They happen one after the other so fast that they're never recorded on /proc/kmsg. I got a screenshot (literaly, with a digital camera) on
http://jrfonseca.dyndns.org/misc/bugs/radeon-core.jpg after insmod'ing radeon. It's likely that the first oops is within the loaded module, but all the others oops trash it away...

This is funny to me. I seem to remember someone scoffing the importance of being able to print oopses, no matter what, at kernel summit. A lot of people nodded approvingly until Linus took the mic...and described almost exactly this situation! :)