Skip to content

Commit da091af

Browse files
Jocelyn FalempeMaarten Lankhorst
authored andcommitted
drm/i915: Add intel_bo_alloc_framebuffer()
Encapsulate the struct intel_framebuffer into an xe_framebuffer or i915_framebuffer, and allow to add specific fields for each variant for the panic use-case. This is particularly needed to have a struct xe_res_cursor available to support drm panic on discrete GPU. Signed-off-by: Jocelyn Falempe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maarten Lankhorst <[email protected]>
1 parent 718370f commit da091af

File tree

8 files changed

+60
-3
lines changed

8 files changed

+60
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "i9xx_plane.h"
1616
#include "i9xx_plane_regs.h"
1717
#include "intel_atomic.h"
18+
#include "intel_bo.h"
1819
#include "intel_de.h"
1920
#include "intel_display_irq.h"
2021
#include "intel_display_regs.h"
@@ -1174,7 +1175,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
11741175

11751176
drm_WARN_ON(display->drm, pipe != crtc->pipe);
11761177

1177-
intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
1178+
intel_fb = intel_bo_alloc_framebuffer();
11781179
if (!intel_fb) {
11791180
drm_dbg_kms(display->drm, "failed to alloc fb\n");
11801181
return;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
/* Copyright © 2024 Intel Corporation */
33

4+
#include "display/intel_display_types.h"
45
#include "gem/i915_gem_mman.h"
56
#include "gem/i915_gem_object.h"
67
#include "gem/i915_gem_object_frontbuffer.h"
@@ -57,3 +58,8 @@ void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj)
5758
{
5859
i915_debugfs_describe_obj(m, to_intel_bo(obj));
5960
}
61+
62+
struct intel_framebuffer *intel_bo_alloc_framebuffer(void)
63+
{
64+
return i915_gem_object_alloc_framebuffer();
65+
}

drivers/gpu/drm/i915/display/intel_bo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/types.h>
88

99
struct drm_gem_object;
10+
struct intel_framebuffer;
1011
struct seq_file;
1112
struct vm_area_struct;
1213

@@ -23,5 +24,6 @@ struct intel_frontbuffer *intel_bo_set_frontbuffer(struct drm_gem_object *obj,
2324
struct intel_frontbuffer *front);
2425

2526
void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj);
27+
struct intel_framebuffer *intel_bo_alloc_framebuffer(void);
2628

2729
#endif /* __INTEL_BO__ */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2346,7 +2346,7 @@ intel_framebuffer_create(struct drm_gem_object *obj,
23462346
struct intel_framebuffer *intel_fb;
23472347
int ret;
23482348

2349-
intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
2349+
intel_fb = intel_bo_alloc_framebuffer();
23502350
if (!intel_fb)
23512351
return ERR_PTR(-ENOMEM);
23522352

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,7 @@ skl_get_initial_plane_config(struct intel_crtc *crtc,
30293029
return;
30303030
}
30313031

3032-
intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
3032+
intel_fb = intel_bo_alloc_framebuffer();
30333033
if (!intel_fb) {
30343034
drm_dbg_kms(display->drm, "failed to alloc fb\n");
30353035
return;

drivers/gpu/drm/i915/gem/i915_gem_object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "i915_vma_types.h"
1818

1919
enum intel_region_id;
20+
struct intel_framebuffer;
2021

2122
#define obj_to_i915(obj__) to_i915((obj__)->base.dev)
2223

@@ -691,6 +692,7 @@ i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
691692
int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
692693
int i915_gem_object_truncate(struct drm_i915_gem_object *obj);
693694

695+
struct intel_framebuffer *i915_gem_object_alloc_framebuffer(void);
694696
/**
695697
* i915_gem_object_pin_map - return a contiguous mapping of the entire object
696698
* @obj: the object to map into kernel address space

drivers/gpu/drm/i915/gem/i915_gem_pages.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <drm/drm_cache.h>
77
#include <linux/vmalloc.h>
88

9+
#include "display/intel_display_types.h"
910
#include "gt/intel_gt.h"
1011
#include "gt/intel_tlb.h"
1112

@@ -354,6 +355,27 @@ static void *i915_gem_object_map_pfn(struct drm_i915_gem_object *obj,
354355
return vaddr ?: ERR_PTR(-ENOMEM);
355356
}
356357

358+
struct i915_panic_data {
359+
struct page **pages;
360+
int page;
361+
void *vaddr;
362+
};
363+
364+
struct i915_framebuffer {
365+
struct intel_framebuffer base;
366+
struct i915_panic_data panic;
367+
};
368+
369+
struct intel_framebuffer *i915_gem_object_alloc_framebuffer(void)
370+
{
371+
struct i915_framebuffer *i915_fb;
372+
373+
i915_fb = kzalloc(sizeof(*i915_fb), GFP_KERNEL);
374+
if (i915_fb)
375+
return &i915_fb->base;
376+
return NULL;
377+
}
378+
357379
/* get, pin, and map the pages of the object into kernel space */
358380
void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
359381
enum i915_map_type type)

drivers/gpu/drm/xe/display/intel_bo.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <drm/drm_gem.h>
55

6+
#include "intel_display_types.h"
7+
68
#include "xe_bo.h"
79
#include "intel_bo.h"
810

@@ -59,3 +61,25 @@ void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj)
5961
{
6062
/* FIXME */
6163
}
64+
65+
struct xe_panic_data {
66+
struct page **pages;
67+
int page;
68+
void *vaddr;
69+
};
70+
71+
struct xe_framebuffer {
72+
struct intel_framebuffer base;
73+
struct xe_panic_data panic;
74+
};
75+
76+
struct intel_framebuffer *intel_bo_alloc_framebuffer(void)
77+
{
78+
struct xe_framebuffer *xe_fb;
79+
80+
xe_fb = kzalloc(sizeof(*xe_fb), GFP_KERNEL);
81+
if (xe_fb)
82+
return &xe_fb->base;
83+
return NULL;
84+
}
85+

0 commit comments

Comments
 (0)