mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
drm/i915/display: allocate struct intel_display dynamically
Allocate struct intel_display dynamically in intel_display_device_probe() and free in intel_display_device_remove(). v2: Remove duplicate intel_display_device_remove() on error path (Lucas) Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://lore.kernel.org/r/8cd526a177061cddf71db59bd0901bd1a24e77be.1747907216.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
dc0698d1b3
commit
6f142c52d3
|
|
@ -1621,13 +1621,17 @@ static void display_platforms_or(struct intel_display_platforms *dst,
|
|||
|
||||
struct intel_display *intel_display_device_probe(struct pci_dev *pdev)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(pdev);
|
||||
struct intel_display *display;
|
||||
const struct intel_display_device_info *info;
|
||||
struct intel_display_ip_ver ip_ver = {};
|
||||
const struct platform_desc *desc;
|
||||
const struct subplatform_desc *subdesc;
|
||||
enum intel_step step;
|
||||
|
||||
display = kzalloc(sizeof(*display), GFP_KERNEL);
|
||||
if (!display)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
/* Add drm device backpointer as early as possible. */
|
||||
display->drm = pci_get_drvdata(pdev);
|
||||
|
||||
|
|
@ -1708,7 +1712,11 @@ struct intel_display *intel_display_device_probe(struct pci_dev *pdev)
|
|||
|
||||
void intel_display_device_remove(struct intel_display *display)
|
||||
{
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
intel_display_params_free(&display->params);
|
||||
kfree(display);
|
||||
}
|
||||
|
||||
static void __intel_display_device_info_runtime_init(struct intel_display *display)
|
||||
|
|
|
|||
|
|
@ -293,6 +293,8 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)
|
|||
intel_sbi_fini(dev_priv);
|
||||
|
||||
i915_params_free(&dev_priv->params);
|
||||
|
||||
intel_display_device_remove(display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -735,6 +737,7 @@ 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 drm_i915_private *i915;
|
||||
struct intel_display *display;
|
||||
|
||||
i915 = devm_drm_dev_alloc(&pdev->dev, &i915_drm_driver,
|
||||
struct drm_i915_private, drm);
|
||||
|
|
@ -749,10 +752,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
/* Set up device info and initial runtime info. */
|
||||
intel_device_info_driver_create(i915, pdev->device, match_info);
|
||||
|
||||
/* TODO: Allocate display dynamically. */
|
||||
i915->display = &i915->__display;
|
||||
display = intel_display_device_probe(pdev);
|
||||
if (IS_ERR(display))
|
||||
return ERR_CAST(display);
|
||||
|
||||
intel_display_device_probe(pdev);
|
||||
i915->display = display;
|
||||
|
||||
return i915;
|
||||
}
|
||||
|
|
@ -911,7 +915,6 @@ void i915_driver_remove(struct drm_i915_private *i915)
|
|||
static void i915_driver_release(struct drm_device *dev)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = to_i915(dev);
|
||||
struct intel_display *display = dev_priv->display;
|
||||
struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
|
||||
intel_wakeref_t wakeref;
|
||||
|
||||
|
|
@ -934,8 +937,6 @@ static void i915_driver_release(struct drm_device *dev)
|
|||
intel_runtime_pm_driver_release(rpm);
|
||||
|
||||
i915_driver_late_release(dev_priv);
|
||||
|
||||
intel_display_device_remove(display);
|
||||
}
|
||||
|
||||
static int i915_driver_open(struct drm_device *dev, struct drm_file *file)
|
||||
|
|
|
|||
|
|
@ -178,7 +178,6 @@ struct drm_i915_private {
|
|||
struct drm_device drm;
|
||||
|
||||
struct intel_display *display;
|
||||
struct intel_display __display; /* Transitional. Do not use directly. */
|
||||
|
||||
/* FIXME: Device release actions should all be moved to drmm_ */
|
||||
bool do_release;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ struct drm_i915_private *mock_gem_device(void)
|
|||
static struct dev_iommu fake_iommu = { .priv = (void *)-1 };
|
||||
#endif
|
||||
struct drm_i915_private *i915;
|
||||
struct intel_display *display;
|
||||
struct pci_dev *pdev;
|
||||
int ret;
|
||||
|
||||
|
|
@ -180,10 +181,11 @@ struct drm_i915_private *mock_gem_device(void)
|
|||
/* Set up device info and initial runtime info. */
|
||||
intel_device_info_driver_create(i915, pdev->device, &mock_info);
|
||||
|
||||
/* TODO: Allocate display dynamically. */
|
||||
i915->display = &i915->__display;
|
||||
display = intel_display_device_probe(pdev);
|
||||
if (IS_ERR(display))
|
||||
goto err_device;
|
||||
|
||||
intel_display_device_probe(pdev);
|
||||
i915->display = display;
|
||||
|
||||
dev_pm_domain_set(&pdev->dev, &pm_domain);
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
|
|
@ -260,6 +262,7 @@ struct drm_i915_private *mock_gem_device(void)
|
|||
intel_gt_driver_late_release_all(i915);
|
||||
intel_memory_regions_driver_release(i915);
|
||||
drm_mode_config_cleanup(&i915->drm);
|
||||
err_device:
|
||||
mock_destroy_device(i915);
|
||||
|
||||
return NULL;
|
||||
|
|
@ -269,6 +272,8 @@ void mock_destroy_device(struct drm_i915_private *i915)
|
|||
{
|
||||
struct device *dev = i915->drm.dev;
|
||||
|
||||
intel_display_device_remove(i915->display);
|
||||
|
||||
devres_release_group(dev, NULL);
|
||||
put_device(dev);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -529,15 +529,16 @@ int xe_display_probe(struct xe_device *xe)
|
|||
if (!xe->info.probe_display)
|
||||
goto no_display;
|
||||
|
||||
/* TODO: Allocate display dynamically. */
|
||||
xe->display = &xe->__display;
|
||||
|
||||
display = intel_display_device_probe(pdev);
|
||||
if (IS_ERR(display))
|
||||
return PTR_ERR(display);
|
||||
|
||||
err = drmm_add_action_or_reset(&xe->drm, display_device_remove, display);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
xe->display = display;
|
||||
|
||||
if (has_display(xe))
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -588,7 +588,6 @@ struct xe_device {
|
|||
* migrating to the right sub-structs
|
||||
*/
|
||||
struct intel_display *display;
|
||||
struct intel_display __display; /* Transitional. Do not use directly. */
|
||||
|
||||
struct dram_info {
|
||||
bool wm_lv_0_adjust_needed;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user