Skip to content

Commit 194c9e2

Browse files
tdztomba
authored andcommitted
drm/omapdrm: Remove bo from struct omap_fbdev
Fbdev's framebuffer stores a pointer to the GEM object. Remove struct omap_fbdev.bo, which contains the same value. No functional changes. v2: * fix commit message (Tomi) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230403104035.15288-4-tzimmermann@suse.de
1 parent 38129bc commit 194c9e2

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

drivers/gpu/drm/omapdrm/omap_fbdev.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <drm/drm_file.h>
1111
#include <drm/drm_fourcc.h>
1212
#include <drm/drm_framebuffer.h>
13+
#include <drm/drm_gem_framebuffer_helper.h>
1314

1415
#include "omap_drv.h"
1516

@@ -25,7 +26,6 @@ module_param_named(ywrap, ywrap_enabled, bool, 0644);
2526

2627
struct omap_fbdev {
2728
struct drm_fb_helper base;
28-
struct drm_gem_object *bo;
2929
bool ywrap_enabled;
3030

3131
/* for deferred dmm roll when getting called in atomic ctx */
@@ -37,12 +37,14 @@ static struct drm_fb_helper *get_fb(struct fb_info *fbi);
3737
static void pan_worker(struct work_struct *work)
3838
{
3939
struct omap_fbdev *fbdev = container_of(work, struct omap_fbdev, work);
40-
struct fb_info *fbi = fbdev->base.info;
40+
struct drm_fb_helper *helper = &fbdev->base;
41+
struct fb_info *fbi = helper->info;
42+
struct drm_gem_object *bo = drm_gem_fb_get_obj(helper->fb, 0);
4143
int npages;
4244

4345
/* DMM roll shifts in 4K pages: */
4446
npages = fbi->fix.line_length >> PAGE_SHIFT;
45-
omap_gem_roll(fbdev->bo, fbi->var.yoffset * npages);
47+
omap_gem_roll(bo, fbi->var.yoffset * npages);
4648
}
4749

4850
static int omap_fbdev_pan_display(struct fb_var_screeninfo *var,
@@ -97,6 +99,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
9799
union omap_gem_size gsize;
98100
struct fb_info *fbi = NULL;
99101
struct drm_mode_fb_cmd2 mode_cmd = {0};
102+
struct drm_gem_object *bo;
100103
dma_addr_t dma_addr;
101104
int ret;
102105

@@ -127,20 +130,20 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
127130
.bytes = PAGE_ALIGN(mode_cmd.pitches[0] * mode_cmd.height),
128131
};
129132
DBG("allocating %d bytes for fb %d", gsize.bytes, dev->primary->index);
130-
fbdev->bo = omap_gem_new(dev, gsize, OMAP_BO_SCANOUT | OMAP_BO_WC);
131-
if (!fbdev->bo) {
133+
bo = omap_gem_new(dev, gsize, OMAP_BO_SCANOUT | OMAP_BO_WC);
134+
if (!bo) {
132135
dev_err(dev->dev, "failed to allocate buffer object\n");
133136
ret = -ENOMEM;
134137
goto fail;
135138
}
136139

137-
fb = omap_framebuffer_init(dev, &mode_cmd, &fbdev->bo);
140+
fb = omap_framebuffer_init(dev, &mode_cmd, &bo);
138141
if (IS_ERR(fb)) {
139142
dev_err(dev->dev, "failed to allocate fb\n");
140143
/* note: if fb creation failed, we can't rely on fb destroy
141144
* to unref the bo:
142145
*/
143-
drm_gem_object_put(fbdev->bo);
146+
drm_gem_object_put(bo);
144147
ret = PTR_ERR(fb);
145148
goto fail;
146149
}
@@ -153,7 +156,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
153156
* to it). Then we just need to be sure that we are able to re-
154157
* pin it in case of an opps.
155158
*/
156-
ret = omap_gem_pin(fbdev->bo, &dma_addr);
159+
ret = omap_gem_pin(bo, &dma_addr);
157160
if (ret) {
158161
dev_err(dev->dev, "could not pin framebuffer\n");
159162
ret = -ENOMEM;
@@ -175,10 +178,10 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
175178

176179
drm_fb_helper_fill_info(fbi, helper, sizes);
177180

178-
fbi->screen_buffer = omap_gem_vaddr(fbdev->bo);
179-
fbi->screen_size = fbdev->bo->size;
181+
fbi->screen_buffer = omap_gem_vaddr(bo);
182+
fbi->screen_size = bo->size;
180183
fbi->fix.smem_start = dma_addr;
181-
fbi->fix.smem_len = fbdev->bo->size;
184+
fbi->fix.smem_len = bo->size;
182185

183186
/* if we have DMM, then we can use it for scrolling by just
184187
* shuffling pages around in DMM rather than doing sw blit.
@@ -265,6 +268,7 @@ void omap_fbdev_fini(struct drm_device *dev)
265268
struct omap_drm_private *priv = dev->dev_private;
266269
struct drm_fb_helper *helper = priv->fbdev;
267270
struct drm_framebuffer *fb;
271+
struct drm_gem_object *bo;
268272
struct omap_fbdev *fbdev;
269273

270274
DBG();
@@ -280,9 +284,11 @@ void omap_fbdev_fini(struct drm_device *dev)
280284

281285
fbdev = to_omap_fbdev(helper);
282286

287+
bo = drm_gem_fb_get_obj(fb, 0);
288+
283289
/* unpin the GEM object pinned in omap_fbdev_create() */
284-
if (fbdev->bo)
285-
omap_gem_unpin(fbdev->bo);
290+
if (bo)
291+
omap_gem_unpin(bo);
286292

287293
/* this will free the backing object */
288294
if (fb)

0 commit comments

Comments
 (0)