Skip to content

Commit e117100

Browse files
committed
drm/i915/dram: allocate struct dram_info dynamically
Allocate struct drm_info dynamically, and convert the struct drm_i915_private and struct xe_device dram_info member into a const pointer. Move the struct definition to intel_dram.h, and keep it opaque to everyone not needing it. This also removes the duplication of the struct definition. Reviewed-by: Vinod Govindapillai <[email protected]> Link: https://lore.kernel.org/r/73625095157346ea0e8614108c9b369208e5df66.1748337870.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent 836864a commit e117100

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "intel_step.h"
6161
#include "intel_uncore.h"
6262

63+
struct dram_info;
6364
struct drm_i915_clock_gating_funcs;
6465
struct intel_display;
6566
struct intel_pxp;
@@ -282,25 +283,7 @@ struct drm_i915_private {
282283
u32 suspend_count;
283284
struct vlv_s0ix_state *vlv_s0ix_state;
284285

285-
struct dram_info {
286-
bool wm_lv_0_adjust_needed;
287-
u8 num_channels;
288-
bool symmetric_memory;
289-
enum intel_dram_type {
290-
INTEL_DRAM_UNKNOWN,
291-
INTEL_DRAM_DDR3,
292-
INTEL_DRAM_DDR4,
293-
INTEL_DRAM_LPDDR3,
294-
INTEL_DRAM_LPDDR4,
295-
INTEL_DRAM_DDR5,
296-
INTEL_DRAM_LPDDR5,
297-
INTEL_DRAM_GDDR,
298-
INTEL_DRAM_GDDR_ECC,
299-
__INTEL_DRAM_TYPE_MAX,
300-
} type;
301-
u8 num_qgv_points;
302-
u8 num_psf_gv_points;
303-
} dram_info;
286+
const struct dram_info *dram_info;
304287

305288
struct intel_runtime_pm runtime_pm;
306289

drivers/gpu/drm/i915/soc/intel_dram.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <linux/string_helpers.h>
77

8+
#include <drm/drm_managed.h>
9+
810
#include "../display/intel_display_core.h" /* FIXME */
911

1012
#include "i915_drv.h"
@@ -706,7 +708,7 @@ static int xelpdp_get_dram_info(struct drm_i915_private *i915, struct dram_info
706708

707709
int intel_dram_detect(struct drm_i915_private *i915)
708710
{
709-
struct dram_info *dram_info = &i915->dram_info;
711+
struct dram_info *dram_info;
710712
int ret;
711713

712714
detect_fsb_freq(i915);
@@ -715,6 +717,12 @@ int intel_dram_detect(struct drm_i915_private *i915)
715717
if (GRAPHICS_VER(i915) < 9 || IS_DG2(i915) || !HAS_DISPLAY(i915))
716718
return 0;
717719

720+
dram_info = drmm_kzalloc(&i915->drm, sizeof(*dram_info), GFP_KERNEL);
721+
if (!dram_info)
722+
return -ENOMEM;
723+
724+
i915->dram_info = dram_info;
725+
718726
/*
719727
* Assume level 0 watermark latency adjustment is needed until proven
720728
* otherwise, this w/a is not needed by bxt/glk.
@@ -749,11 +757,16 @@ int intel_dram_detect(struct drm_i915_private *i915)
749757
return 0;
750758
}
751759

760+
/*
761+
* Returns NULL for platforms that don't have dram info. Avoid overzealous NULL
762+
* checks, and prefer not dereferencing on platforms that shouldn't look at dram
763+
* info, to catch accidental and incorrect dram info checks.
764+
*/
752765
const struct dram_info *intel_dram_info(struct drm_device *drm)
753766
{
754767
struct drm_i915_private *i915 = to_i915(drm);
755768

756-
return &i915->dram_info;
769+
return i915->dram_info;
757770
}
758771

759772
static u32 gen9_edram_size_mb(struct drm_i915_private *i915, u32 cap)

drivers/gpu/drm/i915/soc/intel_dram.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,30 @@
66
#ifndef __INTEL_DRAM_H__
77
#define __INTEL_DRAM_H__
88

9+
#include <linux/types.h>
10+
911
struct drm_i915_private;
1012
struct drm_device;
11-
struct dram_info;
13+
14+
struct dram_info {
15+
bool wm_lv_0_adjust_needed;
16+
u8 num_channels;
17+
bool symmetric_memory;
18+
enum intel_dram_type {
19+
INTEL_DRAM_UNKNOWN,
20+
INTEL_DRAM_DDR3,
21+
INTEL_DRAM_DDR4,
22+
INTEL_DRAM_LPDDR3,
23+
INTEL_DRAM_LPDDR4,
24+
INTEL_DRAM_DDR5,
25+
INTEL_DRAM_LPDDR5,
26+
INTEL_DRAM_GDDR,
27+
INTEL_DRAM_GDDR_ECC,
28+
__INTEL_DRAM_TYPE_MAX,
29+
} type;
30+
u8 num_qgv_points;
31+
u8 num_psf_gv_points;
32+
};
1233

1334
void intel_dram_edram_detect(struct drm_i915_private *i915);
1435
int intel_dram_detect(struct drm_i915_private *i915);

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define TEST_VM_OPS_ERROR
3131
#endif
3232

33+
struct dram_info;
3334
struct intel_display;
3435
struct xe_ggtt;
3536
struct xe_pat_ops;
@@ -585,25 +586,7 @@ struct xe_device {
585586
*/
586587
struct intel_display *display;
587588

588-
struct dram_info {
589-
bool wm_lv_0_adjust_needed;
590-
u8 num_channels;
591-
bool symmetric_memory;
592-
enum intel_dram_type {
593-
INTEL_DRAM_UNKNOWN,
594-
INTEL_DRAM_DDR3,
595-
INTEL_DRAM_DDR4,
596-
INTEL_DRAM_LPDDR3,
597-
INTEL_DRAM_LPDDR4,
598-
INTEL_DRAM_DDR5,
599-
INTEL_DRAM_LPDDR5,
600-
INTEL_DRAM_GDDR,
601-
INTEL_DRAM_GDDR_ECC,
602-
__INTEL_DRAM_TYPE_MAX,
603-
} type;
604-
u8 num_qgv_points;
605-
u8 num_psf_gv_points;
606-
} dram_info;
589+
const struct dram_info *dram_info;
607590

608591
/*
609592
* edram size in MB.

0 commit comments

Comments
 (0)