intel_fbdev.c 17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * Copyright © 2007 David Airlie
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *     David Airlie
 */

27
#include <linux/async.h>
28
#include <linux/console.h>
29
#include <linux/delay.h>
30
#include <linux/errno.h>
31 32
#include <linux/init.h>
#include <linux/kernel.h>
33
#include <linux/mm.h>
34 35
#include <linux/module.h>
#include <linux/string.h>
36
#include <linux/sysrq.h>
37
#include <linux/tty.h>
38
#include <linux/vga_switcheroo.h>
39

40 41
#include <drm/drm_crtc.h>
#include <drm/drm_fb_helper.h>
42
#include <drm/drm_fourcc.h>
43
#include <drm/i915_drm.h>
44

45
#include "i915_drv.h"
46
#include "intel_display_types.h"
47
#include "intel_fbdev.h"
48
#include "intel_frontbuffer.h"
49

50
static struct intel_frontbuffer *to_frontbuffer(struct intel_fbdev *ifbdev)
51
{
52 53
	return ifbdev->fb->frontbuffer;
}
54

55 56 57
static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev)
{
	intel_frontbuffer_invalidate(to_frontbuffer(ifbdev), ORIGIN_CPU);
58 59
}

60 61 62 63 64 65 66 67
static int intel_fbdev_set_par(struct fb_info *info)
{
	struct drm_fb_helper *fb_helper = info->par;
	struct intel_fbdev *ifbdev =
		container_of(fb_helper, struct intel_fbdev, helper);
	int ret;

	ret = drm_fb_helper_set_par(info);
68 69
	if (ret == 0)
		intel_fbdev_invalidate(ifbdev);
70 71 72 73

	return ret;
}

74 75 76 77 78 79 80 81
static int intel_fbdev_blank(int blank, struct fb_info *info)
{
	struct drm_fb_helper *fb_helper = info->par;
	struct intel_fbdev *ifbdev =
		container_of(fb_helper, struct intel_fbdev, helper);
	int ret;

	ret = drm_fb_helper_blank(blank, info);
82 83
	if (ret == 0)
		intel_fbdev_invalidate(ifbdev);
84 85 86 87

	return ret;
}

88 89 90 91 92 93 94 95
static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,
				   struct fb_info *info)
{
	struct drm_fb_helper *fb_helper = info->par;
	struct intel_fbdev *ifbdev =
		container_of(fb_helper, struct intel_fbdev, helper);
	int ret;

96 97 98
	ret = drm_fb_helper_pan_display(var, info);
	if (ret == 0)
		intel_fbdev_invalidate(ifbdev);
99 100 101 102

	return ret;
}

103
static const struct fb_ops intelfb_ops = {
104
	.owner = THIS_MODULE,
105
	DRM_FB_HELPER_DEFAULT_OPS,
106
	.fb_set_par = intel_fbdev_set_par,
107 108 109
	.fb_fillrect = drm_fb_helper_cfb_fillrect,
	.fb_copyarea = drm_fb_helper_cfb_copyarea,
	.fb_imageblit = drm_fb_helper_cfb_imageblit,
110
	.fb_pan_display = intel_fbdev_pan_display,
111
	.fb_blank = intel_fbdev_blank,
112 113
};

114 115
static int intelfb_alloc(struct drm_fb_helper *helper,
			 struct drm_fb_helper_surface_size *sizes)
116
{
117 118
	struct intel_fbdev *ifbdev =
		container_of(helper, struct intel_fbdev, helper);
119
	struct drm_framebuffer *fb;
120
	struct drm_device *dev = helper->dev;
121
	struct drm_i915_private *dev_priv = to_i915(dev);
122
	struct drm_mode_fb_cmd2 mode_cmd = {};
123
	struct drm_i915_gem_object *obj;
124
	int size;
125

126
	/* we don't do packed 24bpp */
127 128
	if (sizes->surface_bpp == 24)
		sizes->surface_bpp = 32;
129

130 131
	mode_cmd.width = sizes->surface_width;
	mode_cmd.height = sizes->surface_height;
132

133 134
	mode_cmd.pitches[0] = ALIGN(mode_cmd.width *
				    DIV_ROUND_UP(sizes->surface_bpp, 8), 64);
135 136
	mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
							  sizes->surface_depth);
137

138
	size = mode_cmd.pitches[0] * mode_cmd.height;
139
	size = PAGE_ALIGN(size);
140 141 142 143

	/* If the FB is too big, just don't use it since fbdev is not very
	 * important and we should probably use that space with FBC or other
	 * features. */
144
	obj = ERR_PTR(-ENODEV);
145
	if (size * 2 < dev_priv->stolen_usable_size)
146
		obj = i915_gem_object_create_stolen(dev_priv, size);
147
	if (IS_ERR(obj))
148
		obj = i915_gem_object_create_shmem(dev_priv, size);
149
	if (IS_ERR(obj)) {
150
		DRM_ERROR("failed to allocate framebuffer\n");
151
		return PTR_ERR(obj);
152 153
	}

154
	fb = intel_framebuffer_create(obj, &mode_cmd);
155 156 157
	i915_gem_object_put(obj);
	if (IS_ERR(fb))
		return PTR_ERR(fb);
158

159
	ifbdev->fb = to_intel_framebuffer(fb);
160 161 162 163 164 165 166 167
	return 0;
}

static int intelfb_create(struct drm_fb_helper *helper,
			  struct drm_fb_helper_surface_size *sizes)
{
	struct intel_fbdev *ifbdev =
		container_of(helper, struct intel_fbdev, helper);
168
	struct intel_framebuffer *intel_fb = ifbdev->fb;
169
	struct drm_device *dev = helper->dev;
170
	struct drm_i915_private *dev_priv = to_i915(dev);
David Weinehall's avatar
David Weinehall committed
171
	struct pci_dev *pdev = dev_priv->drm.pdev;
172
	struct i915_ggtt *ggtt = &dev_priv->ggtt;
173 174 175
	const struct i915_ggtt_view view = {
		.type = I915_GGTT_VIEW_NORMAL,
	};
176 177
	intel_wakeref_t wakeref;
	struct fb_info *info;
178
	struct i915_vma *vma;
179
	unsigned long flags = 0;
180
	bool prealloc = false;
181
	void __iomem *vaddr;
182
	int ret;
183

184 185 186 187 188 189 190
	if (intel_fb &&
	    (sizes->fb_width > intel_fb->base.width ||
	     sizes->fb_height > intel_fb->base.height)) {
		DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
			      " releasing it\n",
			      intel_fb->base.width, intel_fb->base.height,
			      sizes->fb_width, sizes->fb_height);
191
		drm_framebuffer_put(&intel_fb->base);
192 193
		intel_fb = ifbdev->fb = NULL;
	}
194
	if (!intel_fb || drm_WARN_ON(dev, !intel_fb_obj(&intel_fb->base))) {
195
		DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
196 197
		ret = intelfb_alloc(helper, sizes);
		if (ret)
198
			return ret;
199
		intel_fb = ifbdev->fb;
200
	} else {
201
		DRM_DEBUG_KMS("re-using BIOS fb\n");
202
		prealloc = true;
203 204 205 206
		sizes->fb_width = intel_fb->base.width;
		sizes->fb_height = intel_fb->base.height;
	}

207
	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
208

209 210 211 212
	/* Pin the GGTT vma for our access via info->screen_base.
	 * This also validates that any existing fb inherited from the
	 * BIOS is suitable for own access.
	 */
213
	vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base,
214
					 &view, false, &flags);
Chris Wilson's avatar
Chris Wilson committed
215 216
	if (IS_ERR(vma)) {
		ret = PTR_ERR(vma);
217
		goto out_unlock;
Chris Wilson's avatar
Chris Wilson committed
218
	}
219

220
	intel_frontbuffer_flush(to_frontbuffer(ifbdev), ORIGIN_DIRTYFB);
221

222 223
	info = drm_fb_helper_alloc_fbi(helper);
	if (IS_ERR(info)) {
224
		DRM_ERROR("Failed to allocate fb_info\n");
225
		ret = PTR_ERR(info);
226
		goto out_unpin;
227 228
	}

229
	ifbdev->helper.fb = &ifbdev->fb->base;
230

231 232
	info->fbops = &intelfb_ops;

233
	/* setup aperture base/size for vesafb takeover */
234
	info->apertures->ranges[0].base = ggtt->gmadr.start;
235
	info->apertures->ranges[0].size = ggtt->mappable_end;
236

237 238 239 240 241
	/* Our framebuffer is the entirety of fbdev's system memory */
	info->fix.smem_start =
		(unsigned long)(ggtt->gmadr.start + vma->node.start);
	info->fix.smem_len = vma->node.size;

242 243
	vaddr = i915_vma_pin_iomap(vma);
	if (IS_ERR(vaddr)) {
244
		DRM_ERROR("Failed to remap framebuffer into virtual memory\n");
245
		ret = PTR_ERR(vaddr);
246
		goto out_unpin;
247
	}
248 249
	info->screen_base = vaddr;
	info->screen_size = vma->node.size;
250

251
	drm_fb_helper_fill_info(info, &ifbdev->helper, sizes);
252

253 254 255 256
	/* If the object is shmemfs backed, it will have given us zeroed pages.
	 * If the object is stolen however, it will be full of whatever
	 * garbage was left in there.
	 */
257
	if (vma->obj->stolen && !prealloc)
258 259
		memset_io(info->screen_base, 0, info->screen_size);

260
	/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
261

262
	DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08x\n",
263 264
		      ifbdev->fb->base.width, ifbdev->fb->base.height,
		      i915_ggtt_offset(vma));
Chris Wilson's avatar
Chris Wilson committed
265
	ifbdev->vma = vma;
266
	ifbdev->vma_flags = flags;
267

268
	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
David Weinehall's avatar
David Weinehall committed
269
	vga_switcheroo_client_fb_set(pdev, info);
270 271
	return 0;

272
out_unpin:
273
	intel_unpin_fb_vma(vma, flags);
274
out_unlock:
275
	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
276 277 278
	return ret;
}

279
static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
280
	.fb_probe = intelfb_create,
281
};
282

283
static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
284
{
285 286 287 288
	/* We rely on the object-free to release the VMA pinning for
	 * the info->screen_base mmaping. Leaking the VMA is simpler than
	 * trying to rectify all the possible error paths leading here.
	 */
289

290
	drm_fb_helper_fini(&ifbdev->helper);
291

292
	if (ifbdev->vma)
293
		intel_unpin_fb_vma(ifbdev->vma, ifbdev->vma_flags);
294

295
	if (ifbdev->fb)
296
		drm_framebuffer_remove(&ifbdev->fb->base);
297 298

	kfree(ifbdev);
299
}
300

301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
/*
 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
 * The core display code will have read out the current plane configuration,
 * so we use that to figure out if there's an object for us to use as the
 * fb, and if so, we re-use it for the fbdev configuration.
 *
 * Note we only support a single fb shared across pipes for boot (mostly for
 * fbcon), so we just find the biggest and use that.
 */
static bool intel_fbdev_init_bios(struct drm_device *dev,
				 struct intel_fbdev *ifbdev)
{
	struct intel_framebuffer *fb = NULL;
	struct drm_crtc *crtc;
	struct intel_crtc *intel_crtc;
	unsigned int max_size = 0;

	/* Find the largest fb */
319
	for_each_crtc(dev, crtc) {
320 321
		struct drm_i915_gem_object *obj =
			intel_fb_obj(crtc->primary->state->fb);
322 323
		intel_crtc = to_intel_crtc(crtc);

324
		if (!crtc->state->active || !obj) {
325 326 327 328 329
			DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
				      pipe_name(intel_crtc->pipe));
			continue;
		}

330
		if (obj->base.size > max_size) {
331 332
			DRM_DEBUG_KMS("found possible fb from plane %c\n",
				      pipe_name(intel_crtc->pipe));
333 334
			fb = to_intel_framebuffer(crtc->primary->state->fb);
			max_size = obj->base.size;
335 336 337 338 339 340 341 342 343
		}
	}

	if (!fb) {
		DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n");
		goto out;
	}

	/* Now make sure all the pipes will fit into it */
344
	for_each_crtc(dev, crtc) {
345 346 347 348
		unsigned int cur_size;

		intel_crtc = to_intel_crtc(crtc);

349
		if (!crtc->state->active) {
350 351 352 353 354 355 356 357 358 359
			DRM_DEBUG_KMS("pipe %c not active, skipping\n",
				      pipe_name(intel_crtc->pipe));
			continue;
		}

		DRM_DEBUG_KMS("checking plane %c for BIOS fb\n",
			      pipe_name(intel_crtc->pipe));

		/*
		 * See if the plane fb we found above will fit on this
360 361
		 * pipe.  Note we need to use the selected fb's pitch and bpp
		 * rather than the current pipe's, since they differ.
362
		 */
363
		cur_size = crtc->state->adjusted_mode.crtc_hdisplay;
364
		cur_size = cur_size * fb->base.format->cpp[0];
365 366 367 368 369 370 371 372
		if (fb->base.pitches[0] < cur_size) {
			DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
				      pipe_name(intel_crtc->pipe),
				      cur_size, fb->base.pitches[0]);
			fb = NULL;
			break;
		}

373
		cur_size = crtc->state->adjusted_mode.crtc_vdisplay;
374
		cur_size = intel_fb_align_height(&fb->base, 0, cur_size);
375 376 377
		cur_size *= fb->base.pitches[0];
		DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
			      pipe_name(intel_crtc->pipe),
378 379
			      crtc->state->adjusted_mode.crtc_hdisplay,
			      crtc->state->adjusted_mode.crtc_vdisplay,
380
			      fb->base.format->cpp[0] * 8,
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
			      cur_size);

		if (cur_size > max_size) {
			DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
				      pipe_name(intel_crtc->pipe),
				      cur_size, max_size);
			fb = NULL;
			break;
		}

		DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n",
			      pipe_name(intel_crtc->pipe),
			      max_size, cur_size);
	}

	if (!fb) {
		DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
		goto out;
	}

401
	ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8;
402 403
	ifbdev->fb = fb;

404
	drm_framebuffer_get(&ifbdev->fb->base);
405 406

	/* Final pass to check if any active pipes don't have fbs */
407
	for_each_crtc(dev, crtc) {
408 409
		intel_crtc = to_intel_crtc(crtc);

410
		if (!crtc->state->active)
411 412
			continue;

413 414 415
		drm_WARN(dev, !crtc->primary->state->fb,
			 "re-used BIOS config but lost an fb on crtc %d\n",
			 crtc->base.id);
416 417 418 419 420 421 422 423 424 425 426
	}


	DRM_DEBUG_KMS("using BIOS fb for initial console\n");
	return true;

out:

	return false;
}

427 428
static void intel_fbdev_suspend_worker(struct work_struct *work)
{
429 430 431
	intel_fbdev_set_suspend(&container_of(work,
					      struct drm_i915_private,
					      fbdev_suspend_work)->drm,
432 433 434 435
				FBINFO_STATE_RUNNING,
				true);
}

436 437
int intel_fbdev_init(struct drm_device *dev)
{
438
	struct drm_i915_private *dev_priv = to_i915(dev);
439
	struct intel_fbdev *ifbdev;
440
	int ret;
441

442 443
	if (drm_WARN_ON(dev, !HAS_DISPLAY(dev_priv) ||
			!INTEL_DISPLAY_ENABLED(dev_priv)))
444 445 446 447
		return -ENODEV;

	ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
	if (ifbdev == NULL)
448 449
		return -ENOMEM;

450
	mutex_init(&ifbdev->hpd_lock);
451 452
	drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs);

453 454
	if (!intel_fbdev_init_bios(dev, ifbdev))
		ifbdev->preferred_bpp = 32;
455

456
	ret = drm_fb_helper_init(dev, &ifbdev->helper);
457 458 459 460
	if (ret) {
		kfree(ifbdev);
		return ret;
	}
461

462
	dev_priv->fbdev = ifbdev;
463 464
	INIT_WORK(&dev_priv->fbdev_suspend_work, intel_fbdev_suspend_worker);

465 466
	return 0;
}
467

468
static void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
469
{
470
	struct intel_fbdev *ifbdev = data;
471 472

	/* Due to peculiar init order wrt to hpd handling this is separate. */
473
	if (drm_fb_helper_initial_config(&ifbdev->helper,
474
					 ifbdev->preferred_bpp))
475
		intel_fbdev_unregister(to_i915(ifbdev->helper.dev));
476 477
}

478 479
void intel_fbdev_initial_config_async(struct drm_device *dev)
{
480 481
	struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;

482 483 484
	if (!ifbdev)
		return;

485 486 487 488 489 490 491 492 493 494 495
	ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev);
}

static void intel_fbdev_sync(struct intel_fbdev *ifbdev)
{
	if (!ifbdev->cookie)
		return;

	/* Only serialises with all preceding async calls, hence +1 */
	async_synchronize_cookie(ifbdev->cookie + 1);
	ifbdev->cookie = 0;
496 497
}

498
void intel_fbdev_unregister(struct drm_i915_private *dev_priv)
499
{
500 501 502
	struct intel_fbdev *ifbdev = dev_priv->fbdev;

	if (!ifbdev)
503 504
		return;

505
	cancel_work_sync(&dev_priv->fbdev_suspend_work);
506
	if (!current_is_async())
507 508
		intel_fbdev_sync(ifbdev);

509 510 511 512 513 514 515 516 517 518
	drm_fb_helper_unregister_fbi(&ifbdev->helper);
}

void intel_fbdev_fini(struct drm_i915_private *dev_priv)
{
	struct intel_fbdev *ifbdev = fetch_and_zero(&dev_priv->fbdev);

	if (!ifbdev)
		return;

519
	intel_fbdev_destroy(ifbdev);
520
}
521

522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
/* Suspends/resumes fbdev processing of incoming HPD events. When resuming HPD
 * processing, fbdev will perform a full connector reprobe if a hotplug event
 * was received while HPD was suspended.
 */
static void intel_fbdev_hpd_set_suspend(struct intel_fbdev *ifbdev, int state)
{
	bool send_hpd = false;

	mutex_lock(&ifbdev->hpd_lock);
	ifbdev->hpd_suspended = state == FBINFO_STATE_SUSPENDED;
	send_hpd = !ifbdev->hpd_suspended && ifbdev->hpd_waiting;
	ifbdev->hpd_waiting = false;
	mutex_unlock(&ifbdev->hpd_lock);

	if (send_hpd) {
		DRM_DEBUG_KMS("Handling delayed fbcon HPD event\n");
		drm_fb_helper_hotplug_event(&ifbdev->helper);
	}
}

542
void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
543
{
544
	struct drm_i915_private *dev_priv = to_i915(dev);
545 546 547
	struct intel_fbdev *ifbdev = dev_priv->fbdev;
	struct fb_info *info;

548
	if (!ifbdev || !ifbdev->vma)
549 550
		return;

551 552
	info = ifbdev->helper.fbdev;

553 554 555 556 557 558 559 560 561 562
	if (synchronous) {
		/* Flush any pending work to turn the console on, and then
		 * wait to turn it off. It must be synchronous as we are
		 * about to suspend or unload the driver.
		 *
		 * Note that from within the work-handler, we cannot flush
		 * ourselves, so only flush outstanding work upon suspend!
		 */
		if (state != FBINFO_STATE_RUNNING)
			flush_work(&dev_priv->fbdev_suspend_work);
563

564 565 566 567 568 569 570
		console_lock();
	} else {
		/*
		 * The console lock can be pretty contented on resume due
		 * to all the printk activity.  Try to keep it out of the hot
		 * path of resume if possible.
		 */
571
		drm_WARN_ON(dev, state != FBINFO_STATE_RUNNING);
572 573 574 575 576 577 578 579 580
		if (!console_trylock()) {
			/* Don't block our own workqueue as this can
			 * be run in parallel with other i915.ko tasks.
			 */
			schedule_work(&dev_priv->fbdev_suspend_work);
			return;
		}
	}

581 582 583 584
	/* On resume from hibernation: If the object is shmemfs backed, it has
	 * been restored from swap. If the object is stolen however, it will be
	 * full of whatever garbage was left in there.
	 */
585 586
	if (state == FBINFO_STATE_RUNNING &&
	    intel_fb_obj(&ifbdev->fb->base)->stolen)
587 588
		memset_io(info->screen_base, 0, info->screen_size);

589
	drm_fb_helper_set_suspend(&ifbdev->helper, state);
590
	console_unlock();
591 592

	intel_fbdev_hpd_set_suspend(ifbdev, state);
593 594
}

595
void intel_fbdev_output_poll_changed(struct drm_device *dev)
596
{
597
	struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;
598
	bool send_hpd;
599

600 601 602 603
	if (!ifbdev)
		return;

	intel_fbdev_sync(ifbdev);
604 605 606 607 608 609 610

	mutex_lock(&ifbdev->hpd_lock);
	send_hpd = !ifbdev->hpd_suspended;
	ifbdev->hpd_waiting = true;
	mutex_unlock(&ifbdev->hpd_lock);

	if (send_hpd && (ifbdev->vma || ifbdev->helper.deferred_setup))
611
		drm_fb_helper_hotplug_event(&ifbdev->helper);
612
}
613

614
void intel_fbdev_restore_mode(struct drm_device *dev)
615
{
616
	struct intel_fbdev *ifbdev = to_i915(dev)->fbdev;
617

618
	if (!ifbdev)
619 620
		return;

621
	intel_fbdev_sync(ifbdev);
622
	if (!ifbdev->vma)
623
		return;
624

625 626
	if (drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper) == 0)
		intel_fbdev_invalidate(ifbdev);
627
}