Commit d924155d authored by Russell King's avatar Russell King

drm/armada: avoid work allocation

Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent c93dfdcd
...@@ -214,13 +214,15 @@ static void armada_drm_plane_work_call(struct armada_crtc *dcrtc, ...@@ -214,13 +214,15 @@ static void armada_drm_plane_work_call(struct armada_crtc *dcrtc,
void (*fn)(struct armada_crtc *, struct armada_plane_work *)) void (*fn)(struct armada_crtc *, struct armada_plane_work *))
{ {
struct armada_plane *dplane = drm_to_armada_plane(work->plane); struct armada_plane *dplane = drm_to_armada_plane(work->plane);
struct drm_pending_vblank_event *event = work->event; struct drm_pending_vblank_event *event;
struct drm_framebuffer *fb = work->old_fb; struct drm_framebuffer *fb;
if (fn) if (fn)
fn(dcrtc, work); fn(dcrtc, work);
drm_crtc_vblank_put(&dcrtc->crtc); drm_crtc_vblank_put(&dcrtc->crtc);
event = work->event;
fb = work->old_fb;
if (event || fb) { if (event || fb) {
struct drm_device *dev = dcrtc->crtc.dev; struct drm_device *dev = dcrtc->crtc.dev;
unsigned long flags; unsigned long flags;
...@@ -233,6 +235,9 @@ static void armada_drm_plane_work_call(struct armada_crtc *dcrtc, ...@@ -233,6 +235,9 @@ static void armada_drm_plane_work_call(struct armada_crtc *dcrtc,
spin_unlock_irqrestore(&dev->event_lock, flags); spin_unlock_irqrestore(&dev->event_lock, flags);
} }
if (work->need_kfree)
kfree(work);
wake_up(&dplane->frame_wait); wake_up(&dplane->frame_wait);
} }
...@@ -278,12 +283,6 @@ void armada_drm_plane_work_cancel(struct armada_crtc *dcrtc, ...@@ -278,12 +283,6 @@ void armada_drm_plane_work_cancel(struct armada_crtc *dcrtc,
armada_drm_plane_work_call(dcrtc, work, work->cancel); armada_drm_plane_work_call(dcrtc, work, work->cancel);
} }
static void armada_drm_crtc_finish_frame_work(struct armada_crtc *dcrtc,
struct armada_plane_work *work)
{
kfree(work);
}
static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc, static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc,
struct armada_plane_work *work) struct armada_plane_work *work)
{ {
...@@ -292,8 +291,6 @@ static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc, ...@@ -292,8 +291,6 @@ static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc,
spin_lock_irqsave(&dcrtc->irq_lock, flags); spin_lock_irqsave(&dcrtc->irq_lock, flags);
armada_drm_crtc_update_regs(dcrtc, work->regs); armada_drm_crtc_update_regs(dcrtc, work->regs);
spin_unlock_irqrestore(&dcrtc->irq_lock, flags); spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
armada_drm_crtc_finish_frame_work(dcrtc, work);
} }
static struct armada_plane_work * static struct armada_plane_work *
...@@ -308,7 +305,7 @@ armada_drm_crtc_alloc_plane_work(struct drm_plane *plane) ...@@ -308,7 +305,7 @@ armada_drm_crtc_alloc_plane_work(struct drm_plane *plane)
work->plane = plane; work->plane = plane;
work->fn = armada_drm_crtc_complete_frame_work; work->fn = armada_drm_crtc_complete_frame_work;
work->cancel = armada_drm_crtc_finish_frame_work; work->need_kfree = true;
armada_reg_queue_end(work->regs, i); armada_reg_queue_end(work->regs, i);
return work; return work;
...@@ -1173,6 +1170,11 @@ static const struct drm_plane_funcs armada_primary_plane_funcs = { ...@@ -1173,6 +1170,11 @@ static const struct drm_plane_funcs armada_primary_plane_funcs = {
int armada_drm_plane_init(struct armada_plane *plane) int armada_drm_plane_init(struct armada_plane *plane)
{ {
unsigned int i;
for (i = 0; i < ARRAY_SIZE(plane->works); i++)
plane->works[i].plane = &plane->base;
init_waitqueue_head(&plane->frame_wait); init_waitqueue_head(&plane->frame_wait);
return 0; return 0;
......
...@@ -38,6 +38,7 @@ struct armada_variant; ...@@ -38,6 +38,7 @@ struct armada_variant;
struct armada_plane_work { struct armada_plane_work {
void (*fn)(struct armada_crtc *, struct armada_plane_work *); void (*fn)(struct armada_crtc *, struct armada_plane_work *);
void (*cancel)(struct armada_crtc *, struct armada_plane_work *); void (*cancel)(struct armada_crtc *, struct armada_plane_work *);
bool need_kfree;
struct drm_plane *plane; struct drm_plane *plane;
struct drm_framebuffer *old_fb; struct drm_framebuffer *old_fb;
struct drm_pending_vblank_event *event; struct drm_pending_vblank_event *event;
...@@ -56,6 +57,8 @@ struct armada_plane_state { ...@@ -56,6 +57,8 @@ struct armada_plane_state {
struct armada_plane { struct armada_plane {
struct drm_plane base; struct drm_plane base;
wait_queue_head_t frame_wait; wait_queue_head_t frame_wait;
bool next_work;
struct armada_plane_work works[2];
struct armada_plane_work *work; struct armada_plane_work *work;
struct armada_plane_state state; struct armada_plane_state state;
}; };
......
...@@ -32,7 +32,6 @@ struct armada_ovl_plane_properties { ...@@ -32,7 +32,6 @@ struct armada_ovl_plane_properties {
struct armada_ovl_plane { struct armada_ovl_plane {
struct armada_plane base; struct armada_plane base;
struct armada_plane_work work;
struct armada_ovl_plane_properties prop; struct armada_ovl_plane_properties prop;
}; };
#define drm_to_armada_ovl_plane(p) \ #define drm_to_armada_ovl_plane(p) \
...@@ -85,7 +84,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -85,7 +84,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
{ {
struct armada_ovl_plane *dplane = drm_to_armada_ovl_plane(plane); struct armada_ovl_plane *dplane = drm_to_armada_ovl_plane(plane);
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
struct armada_plane_work *work = &dplane->work; struct armada_plane_work *work;
const struct drm_format_info *format; const struct drm_format_info *format;
struct drm_plane_state state = { struct drm_plane_state state = {
.plane = plane, .plane = plane,
...@@ -119,6 +118,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -119,6 +118,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
if (ret) if (ret)
return ret; return ret;
work = &dplane->base.works[dplane->base.next_work];
ctrl0 = CFG_DMA_FMT(drm_fb_to_armada_fb(fb)->fmt) | ctrl0 = CFG_DMA_FMT(drm_fb_to_armada_fb(fb)->fmt) |
CFG_DMA_MOD(drm_fb_to_armada_fb(fb)->mod) | CFG_DMA_MOD(drm_fb_to_armada_fb(fb)->mod) |
CFG_CBSH_ENA; CFG_CBSH_ENA;
...@@ -248,6 +249,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -248,6 +249,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
ret = armada_drm_plane_work_queue(dcrtc, work); ret = armada_drm_plane_work_queue(dcrtc, work);
if (ret) if (ret)
DRM_ERROR("failed to queue plane work: %d\n", ret); DRM_ERROR("failed to queue plane work: %d\n", ret);
dplane->base.next_work = !dplane->base.next_work;
} }
return 0; return 0;
} }
...@@ -434,8 +437,8 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs) ...@@ -434,8 +437,8 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
return ret; return ret;
} }
dplane->work.plane = &dplane->base.base; dplane->base.works[0].fn = armada_ovl_plane_work;
dplane->work.fn = armada_ovl_plane_work; dplane->base.works[1].fn = armada_ovl_plane_work;
ret = drm_universal_plane_init(dev, &dplane->base.base, crtcs, ret = drm_universal_plane_init(dev, &dplane->base.base, crtcs,
&armada_ovl_plane_funcs, &armada_ovl_plane_funcs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment