Skip to content

Commit 446a20c

Browse files
committed
drm/i915: hide mkwrite_device_info() better
The goal has been to just make device info a pointer to static const data, i.e. the static const structs in i915_pci.c. See [1]. However, there were issues with intel_device_info_runtime_init() clearing the display sub-struct of device info on the !HAS_DISPLAY() path, which consequently disables a lot of display functionality, like it should. Looks like we'd have to cover all those paths, and maybe sprinkle HAS_DISPLAY() checks in them, which we haven't gotten around to. In the mean time, hide mkwrite_device_info() better within intel_device_info.c by adding a intel_device_info_driver_create() for the very early initialization of the device info and initial runtime info. This also lets us declutter i915_drv.h a bit, and stops promoting mkwrite_device_info() as something that could be used. [1] https://lore.kernel.org/r/a0422f0a8ac055f65b7922bcd3119b180a41e79e.1655712106.git.jani.nikula@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/20230411105643.292416-1-jani.nikula@intel.com
1 parent d7c281e commit 446a20c

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

drivers/gpu/drm/i915/i915_driver.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,6 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
718718
{
719719
const struct intel_device_info *match_info =
720720
(struct intel_device_info *)ent->driver_data;
721-
struct intel_device_info *device_info;
722-
struct intel_runtime_info *runtime;
723721
struct drm_i915_private *i915;
724722

725723
i915 = devm_drm_dev_alloc(&pdev->dev, &i915_drm_driver,
@@ -732,14 +730,8 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
732730
/* Device parameters start as a copy of module parameters. */
733731
i915_params_copy(&i915->params, &i915_modparams);
734732

735-
/* Setup the write-once "constant" device info */
736-
device_info = mkwrite_device_info(i915);
737-
memcpy(device_info, match_info, sizeof(*device_info));
738-
739-
/* Initialize initial runtime info from static const data and pdev. */
740-
runtime = RUNTIME_INFO(i915);
741-
memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
742-
runtime->device_id = pdev->device;
733+
/* Set up device info and initial runtime info. */
734+
intel_device_info_driver_create(i915, pdev->device, match_info);
743735

744736
return i915;
745737
}

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,11 +929,4 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
929929
#define HAS_LMEMBAR_SMEM_STOLEN(i915) (!HAS_LMEM(i915) && \
930930
GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70))
931931

932-
/* intel_device_info.c */
933-
static inline struct intel_device_info *
934-
mkwrite_device_info(struct drm_i915_private *dev_priv)
935-
{
936-
return (struct intel_device_info *)INTEL_INFO(dev_priv);
937-
}
938-
939932
#endif

drivers/gpu/drm/i915/intel_device_info.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ void intel_device_info_runtime_init_early(struct drm_i915_private *i915)
381381
intel_device_info_subplatform_init(i915);
382382
}
383383

384+
/* FIXME: Remove this, and make device info a const pointer to rodata. */
385+
static struct intel_device_info *
386+
mkwrite_device_info(struct drm_i915_private *i915)
387+
{
388+
return (struct intel_device_info *)INTEL_INFO(i915);
389+
}
390+
384391
/**
385392
* intel_device_info_runtime_init - initialize runtime info
386393
* @dev_priv: the i915 device
@@ -548,6 +555,28 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
548555
dev_priv->drm.driver_features &= ~DRIVER_ATOMIC;
549556
}
550557

558+
/*
559+
* Set up device info and initial runtime info at driver create.
560+
*
561+
* Note: i915 is only an allocated blob of memory at this point.
562+
*/
563+
void intel_device_info_driver_create(struct drm_i915_private *i915,
564+
u16 device_id,
565+
const struct intel_device_info *match_info)
566+
{
567+
struct intel_device_info *info;
568+
struct intel_runtime_info *runtime;
569+
570+
/* Setup the write-once "constant" device info */
571+
info = mkwrite_device_info(i915);
572+
memcpy(info, match_info, sizeof(*info));
573+
574+
/* Initialize initial runtime info from static const data and pdev. */
575+
runtime = RUNTIME_INFO(i915);
576+
memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
577+
runtime->device_id = device_id;
578+
}
579+
551580
void intel_driver_caps_print(const struct intel_driver_caps *caps,
552581
struct drm_printer *p)
553582
{

drivers/gpu/drm/i915/intel_device_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ struct intel_driver_caps {
316316

317317
const char *intel_platform_name(enum intel_platform platform);
318318

319+
void intel_device_info_driver_create(struct drm_i915_private *i915, u16 device_id,
320+
const struct intel_device_info *match_info);
319321
void intel_device_info_runtime_init_early(struct drm_i915_private *dev_priv);
320322
void intel_device_info_runtime_init(struct drm_i915_private *dev_priv);
321323

0 commit comments

Comments
 (0)