Skip to content

Commit c1736b9

Browse files
author
Thomas Zimmermann
committed
drm: IRQ midlayer is now legacy
Hide the DRM midlayer behind CONFIG_DRM_LEGACY, make functions use the prefix drm_legacy_, and move declarations to drm_legacy.h. In struct drm_device, move the fields irq and irq_enabled behind CONFIG_DRM_LEGACY. All callers have been updated. Signed-off-by: Thomas Zimmermann <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0b05dd6 commit c1736b9

File tree

12 files changed

+27
-155
lines changed

12 files changed

+27
-155
lines changed

drivers/gpu/drm/drm_irq.c

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -60,46 +60,14 @@
6060
#include <drm/drm.h>
6161
#include <drm/drm_device.h>
6262
#include <drm/drm_drv.h>
63-
#include <drm/drm_irq.h>
63+
#include <drm/drm_legacy.h>
6464
#include <drm/drm_print.h>
6565
#include <drm/drm_vblank.h>
6666

6767
#include "drm_internal.h"
6868

69-
/**
70-
* DOC: irq helpers
71-
*
72-
* The DRM core provides very simple support helpers to enable IRQ handling on a
73-
* device through the drm_irq_install() and drm_irq_uninstall() functions. This
74-
* only supports devices with a single interrupt on the main device stored in
75-
* &drm_device.dev and set as the device parameter in drm_dev_alloc().
76-
*
77-
* These IRQ helpers are strictly optional. Since these helpers don't automatically
78-
* clean up the requested interrupt like e.g. devm_request_irq() they're not really
79-
* recommended.
80-
*/
81-
82-
/**
83-
* drm_irq_install - install IRQ handler
84-
* @dev: DRM device
85-
* @irq: IRQ number to install the handler for
86-
*
87-
* Initializes the IRQ related data. Installs the handler, calling the driver
88-
* &drm_driver.irq_preinstall and &drm_driver.irq_postinstall functions before
89-
* and after the installation.
90-
*
91-
* This is the simplified helper interface provided for drivers with no special
92-
* needs.
93-
*
94-
* @irq must match the interrupt number that would be passed to request_irq(),
95-
* if called directly instead of using this helper function.
96-
*
97-
* &drm_driver.irq_handler is called to handle the registered interrupt.
98-
*
99-
* Returns:
100-
* Zero on success or a negative error code on failure.
101-
*/
102-
int drm_irq_install(struct drm_device *dev, int irq)
69+
#if IS_ENABLED(CONFIG_DRM_LEGACY)
70+
static int drm_legacy_irq_install(struct drm_device *dev, int irq)
10371
{
10472
int ret;
10573
unsigned long sh_flags = 0;
@@ -144,24 +112,8 @@ int drm_irq_install(struct drm_device *dev, int irq)
144112

145113
return ret;
146114
}
147-
EXPORT_SYMBOL(drm_irq_install);
148115

149-
/**
150-
* drm_irq_uninstall - uninstall the IRQ handler
151-
* @dev: DRM device
152-
*
153-
* Calls the driver's &drm_driver.irq_uninstall function and unregisters the IRQ
154-
* handler. This should only be called by drivers which used drm_irq_install()
155-
* to set up their interrupt handler.
156-
*
157-
* Note that for kernel modesetting drivers it is a bug if this function fails.
158-
* The sanity checks are only to catch buggy user modesetting drivers which call
159-
* the same function through an ioctl.
160-
*
161-
* Returns:
162-
* Zero on success or a negative error code on failure.
163-
*/
164-
int drm_irq_uninstall(struct drm_device *dev)
116+
int drm_legacy_irq_uninstall(struct drm_device *dev)
165117
{
166118
unsigned long irqflags;
167119
bool irq_enabled;
@@ -207,9 +159,8 @@ int drm_irq_uninstall(struct drm_device *dev)
207159

208160
return 0;
209161
}
210-
EXPORT_SYMBOL(drm_irq_uninstall);
162+
EXPORT_SYMBOL(drm_legacy_irq_uninstall);
211163

212-
#if IS_ENABLED(CONFIG_DRM_LEGACY)
213164
int drm_legacy_irq_control(struct drm_device *dev, void *data,
214165
struct drm_file *file_priv)
215166
{
@@ -238,13 +189,13 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,
238189
ctl->irq != irq)
239190
return -EINVAL;
240191
mutex_lock(&dev->struct_mutex);
241-
ret = drm_irq_install(dev, irq);
192+
ret = drm_legacy_irq_install(dev, irq);
242193
mutex_unlock(&dev->struct_mutex);
243194

244195
return ret;
245196
case DRM_UNINST_HANDLER:
246197
mutex_lock(&dev->struct_mutex);
247-
ret = drm_irq_uninstall(dev);
198+
ret = drm_legacy_irq_uninstall(dev);
248199
mutex_unlock(&dev->struct_mutex);
249200

250201
return ret;

drivers/gpu/drm/drm_legacy_misc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include <drm/drm_device.h>
3737
#include <drm/drm_drv.h>
38-
#include <drm/drm_irq.h>
3938
#include <drm/drm_print.h>
4039

4140
#include "drm_internal.h"
@@ -78,7 +77,7 @@ int drm_legacy_setup(struct drm_device * dev)
7877
void drm_legacy_dev_reinit(struct drm_device *dev)
7978
{
8079
if (dev->irq_enabled)
81-
drm_irq_uninstall(dev);
80+
drm_legacy_irq_uninstall(dev);
8281

8382
mutex_lock(&dev->struct_mutex);
8483

drivers/gpu/drm/drm_vblank.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,10 +1739,10 @@ static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe,
17391739

17401740
static bool drm_wait_vblank_supported(struct drm_device *dev)
17411741
{
1742-
if (IS_ENABLED(CONFIG_DRM_LEGACY)) {
1743-
if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY)))
1744-
return dev->irq_enabled;
1745-
}
1742+
#if IS_ENABLED(CONFIG_DRM_LEGACY)
1743+
if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY)))
1744+
return dev->irq_enabled;
1745+
#endif
17461746
return drm_dev_has_vblank(dev);
17471747
}
17481748

drivers/gpu/drm/i810/i810_dma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <drm/drm_drv.h>
3939
#include <drm/drm_file.h>
4040
#include <drm/drm_ioctl.h>
41-
#include <drm/drm_irq.h>
4241
#include <drm/drm_print.h>
4342
#include <drm/i810_drm.h>
4443

@@ -209,7 +208,7 @@ static int i810_dma_cleanup(struct drm_device *dev)
209208
* is freed, it's too late.
210209
*/
211210
if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled)
212-
drm_irq_uninstall(dev);
211+
drm_legacy_irq_uninstall(dev);
213212

214213
if (dev->dev_private) {
215214
int i;

drivers/gpu/drm/mga/mga_dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
949949
* is freed, it's too late.
950950
*/
951951
if (dev->irq_enabled)
952-
drm_irq_uninstall(dev);
952+
drm_legacy_irq_uninstall(dev);
953953

954954
if (dev->dev_private) {
955955
drm_mga_private_t *dev_priv = dev->dev_private;

drivers/gpu/drm/mga/mga_drv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <drm/drm_device.h>
3939
#include <drm/drm_file.h>
4040
#include <drm/drm_ioctl.h>
41-
#include <drm/drm_irq.h>
4241
#include <drm/drm_legacy.h>
4342
#include <drm/drm_print.h>
4443
#include <drm/drm_sarea.h>

drivers/gpu/drm/r128/r128_cce.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#include <drm/drm_device.h>
4141
#include <drm/drm_file.h>
42-
#include <drm/drm_irq.h>
4342
#include <drm/drm_legacy.h>
4443
#include <drm/drm_print.h>
4544
#include <drm/r128_drm.h>
@@ -603,7 +602,7 @@ int r128_do_cleanup_cce(struct drm_device *dev)
603602
* is freed, it's too late.
604603
*/
605604
if (dev->irq_enabled)
606-
drm_irq_uninstall(dev);
605+
drm_legacy_irq_uninstall(dev);
607606

608607
if (dev->dev_private) {
609608
drm_r128_private_t *dev_priv = dev->dev_private;

drivers/gpu/drm/via/via_mm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include <drm/drm_device.h>
3131
#include <drm/drm_file.h>
32-
#include <drm/drm_irq.h>
3332
#include <drm/via_drm.h>
3433

3534
#include "via_drv.h"
@@ -86,7 +85,7 @@ int via_final_context(struct drm_device *dev, int context)
8685
/* Last context, perform cleanup */
8786
if (list_is_singular(&dev->ctxlist)) {
8887
DRM_DEBUG("Last Context\n");
89-
drm_irq_uninstall(dev);
88+
drm_legacy_irq_uninstall(dev);
9089
via_cleanup_futex(dev_priv);
9190
via_do_cleanup_map(dev);
9291
}

include/drm/drm_device.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,6 @@ struct drm_device {
191191
*/
192192
struct list_head clientlist;
193193

194-
/**
195-
* @irq_enabled:
196-
*
197-
* Indicates that interrupt handling is enabled, specifically vblank
198-
* handling. Drivers which don't use drm_irq_install() need to set this
199-
* to true manually.
200-
*/
201-
bool irq_enabled;
202-
203-
/**
204-
* @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers.
205-
*/
206-
int irq;
207-
208194
/**
209195
* @vblank_disable_immediate:
210196
*
@@ -372,6 +358,10 @@ struct drm_device {
372358

373359
/* Scatter gather memory */
374360
struct drm_sg_mem *sg;
361+
362+
/* IRQs */
363+
bool irq_enabled;
364+
int irq;
375365
#endif
376366
};
377367

include/drm/drm_drv.h

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ enum drm_driver_feature {
137137
* @DRIVER_HAVE_IRQ:
138138
*
139139
* Legacy irq support. Only for legacy drivers. Do not use.
140-
*
141-
* New drivers can either use the drm_irq_install() and
142-
* drm_irq_uninstall() helper functions, or roll their own irq support
143-
* code by calling request_irq() directly.
144140
*/
145141
DRIVER_HAVE_IRQ = BIT(30),
146142
/**
@@ -271,42 +267,6 @@ struct drm_driver {
271267
*/
272268
void (*release) (struct drm_device *);
273269

274-
/**
275-
* @irq_handler:
276-
*
277-
* Interrupt handler called when using drm_irq_install(). Not used by
278-
* drivers which implement their own interrupt handling.
279-
*/
280-
irqreturn_t(*irq_handler) (int irq, void *arg);
281-
282-
/**
283-
* @irq_preinstall:
284-
*
285-
* Optional callback used by drm_irq_install() which is called before
286-
* the interrupt handler is registered. This should be used to clear out
287-
* any pending interrupts (from e.g. firmware based drives) and reset
288-
* the interrupt handling registers.
289-
*/
290-
void (*irq_preinstall) (struct drm_device *dev);
291-
292-
/**
293-
* @irq_postinstall:
294-
*
295-
* Optional callback used by drm_irq_install() which is called after
296-
* the interrupt handler is registered. This should be used to enable
297-
* interrupt generation in the hardware.
298-
*/
299-
int (*irq_postinstall) (struct drm_device *dev);
300-
301-
/**
302-
* @irq_uninstall:
303-
*
304-
* Optional callback used by drm_irq_uninstall() which is called before
305-
* the interrupt handler is unregistered. This should be used to disable
306-
* interrupt generation in the hardware.
307-
*/
308-
void (*irq_uninstall) (struct drm_device *dev);
309-
310270
/**
311271
* @master_set:
312272
*
@@ -504,6 +464,10 @@ struct drm_driver {
504464
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
505465
int (*dma_quiescent) (struct drm_device *);
506466
int (*context_dtor) (struct drm_device *dev, int context);
467+
irqreturn_t (*irq_handler)(int irq, void *arg);
468+
void (*irq_preinstall)(struct drm_device *dev);
469+
int (*irq_postinstall)(struct drm_device *dev);
470+
void (*irq_uninstall)(struct drm_device *dev);
507471
u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe);
508472
int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
509473
void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);

0 commit comments

Comments
 (0)