diff mbox series

[v3,07/14] drm/i915: Use a DRM-managed action to release the PCI bridge device

Message ID 20220906234934.3655440-8-matthew.d.roper@intel.com (mailing list archive)
State New, archived
Headers show
Series i915: Add "standalone media" support for MTL | expand

Commit Message

Matt Roper Sept. 6, 2022, 11:49 p.m. UTC
As we start supporting multiple uncore structures in future patches, the
MMIO cleanup (which make also get called mid-init if there's a failure)
will become more complicated.  Moving to DRM-managed actions will help
keep things simple.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Sripada, Radhakrishna Sept. 9, 2022, 8:57 p.m. UTC | #1
> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Matt
> Roper
> Sent: Tuesday, September 6, 2022 4:49 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Subject: [PATCH v3 07/14] drm/i915: Use a DRM-managed action to release the
> PCI bridge device
> 
> As we start supporting multiple uncore structures in future patches, the
> MMIO cleanup (which make also get called mid-init if there's a failure)
> will become more complicated.  Moving to DRM-managed actions will help
> keep things simple.
> 
LGTM,
Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>

> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_driver.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_driver.c
> b/drivers/gpu/drm/i915/i915_driver.c
> index 18acba1bc3b0..1f46dd1ffaf7 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -105,6 +105,12 @@ static const char irst_name[] = "INT3392";
> 
>  static const struct drm_driver i915_drm_driver;
> 
> +static void i915_release_bridge_dev(struct drm_device *dev,
> +				    void *bridge)
> +{
> +	pci_dev_put(bridge);
> +}
> +
>  static int i915_get_bridge_dev(struct drm_i915_private *dev_priv)
>  {
>  	int domain = pci_domain_nr(to_pci_dev(dev_priv->drm.dev)->bus);
> @@ -115,7 +121,9 @@ static int i915_get_bridge_dev(struct drm_i915_private
> *dev_priv)
>  		drm_err(&dev_priv->drm, "bridge device not found\n");
>  		return -EIO;
>  	}
> -	return 0;
> +
> +	return drmm_add_action_or_reset(&dev_priv->drm,
> i915_release_bridge_dev,
> +					dev_priv->bridge_dev);
>  }
> 
>  /* Allocate space for the MCH regs if needed, return nonzero on error */
> @@ -452,7 +460,6 @@ static int i915_driver_mmio_probe(struct
> drm_i915_private *dev_priv)
>  err_uncore:
>  	intel_teardown_mchbar(dev_priv);
>  	intel_uncore_fini_mmio(&dev_priv->uncore);
> -	pci_dev_put(dev_priv->bridge_dev);
> 
>  	return ret;
>  }
> @@ -465,7 +472,6 @@ static void i915_driver_mmio_release(struct
> drm_i915_private *dev_priv)
>  {
>  	intel_teardown_mchbar(dev_priv);
>  	intel_uncore_fini_mmio(&dev_priv->uncore);
> -	pci_dev_put(dev_priv->bridge_dev);
>  }
> 
>  /**
> --
> 2.37.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 18acba1bc3b0..1f46dd1ffaf7 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -105,6 +105,12 @@  static const char irst_name[] = "INT3392";
 
 static const struct drm_driver i915_drm_driver;
 
+static void i915_release_bridge_dev(struct drm_device *dev,
+				    void *bridge)
+{
+	pci_dev_put(bridge);
+}
+
 static int i915_get_bridge_dev(struct drm_i915_private *dev_priv)
 {
 	int domain = pci_domain_nr(to_pci_dev(dev_priv->drm.dev)->bus);
@@ -115,7 +121,9 @@  static int i915_get_bridge_dev(struct drm_i915_private *dev_priv)
 		drm_err(&dev_priv->drm, "bridge device not found\n");
 		return -EIO;
 	}
-	return 0;
+
+	return drmm_add_action_or_reset(&dev_priv->drm, i915_release_bridge_dev,
+					dev_priv->bridge_dev);
 }
 
 /* Allocate space for the MCH regs if needed, return nonzero on error */
@@ -452,7 +460,6 @@  static int i915_driver_mmio_probe(struct drm_i915_private *dev_priv)
 err_uncore:
 	intel_teardown_mchbar(dev_priv);
 	intel_uncore_fini_mmio(&dev_priv->uncore);
-	pci_dev_put(dev_priv->bridge_dev);
 
 	return ret;
 }
@@ -465,7 +472,6 @@  static void i915_driver_mmio_release(struct drm_i915_private *dev_priv)
 {
 	intel_teardown_mchbar(dev_priv);
 	intel_uncore_fini_mmio(&dev_priv->uncore);
-	pci_dev_put(dev_priv->bridge_dev);
 }
 
 /**