Wrap fb objects from BIOS/bootloader
Subsystems (2)
There was a TODO from last time that Daniel and I talked about:
- reconstruct fb state in our get_config callbacks instead
- reconstruct per-crtc fb state and allocate separate buffers if needed
- make sure we only preserve the buffer if it's the preferred mode
Just wanted to get this refreshed version out there to get some eyes on it.
Thanks,
Jesse
PATCH 1/1 drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v4
Retrieve current framebuffer config info from the regs and create an fb object for the buffer the BIOS or boot loader left us. This should allow for smooth transitions to userspace apps once we finish the initial configuration construction.
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref if init_bios fails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path for pin_and_fence (Imre)
v3: fixup fixup of aperture frees (Chris)
v4: update to current bits (locking & pin_and_fence hack) (Jesse)
--- drivers/gpu/drm/i915/i915_dma.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_display.c | 14 +- drivers/gpu/drm/i915/intel_drv.h | 4 + drivers/gpu/drm/i915/intel_fbdev.c | 295 +++++++++++++++++++++++++++++++++-- 5 files changed, 308 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +7 -1
@@ -1277,6 +1277,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {static int i915_load_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_vga_enabled;int ret; ret =intel_parse_bios (dev);
@@ -1315,7 +1316,11 @@ static int i915_load_modeset_init(struct drm_device *dev)/* Important: The output setup functions called by modeset_init need * working irqs for e.g. gmbus and dp aux transfers. */ -intel_modeset_init (dev); +intel_modeset_init (dev, &was_vga_enabled); + +/* Wrap existing BIOS mode configuration prior to GEM takeover */ +if (!was_vga_enabled) +intel_fbdev_init_bios (dev); ret =i915_gem_init (dev);if (ret)
@@ -1333,6 +1338,7 @@ static int i915_load_modeset_init(struct drm_device *dev)return 0 ; } +/* Install a default KMS/GEM fbcon if we failed to wrap the BIOS fb */ ret =intel_fbdev_init (dev);if (ret) goto cleanup_gem;
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -2372,7 +2372,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }/* modesetting */ extern void intel_modeset_init_hw (struct drm_device *dev);extern void intel_modeset_suspend_hw (struct drm_device *dev); -extern void intel_modeset_init (struct drm_device *dev); +extern void intel_modeset_init (struct drm_device *dev,bool *was_vga_enabled);extern void intel_modeset_gem_init (struct drm_device *dev);extern void intel_modeset_cleanup (struct drm_device *dev);extern int intel_modeset_vga_set_state (struct drm_device *dev,bool state);
drivers/gpu/drm/i915/intel_display.c +11 -3
@@ -10735,12 +10735,17 @@ static void intel_init_quirks(struct drm_device *dev) }/* Disable the VGA plane that we never use */ -static void i915_disable_vga (struct drm_device *dev) +static bool i915_disable_vga (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_enabled;u8 sr1;u32 vga_reg =i915_vgacntrl_reg (dev); + was_enabled = !(I915_READ (vga_reg) &VGA_DISP_DISABLE ); +DRM_DEBUG_KMS ("VGA output is currently %s\n" , + was_enabled ?"enabled" :"disabled" ); +vga_get_uninterruptible (dev->pdev,VGA_RSRC_LEGACY_IO );outb (SR01 ,VGA_SR_INDEX ); sr1 =inb (VGA_SR_DATA );
@@ -10750,6 +10755,8 @@ static void i915_disable_vga(struct drm_device *dev)I915_WRITE (vga_reg,VGA_DISP_DISABLE );POSTING_READ (vga_reg); + +return was_enabled; }void intel_modeset_init_hw (struct drm_device *dev)
@@ -10777,7 +10784,8 @@ void intel_modeset_suspend_hw(struct drm_device *dev)intel_suspend_hw (dev); } -void intel_modeset_init (struct drm_device *dev) +void intel_modeset_init (struct drm_device *dev, +bool *was_vga_enabled) {struct drm_i915_private *dev_priv = dev->dev_private;int i, j, ret;
@@ -10831,7 +10839,7 @@ void intel_modeset_init(struct drm_device *dev)intel_shared_dpll_init (dev);/* Just disable it once at startup */ -i915_disable_vga (dev); + *was_vga_enabled =i915_disable_vga (dev);intel_setup_outputs (dev);/* Just in case the BIOS is doing something questionable. */
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -113,6 +113,8 @@ struct intel_fbdev {struct intel_framebuffer ifb;struct list_head fbdev_list;struct drm_display_mode *our_mode; +bool stolen; +int preferred_bpp; };struct intel_encoder {
@@ -320,6 +322,7 @@ struct intel_crtc {enum pipe pipe;enum plane plane;u8 lut_r[256 ], lut_g[256 ], lut_b[256 ]; +bool mode_valid;/* * Whether the crtc and the connected output pipeline is active. Implies * that crtc->enabled is set, i.e. the current mode configuration has
@@ -652,6 +655,7 @@ int intel_framebuffer_init(struct drm_device *dev,struct intel_framebuffer *ifb, struct drm_mode_fb_cmd2 *mode_cmd, struct drm_i915_gem_object *obj); +void intel_fbdev_init_bios (struct drm_device *dev);void intel_framebuffer_fini (struct intel_framebuffer *fb);void intel_prepare_page_flip (struct drm_device *dev,int plane);void intel_finish_page_flip (struct drm_device *dev,int pipe);
drivers/gpu/drm/i915/intel_fbdev.c +285 -10
347 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Re: [PATCH] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v4
Quoted 5 lines · Jesse Barnes
Retrieve current framebuffer config info from the regs and create an fb object for the buffer the BIOS or boot loader left us. This should allow for smooth transitions to userspace apps once we finish the initial configuration construction.
Quoted 7 lines
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref ifinit_biosfails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path forpin_and_fence(Imre)
v3: fixup fixup of aperture frees (Chris)
v4: update to current bits (locking &pin_and_fencehack) (Jesse)
The only thing that I noticed was that the bookkeeping for the fb/obj is incorrect - which is presumably the hack mentioned above. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v4
Quoted 14 lines · On Thu, 7 Nov 2013 14:22:55 +0000 Chris Wilson <[email protected]> wrote:
Quoted 5 lines · Jesse Barnes
Retrieve current framebuffer config info from the regs and create an fb object for the buffer the BIOS or boot loader left us. This should allow for smooth transitions to userspace apps once we finish the initial configuration construction.
Quoted 7 lines
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref ifinit_biosfails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path forpin_and_fence(Imre)
v3: fixup fixup of aperture frees (Chris)
v4: update to current bits (locking &pin_and_fencehack) (Jesse)
Quoted 2 lines
The only thing that I noticed was that the bookkeeping for the fb/obj is incorrect - which is presumably the hack mentioned above.
Yeah I should have left the pin_and_fence in with an #if 0 to make that clearer... is that the only thing that's missing?
Any thoughts on why the pin_and_fence falls over on the preallocated object?
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Re: [PATCH] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v4
In reply to Jesse BarnesQuoted 35 lines · Jesse Barnes
Retrieve current framebuffer config info from the regs and create an fb object for the buffer the BIOS or boot loader left us. This should allow for smooth transitions to userspace apps once we finish the initial configuration construction.
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref ifinit_biosfails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path forpin_and_fence(Imre)
v3: fixup fixup of aperture frees (Chris)
v4: update to current bits (locking &pin_and_fencehack) (Jesse)Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/i915_dma.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_display.c | 14 +- drivers/gpu/drm/i915/intel_drv.h | 4 + drivers/gpu/drm/i915/intel_fbdev.c | 295 +++++++++++++++++++++++++++++++++-- 5 files changed, 308 insertions(+), 15 deletions(-)drivers/gpu/drm/i915/i915_dma.c +1
-0@@ -1277,6 +1277,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {static int i915_load_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_vga_enabled;int ret; ret =intel_parse_bios (dev);
drivers/gpu/drm/i915/i915_dma.c static int i915_load_modeset_init(struct drm_device *dev) · line 1323
Quoted 9 lines
drivers/gpu/drm/i915/i915_dma.c +5
-1@@ -1315,7 +1316,11 @@ static int i915_load_modeset_init(struct drm_device *dev)/* Important: The output setup functions called by modeset_init need * working irqs for e.g. gmbus and dp aux transfers. */ -intel_modeset_init (dev); +intel_modeset_init (dev, &was_vga_enabled); + +/* Wrap existing BIOS mode configuration prior to GEM takeover */ +if (!was_vga_enabled) +intel_fbdev_init_bios (dev);
We attempt to pin into the GTT here, but...
drivers/gpu/drm/i915/i915_dma.c static int i915_load_modeset_init(struct drm_device *dev) · line 1325
Quoted 1 line
drivers/gpu/drm/i915/i915_dma.c +0
-0ret =i915_gem_init (dev);
GTT drm_mm range manager is only now initialised.
That would seem to explain an oops in drm_mm.c
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 1/1 drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v5
In reply to Jesse BarnesRetrieve current framebuffer config info from the regs and create an fb object for the buffer the BIOS or boot loader left us. This should allow for smooth transitions to userspace apps once we finish the initial configuration construction.
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref if init_bios fails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path for pin_and_fence (Imre)
v3: fixup fixup of aperture frees (Chris)
v4: update to current bits (locking & pin_and_fence hack) (Jesse)
v5: move fb config fetch to display code (Jesse)
re-order hw state readout on initial load to suit fb inherit (Jesse) re-add pin_and_fence in fbdev code to make sure we refcount properly (Jesse)
--- drivers/gpu/drm/i915/i915_dma.c | 4 - drivers/gpu/drm/i915/i915_drv.c | 5 ++ drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_display.c | 139 +++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_dp.c | 2 +- drivers/gpu/drm/i915/intel_drv.h | 14 ++++ drivers/gpu/drm/i915/intel_fbdev.c | 149 +++++++---------------------------- 7 files changed, 176 insertions(+), 139 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +0 -4
@@ -1318,10 +1318,6 @@ static int i915_load_modeset_init(struct drm_device *dev)* working irqs for e.g. gmbus and dp aux transfers. */ intel_modeset_init (dev, &was_vga_enabled); -/* Wrap existing BIOS mode configuration prior to GEM takeover */ -if (!was_vga_enabled) -intel_fbdev_init_bios (dev); - ret =i915_gem_init (dev);if (ret) goto cleanup_power;
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -154,6 +154,11 @@ module_param_named(prefault_disable, i915_prefault_disable, bool, 0600);MODULE_PARM_DESC (prefault_disable,"Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only." ); +bool i915_use_bios_fb__read_mostly =1 ; +module_param_named (use_bios_fb, i915_use_bios_fb, bool,0600 ); +MODULE_PARM_DESC (use_bios_fb, +"Use BIOS allocated framebuffer for fbcon (default: true)" ); +static struct drm_driver driver;extern int intel_agp_enabled;
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -390,6 +390,7 @@ struct drm_i915_display_funcs {* fills out the pipe-config with the hw state. */ bool (*get_pipe_config)(struct intel_crtc *,struct intel_crtc_config *); +void (*get_fb_config)(struct intel_crtc *,struct intel_crtc_config *);int (*crtc_mode_set)(struct drm_crtc *crtc,int x,int y,struct drm_framebuffer *old_fb);
@@ -1861,6 +1862,7 @@ extern bool i915_fastboot __read_mostly;extern int i915_enable_pc8__read_mostly ;extern int i915_pc8_timeout__read_mostly ;extern bool i915_prefault_disable__read_mostly ; +extern bool i915_use_bios_fb__read_mostly ;extern int i915_suspend (struct drm_device *dev,pm_message_t state);extern int i915_resume (struct drm_device *dev);
drivers/gpu/drm/i915/intel_display.c +127 -12
201 lines not on this page · raw message
drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -1230,7 +1230,7 @@ void ironlake_edp_panel_off(struct intel_dp *intel_dp)WARN (!intel_dp->want_panel_vdd,"Need VDD to turn off panel\n" ); pp =ironlake_get_pp_control (intel_dp); - pp &= ~(POWER_TARGET_ON |PANEL_POWER_RESET |EDP_BLC_ENABLE ); + pp &= ~(POWER_TARGET_ON |EDP_FORCE_VDD |PANEL_POWER_RESET |EDP_BLC_ENABLE ); pp_ctrl_reg =_pp_ctrl_reg (intel_dp);
drivers/gpu/drm/i915/intel_drv.h +14 -0
@@ -200,6 +200,17 @@ typedef struct dpll {int p; } intel_clock_t; +struct intel_fb_config { +int pixel_format;/* DRM fourcc code */ +int bpp; +bool tiled; +int base, offset; +int fb_width, fb_height; +int pipe_width, pipe_height; +int pitch; +struct drm_i915_gem_object *obj; +}; +struct intel_crtc_config {/** * quirks - bitfield with hw state readout quirks
@@ -222,6 +233,8 @@ struct intel_crtc_config {* registers. adjusted_mode.crtc_clock is the pipe pixel clock. */ struct drm_display_mode adjusted_mode; +struct intel_fb_config fb_config; +/* Pipe source size (ie. panel fitter input size) * All planes will be positioned inside this space, * and get clipped at the edges. */
@@ -699,6 +712,7 @@ void hsw_enable_ips(struct intel_crtc *crtc);void hsw_disable_ips (struct intel_crtc *crtc);void intel_display_set_init_power (struct drm_device *dev,bool enable);int valleyview_get_vco (struct drm_i915_private *dev_priv); +int intel_format_to_fourcc (int format);/* intel_dp.c */ void intel_dp_init (struct drm_device *dev,int output_reg,enum port port);
drivers/gpu/drm/i915/intel_fbdev.c +27 -122
202 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Re: [PATCH] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v5
Note that with this patch I see this on boot when the preallocated objects are scanned:
[ 3.951078] WARNING: CPU: 1 PID: 398 at lib/list_debug.c:36 __list_add+0x8a/0 xc0() [ 3.951081] list_add double add: new=ffff88003fa42ba8, prev=ffff88003f9903c0, next=ffff88003fa42ba8. [ 3.951083] Modules linked in: coretemp snd_hda_intel(+) kvm_intel kvm vfat f
at i915(OF+) snd_hda_codec snd_hwdep crc32_pclmul snd_seq crc32c_intel snd_seq_d evice snd_pcm ghash_clmulni_intel microcode snd_page_alloc snd_timer snd asix se rio_raw soundcore usbnet shpchp mii i2c_algo_bit drm_kms_helper(OF) drm(OF) i2c_ core sdhci_acpi video nfsd sdhci mmc_core acpi_cpufreq auth_rpcgss nfs_acl lockd
sunrpc usb_storage
[ 3.951122] CPU: 1 PID: 398 Comm: systemd-udevd Tainted: GF W O 3.12.0+ #8 [ 3.951125] Hardware name: Intel Corp. VALLEYVIEW B3 PLATFORM/NOTEBOOK, BIOS BBAYCRB1.X64.0060.R40.1309121618 BBAY_X64_R_V60_40 09/12/2013 [ 3.951127] 0000000000000009 ffff88003ffd3790 ffffffff81640eb8 ffff88003ffd37d8 [ 3.951132] ffff88003ffd37c8 ffffffff810680dd ffff88003fa42ba8 ffff88003fa42ba8 [ 3.951136] ffff88003f9903c0 ffff8800752ce870 ffff88003f990300 ffff88003ffd3828 [ 3.951140] Call Trace: [ 3.951148] [<ffffffff81640eb8>] dump_stack+0x45/0x56 [ 3.951154] [<ffffffff810680dd>] warn_slowpath_common+0x7d/0xa0 [ 3.951158] [<ffffffff8106814c>] warn_slowpath_fmt+0x4c/0x50 [ 3.951178] [<ffffffffa01313f5>] ? drm_mm_reserve_node+0xe5/0x170 [drm] [ 3.951199] [<ffffffff8130e6ea>] __list_add+0x8a/0xc0 [ 3.951230] [<ffffffffa02863a0>] i915_gem_setup_global_gtt+0xc0/0x280 [i915] [ 3.951256] [<ffffffffa02869a4>] i915_gem_init_global_gtt+0x444/0x980 [i915] [ 3.951280] [<ffffffffa0290f38>] ? i9xx_get_fb_config+0x268/0x370 [i915] [ 3.951304] [<ffffffffa027c2a2>] i915_gem_init+0x42/0x180 [i915] [ 3.951324] [<ffffffffa0266080>] i915_driver_load+0xc50/0xf10 [i915]
...
So something is still off with the block management of stolen objects in this patch...
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center