Skip to content

Commit ea2f45a

Browse files
Saurabh Sengarliuw
authored andcommitted
fbdev: hyperv_fb: Allow graceful removal of framebuffer
When a Hyper-V framebuffer device is unbind, hyperv_fb driver tries to release the framebuffer forcefully. If this framebuffer is in use it produce the following WARN and hence this framebuffer is never released. [ 44.111220] WARNING: CPU: 35 PID: 1882 at drivers/video/fbdev/core/fb_info.c:70 framebuffer_release+0x2c/0x40 < snip > [ 44.111289] Call Trace: [ 44.111290] <TASK> [ 44.111291] ? show_regs+0x6c/0x80 [ 44.111295] ? __warn+0x8d/0x150 [ 44.111298] ? framebuffer_release+0x2c/0x40 [ 44.111300] ? report_bug+0x182/0x1b0 [ 44.111303] ? handle_bug+0x6e/0xb0 [ 44.111306] ? exc_invalid_op+0x18/0x80 [ 44.111308] ? asm_exc_invalid_op+0x1b/0x20 [ 44.111311] ? framebuffer_release+0x2c/0x40 [ 44.111313] ? hvfb_remove+0x86/0xa0 [hyperv_fb] [ 44.111315] vmbus_remove+0x24/0x40 [hv_vmbus] [ 44.111323] device_remove+0x40/0x80 [ 44.111325] device_release_driver_internal+0x20b/0x270 [ 44.111327] ? bus_find_device+0xb3/0xf0 Fix this by moving the release of framebuffer and assosiated memory to fb_ops.fb_destroy function, so that framebuffer framework handles it gracefully. While we fix this, also replace manual registrations/unregistration of framebuffer with devm_register_framebuffer. Fixes: 68a2d20 ("drivers/video: add Hyper-V Synthetic Video Frame Buffer Driver") Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Tested-by: Michael Kelley <mhklinux@outlook.com> Link: https://lore.kernel.org/r/1740845791-19977-3-git-send-email-ssengar@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <1740845791-19977-3-git-send-email-ssengar@linux.microsoft.com>
1 parent f5e728a commit ea2f45a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/video/fbdev/hyperv_fb.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ static uint screen_depth;
282282
static uint screen_fb_size;
283283
static uint dio_fb_size; /* FB size for deferred IO */
284284

285+
static void hvfb_putmem(struct fb_info *info);
286+
285287
/* Send message to Hyper-V host */
286288
static inline int synthvid_send(struct hv_device *hdev,
287289
struct synthvid_msg *msg)
@@ -862,6 +864,17 @@ static void hvfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width,
862864
hvfb_ondemand_refresh_throttle(par, x, y, width, height);
863865
}
864866

867+
/*
868+
* fb_ops.fb_destroy is called by the last put_fb_info() call at the end
869+
* of unregister_framebuffer() or fb_release(). Do any cleanup related to
870+
* framebuffer here.
871+
*/
872+
static void hvfb_destroy(struct fb_info *info)
873+
{
874+
hvfb_putmem(info);
875+
framebuffer_release(info);
876+
}
877+
865878
/*
866879
* TODO: GEN1 codepaths allocate from system or DMA-able memory. Fix the
867880
* driver to use the _SYSMEM_ or _DMAMEM_ helpers in these cases.
@@ -877,6 +890,7 @@ static const struct fb_ops hvfb_ops = {
877890
.fb_set_par = hvfb_set_par,
878891
.fb_setcolreg = hvfb_setcolreg,
879892
.fb_blank = hvfb_blank,
893+
.fb_destroy = hvfb_destroy,
880894
};
881895

882896
/* Get options from kernel paramenter "video=" */
@@ -1178,7 +1192,7 @@ static int hvfb_probe(struct hv_device *hdev,
11781192
if (ret)
11791193
goto error;
11801194

1181-
ret = register_framebuffer(info);
1195+
ret = devm_register_framebuffer(&hdev->device, info);
11821196
if (ret) {
11831197
pr_err("Unable to register framebuffer\n");
11841198
goto error;
@@ -1226,14 +1240,10 @@ static void hvfb_remove(struct hv_device *hdev)
12261240

12271241
fb_deferred_io_cleanup(info);
12281242

1229-
unregister_framebuffer(info);
12301243
cancel_delayed_work_sync(&par->dwork);
12311244

12321245
vmbus_close(hdev->channel);
12331246
hv_set_drvdata(hdev, NULL);
1234-
1235-
hvfb_putmem(info);
1236-
framebuffer_release(info);
12371247
}
12381248

12391249
static int hvfb_suspend(struct hv_device *hdev)

0 commit comments

Comments
 (0)