[Intel-gfx] [PATCH 16/16] drm/i915: make device info a pointer to static const data
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Thu Aug 18 11:05:35 UTC 2022
Op 18-08-2022 om 12:48 schreef Jani Nikula:
> On Thu, 18 Aug 2022, Maarten Lankhorst <maarten.lankhorst at linux.intel.com> wrote:
>> Op 20-06-2022 om 10:49 schreef Jani Nikula:
>>> Now that the device info is no longer modified runtime, we don't need to
>>> make a copy of it, and we can convert i915->__info into a pointer to
>>> static const data. Also remove mkwrite_device_info().
>>>
>>> This does increase the text size slightly.
>>>
>>> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
>>>
>>> ---
>>>
>>> An alternative is to keep copying device info, but casting away the
>>> const only once at the copy time, removing mkwrite_device_info().
>>> ---
>>> drivers/gpu/drm/i915/i915_driver.c | 8 ++------
>>> drivers/gpu/drm/i915/i915_drv.h | 11 ++---------
>>> 2 files changed, 4 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
>>> index 5969cc7805d3..9c9c492e97a8 100644
>>> --- a/drivers/gpu/drm/i915/i915_driver.c
>>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>>> @@ -793,9 +793,6 @@ static void i915_welcome_messages(struct drm_i915_private *dev_priv)
>>> static struct drm_i915_private *
>>> 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;
>>>
>>> @@ -809,9 +806,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));
>>> + /* Static const device info. */
>>> + i915->__info = (const struct intel_device_info *)ent->driver_data;
>>>
>>> /* Initialize initial runtime info from static const data and pdev. */
>>> runtime = RUNTIME_INFO(i915);
>>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>>> index 89472440947c..a2a57f07c5be 100644
>>> --- a/drivers/gpu/drm/i915/i915_drv.h
>>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>>> @@ -380,7 +380,7 @@ struct drm_i915_private {
>>> /* i915 device parameters */
>>> struct i915_params params;
>>>
>>> - const struct intel_device_info __info; /* Use INTEL_INFO() to access. */
>>> + const struct intel_device_info *__info; /* Use INTEL_INFO() to access. */
>>> struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */
>>> struct intel_driver_caps caps;
>>>
>>> @@ -848,7 +848,7 @@ static inline struct intel_gt *to_gt(struct drm_i915_private *i915)
>>> GENMASK(INTEL_FRONTBUFFER_BITS_PER_PIPE * ((pipe) + 1) - 1, \
>>> INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe))
>>>
>>> -#define INTEL_INFO(dev_priv) (&(dev_priv)->__info)
>>> +#define INTEL_INFO(__i915) (__i915->__info)
>>> #define RUNTIME_INFO(dev_priv) (&(dev_priv)->__runtime)
>>> #define DRIVER_CAPS(dev_priv) (&(dev_priv)->caps)
>>>
>>> @@ -1432,13 +1432,6 @@ void i915_gem_driver_release(struct drm_i915_private *dev_priv);
>>>
>>> int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file);
>>>
>>> -/* 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);
>>> -}
>>> -
>>> static inline enum i915_map_type
>>> i915_coherent_map_type(struct drm_i915_private *i915,
>>> struct drm_i915_gem_object *obj, bool always_coherent)
>> I think just moving around things is safest in this case. I believe
>> all should be moved to the new display sub-struct, but this is a start
>> of making that easier.
>>
>> For the series, except patch 5:
>>
>> Reviewed-by: Maarten Lankhort <maarten.lankhorst at linux.intel.com>
> Thanks... but there's v2 starting at [1]. I don't recall any changes
> other than rebase and slight reordering of patches.
>
> What's wrong with patch 5? I mean it does get modified runtime.
>
> BR,
> Jani.
>
>
>
> [1] https://lore.kernel.org/r/cover.1660137416.git.jani.nikula@intel.com
>
>
Sorry, except 5 was for the display split series. Patch 5 from this series is fine. :)
More information about the Intel-gfx
mailing list