Skip to content

Commit 0c4f52b

Browse files
committed
drm/i915: make device info a const pointer to rodata
Finally we can get rid of the pseudo-const write-once device info, and convert it into a const pointer to device info in rodata. Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/f31933222f44e4a9224e41399a96896eb243e653.1687878757.git.jani.nikula@intel.com
1 parent e672f9e commit 0c4f52b

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct drm_i915_private {
203203
/* i915 device parameters */
204204
struct i915_params params;
205205

206-
const struct intel_device_info __info; /* Use INTEL_INFO() to access. */
206+
const struct intel_device_info *__info; /* Use INTEL_INFO() to access. */
207207
struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */
208208
struct intel_driver_caps caps;
209209

@@ -415,7 +415,7 @@ static inline struct intel_gt *to_gt(struct drm_i915_private *i915)
415415
(engine__) && (engine__)->uabi_class == (class__); \
416416
(engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
417417

418-
#define INTEL_INFO(i915) (&(i915)->__info)
418+
#define INTEL_INFO(i915) ((i915)->__info)
419419
#define RUNTIME_INFO(i915) (&(i915)->__runtime)
420420
#define DISPLAY_INFO(i915) ((i915)->display.info.__device_info)
421421
#define DISPLAY_RUNTIME_INFO(i915) (&(i915)->display.info.__runtime_info)

drivers/gpu/drm/i915/intel_device_info.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,6 @@ void intel_device_info_runtime_init_early(struct drm_i915_private *i915)
364364
intel_device_info_subplatform_init(i915);
365365
}
366366

367-
/* FIXME: Remove this, and make device info a const pointer to rodata. */
368-
static struct intel_device_info *
369-
mkwrite_device_info(struct drm_i915_private *i915)
370-
{
371-
return (struct intel_device_info *)INTEL_INFO(i915);
372-
}
373-
374367
static const struct intel_display_device_info no_display = {};
375368

376369
/**
@@ -430,26 +423,24 @@ void intel_device_info_driver_create(struct drm_i915_private *i915,
430423
u16 device_id,
431424
const struct intel_device_info *match_info)
432425
{
433-
struct intel_device_info *info;
434426
struct intel_runtime_info *runtime;
435427
u16 ver, rel, step;
436428

437-
/* Setup the write-once "constant" device info */
438-
info = mkwrite_device_info(i915);
439-
memcpy(info, match_info, sizeof(*info));
429+
/* Setup INTEL_INFO() */
430+
i915->__info = match_info;
440431

441432
/* Initialize initial runtime info from static const data and pdev. */
442433
runtime = RUNTIME_INFO(i915);
443434
memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
444435

445436
/* Probe display support */
446-
i915->display.info.__device_info = intel_display_device_probe(i915, info->has_gmd_id,
437+
i915->display.info.__device_info = intel_display_device_probe(i915, HAS_GMD_ID(i915),
447438
&ver, &rel, &step);
448439
memcpy(DISPLAY_RUNTIME_INFO(i915),
449440
&DISPLAY_INFO(i915)->__runtime_defaults,
450441
sizeof(*DISPLAY_RUNTIME_INFO(i915)));
451442

452-
if (info->has_gmd_id) {
443+
if (HAS_GMD_ID(i915)) {
453444
DISPLAY_RUNTIME_INFO(i915)->ip.ver = ver;
454445
DISPLAY_RUNTIME_INFO(i915)->ip.rel = rel;
455446
DISPLAY_RUNTIME_INFO(i915)->ip.step = step;

0 commit comments

Comments
 (0)