Skip to content

Commit 04a1c47

Browse files
Thomas ZimmermannMaarten Lankhorst
authored andcommitted
drm/i915/display: Remove struct drm_fb_helper from struct intel_fbdev
Store instances of drm_fb_helper and struct intel_fbdev separately. This will allow i915 to use the common fbdev client, which allocates its own instance of struct drm_fb_helper. There is at most one instance of type each per DRM device, so both can be referenced directly from the i915 and DRM device structures. A later patchset might rework the common fbdev client to allow for storing both, drm_fb_helper and intel_fbdev, together in the same place. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maarten Lankhorst <[email protected]>
1 parent 03e1b3d commit 04a1c47

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

drivers/gpu/drm/i915/display/intel_fbdev.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <drm/drm_fourcc.h>
4444
#include <drm/drm_gem.h>
4545
#include <drm/drm_gem_framebuffer_helper.h>
46+
#include <drm/drm_managed.h>
4647
#include <drm/drm_print.h>
4748

4849
#include "i915_drv.h"
@@ -56,15 +57,16 @@
5657
#include "intel_frontbuffer.h"
5758

5859
struct intel_fbdev {
59-
struct drm_fb_helper helper;
6060
struct intel_framebuffer *fb;
6161
struct i915_vma *vma;
6262
unsigned long vma_flags;
6363
};
6464

6565
static struct intel_fbdev *to_intel_fbdev(struct drm_fb_helper *fb_helper)
6666
{
67-
return container_of(fb_helper, struct intel_fbdev, helper);
67+
struct drm_i915_private *i915 = to_i915(fb_helper->client.dev);
68+
69+
return i915->display.fbdev.fbdev;
6870
}
6971

7072
static struct intel_frontbuffer *to_frontbuffer(struct intel_fbdev *ifbdev)
@@ -120,30 +122,30 @@ static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,
120122

121123
static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
122124
{
123-
struct intel_fbdev *fbdev = to_intel_fbdev(info->par);
124-
struct drm_gem_object *obj = drm_gem_fb_get_obj(&fbdev->fb->base, 0);
125+
struct drm_fb_helper *fb_helper = info->par;
126+
struct drm_gem_object *obj = drm_gem_fb_get_obj(fb_helper->fb, 0);
125127

126128
return intel_bo_fb_mmap(obj, vma);
127129
}
128130

129131
static void intel_fbdev_fb_destroy(struct fb_info *info)
130132
{
131133
struct drm_fb_helper *fb_helper = info->par;
132-
struct intel_fbdev *ifbdev = container_of(fb_helper, struct intel_fbdev, helper);
134+
struct intel_fbdev *ifbdev = to_intel_fbdev(fb_helper);
133135

134-
drm_fb_helper_fini(&ifbdev->helper);
136+
drm_fb_helper_fini(fb_helper);
135137

136138
/*
137139
* We rely on the object-free to release the VMA pinning for
138140
* the info->screen_base mmaping. Leaking the VMA is simpler than
139141
* trying to rectify all the possible error paths leading here.
140142
*/
141143
intel_fb_unpin_vma(ifbdev->vma, ifbdev->vma_flags);
142-
drm_framebuffer_remove(&ifbdev->fb->base);
144+
drm_framebuffer_remove(fb_helper->fb);
143145

144146
drm_client_release(&fb_helper->client);
145-
drm_fb_helper_unprepare(&ifbdev->helper);
146-
kfree(ifbdev);
147+
drm_fb_helper_unprepare(fb_helper);
148+
kfree(fb_helper);
147149
}
148150

149151
__diag_push();
@@ -227,7 +229,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
227229
goto out_unpin;
228230
}
229231

230-
ifbdev->helper.fb = &fb->base;
232+
helper->fb = &fb->base;
231233

232234
info->fbops = &intelfb_ops;
233235

@@ -237,7 +239,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
237239
if (ret)
238240
goto out_unpin;
239241

240-
drm_fb_helper_fill_info(info, &ifbdev->helper, sizes);
242+
drm_fb_helper_fill_info(info, dev->fb_helper, sizes);
241243

242244
/* If the object is shmemfs backed, it will have given us zeroed pages.
243245
* If the object is stolen however, it will be full of whatever
@@ -528,13 +530,14 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous
528530
}
529531
}
530532

531-
drm_fb_helper_set_suspend(&ifbdev->helper, state);
533+
drm_fb_helper_set_suspend(dev->fb_helper, state);
532534
console_unlock();
533535
}
534536

535537
static int intel_fbdev_restore_mode(struct drm_i915_private *dev_priv)
536538
{
537539
struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev;
540+
struct drm_device *dev = &dev_priv->drm;
538541
int ret;
539542

540543
if (!ifbdev)
@@ -543,7 +546,7 @@ static int intel_fbdev_restore_mode(struct drm_i915_private *dev_priv)
543546
if (!ifbdev->vma)
544547
return -ENOMEM;
545548

546-
ret = drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper);
549+
ret = drm_fb_helper_restore_fbdev_mode_unlocked(dev->fb_helper);
547550
if (ret)
548551
return ret;
549552

@@ -640,13 +643,14 @@ void intel_fbdev_setup(struct drm_i915_private *i915)
640643
{
641644
struct drm_device *dev = &i915->drm;
642645
struct intel_fbdev *ifbdev;
646+
struct drm_fb_helper *fb_helper;
643647
unsigned int preferred_bpp = 0;
644648
int ret;
645649

646650
if (!HAS_DISPLAY(i915))
647651
return;
648652

649-
ifbdev = kzalloc(sizeof(*ifbdev), GFP_KERNEL);
653+
ifbdev = drmm_kzalloc(dev, sizeof(*ifbdev), GFP_KERNEL);
650654
if (!ifbdev)
651655
return;
652656

@@ -657,30 +661,33 @@ void intel_fbdev_setup(struct drm_i915_private *i915)
657661
if (!preferred_bpp)
658662
preferred_bpp = 32;
659663

660-
drm_fb_helper_prepare(dev, &ifbdev->helper, preferred_bpp, &intel_fb_helper_funcs);
664+
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
665+
if (!fb_helper)
666+
return;
667+
drm_fb_helper_prepare(dev, fb_helper, preferred_bpp, &intel_fb_helper_funcs);
661668

662-
ret = drm_client_init(dev, &ifbdev->helper.client, "intel-fbdev",
669+
ret = drm_client_init(dev, &fb_helper->client, "intel-fbdev",
663670
&intel_fbdev_client_funcs);
664671
if (ret) {
665672
drm_err(dev, "Failed to register client: %d\n", ret);
666673
goto err_drm_fb_helper_unprepare;
667674
}
668675

669-
drm_client_register(&ifbdev->helper.client);
676+
drm_client_register(&fb_helper->client);
670677

671678
return;
672679

673680
err_drm_fb_helper_unprepare:
674-
drm_fb_helper_unprepare(&ifbdev->helper);
675-
kfree(ifbdev);
681+
drm_fb_helper_unprepare(dev->fb_helper);
682+
kfree(fb_helper);
676683
}
677684

678685
struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev)
679686
{
680-
if (!fbdev || !fbdev->helper.fb)
687+
if (!fbdev)
681688
return NULL;
682689

683-
return to_intel_framebuffer(fbdev->helper.fb);
690+
return fbdev->fb;
684691
}
685692

686693
struct i915_vma *intel_fbdev_vma_pointer(struct intel_fbdev *fbdev)

0 commit comments

Comments
 (0)