From: Jani Nikula <jani.nikula@intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [RESEND] drm/i915: hide mkwrite_device_info() better
Date: Fri, 14 Apr 2023 13:11:10 +0300 [thread overview]
Message-ID: <87h6tig4e9.fsf@intel.com> (raw)
In-Reply-To: <a81da631-c389-77ee-5c39-bdbfff02b034@linux.intel.com>
On Thu, 13 Apr 2023, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote:
> On 11/04/2023 11:56, Jani Nikula wrote:
>> 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>
>> ---
>> drivers/gpu/drm/i915/i915_driver.c | 12 ++--------
>> drivers/gpu/drm/i915/i915_drv.h | 7 ------
>> drivers/gpu/drm/i915/intel_device_info.c | 29 ++++++++++++++++++++++++
>> drivers/gpu/drm/i915/intel_device_info.h | 2 ++
>> 4 files changed, 33 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
>> index 93fdc40d724f..2980ccdef6cd 100644
>> --- a/drivers/gpu/drm/i915/i915_driver.c
>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>> @@ -720,8 +720,6 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
>> {
>> const struct intel_device_info *match_info =
>> (struct intel_device_info *)ent->driver_data;
>> - struct intel_device_info *device_info;
>> - struct intel_runtime_info *runtime;
>> struct drm_i915_private *i915;
>>
>> i915 = devm_drm_dev_alloc(&pdev->dev, &i915_drm_driver,
>> @@ -734,14 +732,8 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
>> /* Device parameters start as a copy of module parameters. */
>> i915_params_copy(&i915->params, &i915_modparams);
>>
>> - /* Setup the write-once "constant" device info */
>> - device_info = mkwrite_device_info(i915);
>> - memcpy(device_info, match_info, sizeof(*device_info));
>> -
>> - /* Initialize initial runtime info from static const data and pdev. */
>> - runtime = RUNTIME_INFO(i915);
>> - memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
>> - runtime->device_id = pdev->device;
>> + /* Set up device info and initial runtime info. */
>> + intel_device_info_driver_create(i915, pdev->device, match_info);
>>
>> return i915;
>> }
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index e771fdc3099c..fe7eeafe9cff 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -931,11 +931,4 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
>> #define HAS_LMEMBAR_SMEM_STOLEN(i915) (!HAS_LMEM(i915) && \
>> GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70))
>>
>> -/* intel_device_info.c */
>> -static inline struct intel_device_info *
>> -mkwrite_device_info(struct drm_i915_private *dev_priv)
>> -{
>> - return (struct intel_device_info *)INTEL_INFO(dev_priv);
>> -}
>> -
>> #endif
>> diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
>> index fc5cd14adfcc..4e23be2995bf 100644
>> --- a/drivers/gpu/drm/i915/intel_device_info.c
>> +++ b/drivers/gpu/drm/i915/intel_device_info.c
>> @@ -381,6 +381,13 @@ void intel_device_info_runtime_init_early(struct drm_i915_private *i915)
>> intel_device_info_subplatform_init(i915);
>> }
>>
>> +/* FIXME: Remove this, and make device info a const pointer to rodata. */
>> +static struct intel_device_info *
>> +mkwrite_device_info(struct drm_i915_private *i915)
>> +{
>> + return (struct intel_device_info *)INTEL_INFO(i915);
>> +}
>> +
>> /**
>> * intel_device_info_runtime_init - initialize runtime info
>> * @dev_priv: the i915 device
>> @@ -548,6 +555,28 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
>> dev_priv->drm.driver_features &= ~DRIVER_ATOMIC;
>> }
>>
>> +/*
>> + * Set up device info and initial runtime info at driver create.
>> + *
>> + * Note: i915 is only an allocated blob of memory at this point.
>> + */
>> +void intel_device_info_driver_create(struct drm_i915_private *i915,
>> + u16 device_id,
>> + const struct intel_device_info *match_info)
>> +{
>> + struct intel_device_info *info;
>> + struct intel_runtime_info *runtime;
>> +
>> + /* Setup the write-once "constant" device info */
>> + info = mkwrite_device_info(i915);
>> + memcpy(info, match_info, sizeof(*info));
>> +
>> + /* Initialize initial runtime info from static const data and pdev. */
>> + runtime = RUNTIME_INFO(i915);
>> + memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
>> + runtime->device_id = device_id;
>> +}
>> +
>> void intel_driver_caps_print(const struct intel_driver_caps *caps,
>> struct drm_printer *p)
>> {
>> diff --git a/drivers/gpu/drm/i915/intel_device_info.h b/drivers/gpu/drm/i915/intel_device_info.h
>> index 080a4557899b..f032f2500f50 100644
>> --- a/drivers/gpu/drm/i915/intel_device_info.h
>> +++ b/drivers/gpu/drm/i915/intel_device_info.h
>> @@ -317,6 +317,8 @@ struct intel_driver_caps {
>>
>> const char *intel_platform_name(enum intel_platform platform);
>>
>> +void intel_device_info_driver_create(struct drm_i915_private *i915, u16 device_id,
>> + const struct intel_device_info *match_info);
>
> Match_info maybe reads a bit odd when "exported" but I have no superior
> suggestions either (const? template? pci?). Hiding seems a good plan so:
>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Naming is hard, pushed as-is, thanks for the review.
BR,
Jani.
>
> Regards,
>
> Tvrtko
>
>> void intel_device_info_runtime_init_early(struct drm_i915_private *dev_priv);
>> void intel_device_info_runtime_init(struct drm_i915_private *dev_priv);
>>
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-04-14 10:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 10:56 [Intel-gfx] [RESEND] drm/i915: hide mkwrite_device_info() better Jani Nikula
2023-04-11 22:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: hide mkwrite_device_info() better (rev2) Patchwork
2023-04-11 22:32 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-04-11 22:45 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-12 12:51 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-04-13 12:14 ` [Intel-gfx] [RESEND] drm/i915: hide mkwrite_device_info() better Tvrtko Ursulin
2023-04-14 10:11 ` Jani Nikula [this message]
2023-04-13 17:57 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: hide mkwrite_device_info() better (rev3) Patchwork
2023-04-13 17:57 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-04-13 18:10 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-13 22:55 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6tig4e9.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tvrtko.ursulin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.