Skip to contentSkip to conversation

drm/hisilicon: Add load and unload callback functions

PATCH In review Tian Tao 2 participants 2 messages Dec 24, 2020 – Jan 4, 2021

Subsystems (3)
lore
Share & tools
lore

Tian Tao

author maintainer
#0 lore raw

PATCH v2 1/1 drm/hisilicon: Add load and unload callback functions

Add the callback functions of drm_driver structure member functions load and unload, no need to call load in the hibmc_pci_probe function and unload in the hibmc_pci_remove function.

v2:
remove the hibmc_unload called from hibmc_pic_remove.

---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +7 -11
index 0d4e902..10042cf 100644
@@ -27,6 +27,9 @@
 
 DEFINE_DRM_GEM_FOPS(hibmc_fops);
 
+static int hibmc_load(struct drm_device *dev, unsigned long flags);
+static void hibmc_unload(struct drm_device *dev);
+
 static irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *)arg;
@@ -63,6 +66,8 @@ static const struct drm_driver hibmc_driver = {
 	.dumb_map_offset        = drm_gem_vram_driver_dumb_mmap_offset,
 	.gem_prime_mmap		= drm_gem_prime_mmap,
 	.irq_handler		= hibmc_drm_interrupt,
+	.load			= hibmc_load,
+	.unload			= hibmc_unload,
 };
 
 static int __maybe_unused hibmc_pm_suspend(struct device *dev)
@@ -248,7 +253,7 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)
 	return 0;
 }
 
-static int hibmc_unload(struct drm_device *dev)
+static void hibmc_unload(struct drm_device *dev)
 {
 	drm_atomic_helper_shutdown(dev);
 
@@ -256,11 +261,9 @@ static int hibmc_unload(struct drm_device *dev)
 		drm_irq_uninstall(dev);
 
 	pci_disable_msi(dev->pdev);
-
-	return 0;
 }
 
-static int hibmc_load(struct drm_device *dev)
+static int hibmc_load(struct drm_device *dev, unsigned long flags)
 {
 	struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
 	int ret;
@@ -335,12 +338,6 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
 		goto err_return;
 	}
 
-	ret = hibmc_load(dev);
-	if (ret) {
-		drm_err(dev, "failed to load hibmc: %d\n", ret);
-		goto err_return;
-	}
-
 	ret = drm_dev_register(dev, 0);
 	if (ret) {
 		drm_err(dev, "failed to register drv for userspace access: %d\n",
@@ -363,7 +360,6 @@ static void hibmc_pci_remove(struct pci_dev *pdev)
 	struct drm_device *dev = pci_get_drvdata(pdev);
 
 	drm_dev_unregister(dev);
-	hibmc_unload(dev);
 }
 
 static const struct pci_device_id hibmc_pci_table[] = {
Signature · 1 line
2.7.4
#1 lore raw

Hi,

and a happy new year.

Am 24.12.20 um 09:45 schrieb Tian Tao:

Quoted 3 lines

Add the callback functions of drm_driver structure member functions load and unload, no need to call load in the hibmc_pci_probe function and unload in the hibmc_pci_remove function.

The load and unload callbacks are left over from long ago. They are now deprecated.* Don't use them.

Quoted 3 lines

v2:
remove the hibmc_unload called from hibmc_pic_remove.

If anything, you'd want to inline hibmc's load/unload into their callers.

Best regards
Thomas

*) White lie: They are used by the old non-KMS drivers. Anything with KMS should not use them.

Quoted 73 lines
---
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 +++++++-----------
  1 file changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +7 -11
index 0d4e902..10042cf 100644
@@ -27,6 +27,9 @@
 
  DEFINE_DRM_GEM_FOPS(hibmc_fops);
 
+static int hibmc_load(struct drm_device *dev, unsigned long flags);
+static void hibmc_unload(struct drm_device *dev);
+
  static irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
  {
  	struct drm_device *dev = (struct drm_device *)arg;
@@ -63,6 +66,8 @@ static const struct drm_driver hibmc_driver = {
  	.dumb_map_offset        = drm_gem_vram_driver_dumb_mmap_offset,
  	.gem_prime_mmap		= drm_gem_prime_mmap,
  	.irq_handler		= hibmc_drm_interrupt,
+	.load			= hibmc_load,
+	.unload			= hibmc_unload,
  };
 
  static int __maybe_unused hibmc_pm_suspend(struct device *dev)
@@ -248,7 +253,7 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)
  	return 0;
  }
 
-static int hibmc_unload(struct drm_device *dev)
+static void hibmc_unload(struct drm_device *dev)
  {
  	drm_atomic_helper_shutdown(dev);
 
@@ -256,11 +261,9 @@ static int hibmc_unload(struct drm_device *dev)
  		drm_irq_uninstall(dev);
 
  	pci_disable_msi(dev->pdev);
-
-	return 0;
  }
 
-static int hibmc_load(struct drm_device *dev)
+static int hibmc_load(struct drm_device *dev, unsigned long flags)
  {
  	struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
  	int ret;
@@ -335,12 +338,6 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
  		goto err_return;
  	}
 
-	ret = hibmc_load(dev);
-	if (ret) {
-		drm_err(dev, "failed to load hibmc: %d\n", ret);
-		goto err_return;
-	}
-
  	ret = drm_dev_register(dev, 0);
  	if (ret) {
  		drm_err(dev, "failed to register drv for userspace access: %d\n",
@@ -363,7 +360,6 @@ static void hibmc_pci_remove(struct pci_dev *pdev)
  	struct drm_device *dev = pci_get_drvdata(pdev);
 
  	drm_dev_unregister(dev);
-	hibmc_unload(dev);
  }
 
  static const struct pci_device_id hibmc_pci_table[] = {
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel