All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
@ 2013-12-16 15:57 ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2013-12-16 15:57 UTC (permalink / raw)
  To: intel-gfx
  Cc: linux-fbdev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard, dri-devel

If we fail to remove a conflicting fb driver, we need to abort the
loading of the second driver to avoid likely kernel panics.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
 include/linux/fb.h    |  4 ++--
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 010d19105ebc..e296967a3abb 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
 static int do_unregister_framebuffer(struct fb_info *fb_info);
 
 #define VGA_FB_PHYS 0xA0000
-static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
-				     const char *name, bool primary)
+static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
+					      const char *name, bool primary)
 {
-	int i;
+	int i, ret;
 
 	/* check all firmware fbs and kick off if the base addr overlaps */
 	for (i = 0 ; i < FB_MAX; i++) {
@@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
 			printk(KERN_INFO "fb: conflicting fb hw usage "
 			       "%s vs %s - removing generic driver\n",
 			       name, registered_fb[i]->fix.id);
-			do_unregister_framebuffer(registered_fb[i]);
+			ret = do_unregister_framebuffer(registered_fb[i]);
+			if (ret)
+				return ret;
 		}
 	}
+
+	return 0;
 }
 
 static int do_register_framebuffer(struct fb_info *fb_info)
 {
-	int i;
+	int i, ret;
 	struct fb_event event;
 	struct fb_videomode mode;
 
 	if (fb_check_foreignness(fb_info))
 		return -ENOSYS;
 
-	do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
-					 fb_is_primary_device(fb_info));
+	ret = do_remove_conflicting_framebuffers(fb_info->apertures,
+						 fb_info->fix.id,
+						 fb_is_primary_device(fb_info));
+	if (ret)
+		return ret;
 
 	if (num_registered_fb = FB_MAX)
 		return -ENXIO;
@@ -1739,12 +1746,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
 }
 EXPORT_SYMBOL(unlink_framebuffer);
 
-void remove_conflicting_framebuffers(struct apertures_struct *a,
-				     const char *name, bool primary)
+int remove_conflicting_framebuffers(struct apertures_struct *a,
+				    const char *name, bool primary)
 {
+	int ret;
+
 	mutex_lock(&registration_lock);
-	do_remove_conflicting_framebuffers(a, name, primary);
+	ret = do_remove_conflicting_framebuffers(a, name, primary);
 	mutex_unlock(&registration_lock);
+
+	return ret;
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
 
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 70c4836e4a9f..fe6ac956550e 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -613,8 +613,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 extern int register_framebuffer(struct fb_info *fb_info);
 extern int unregister_framebuffer(struct fb_info *fb_info);
 extern int unlink_framebuffer(struct fb_info *fb_info);
-extern void remove_conflicting_framebuffers(struct apertures_struct *a,
-				const char *name, bool primary);
+extern int remove_conflicting_framebuffers(struct apertures_struct *a,
+					   const char *name, bool primary);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
 extern int fb_show_logo(struct fb_info *fb_info, int rotate);
 extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
@ 2013-12-16 15:57 ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2013-12-16 15:57 UTC (permalink / raw)
  To: intel-gfx
  Cc: linux-fbdev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard, dri-devel

If we fail to remove a conflicting fb driver, we need to abort the
loading of the second driver to avoid likely kernel panics.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
 include/linux/fb.h    |  4 ++--
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 010d19105ebc..e296967a3abb 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
 static int do_unregister_framebuffer(struct fb_info *fb_info);
 
 #define VGA_FB_PHYS 0xA0000
-static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
-				     const char *name, bool primary)
+static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
+					      const char *name, bool primary)
 {
-	int i;
+	int i, ret;
 
 	/* check all firmware fbs and kick off if the base addr overlaps */
 	for (i = 0 ; i < FB_MAX; i++) {
@@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
 			printk(KERN_INFO "fb: conflicting fb hw usage "
 			       "%s vs %s - removing generic driver\n",
 			       name, registered_fb[i]->fix.id);
-			do_unregister_framebuffer(registered_fb[i]);
+			ret = do_unregister_framebuffer(registered_fb[i]);
+			if (ret)
+				return ret;
 		}
 	}
+
+	return 0;
 }
 
 static int do_register_framebuffer(struct fb_info *fb_info)
 {
-	int i;
+	int i, ret;
 	struct fb_event event;
 	struct fb_videomode mode;
 
 	if (fb_check_foreignness(fb_info))
 		return -ENOSYS;
 
-	do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
-					 fb_is_primary_device(fb_info));
+	ret = do_remove_conflicting_framebuffers(fb_info->apertures,
+						 fb_info->fix.id,
+						 fb_is_primary_device(fb_info));
+	if (ret)
+		return ret;
 
 	if (num_registered_fb == FB_MAX)
 		return -ENXIO;
@@ -1739,12 +1746,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
 }
 EXPORT_SYMBOL(unlink_framebuffer);
 
-void remove_conflicting_framebuffers(struct apertures_struct *a,
-				     const char *name, bool primary)
+int remove_conflicting_framebuffers(struct apertures_struct *a,
+				    const char *name, bool primary)
 {
+	int ret;
+
 	mutex_lock(&registration_lock);
-	do_remove_conflicting_framebuffers(a, name, primary);
+	ret = do_remove_conflicting_framebuffers(a, name, primary);
 	mutex_unlock(&registration_lock);
+
+	return ret;
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
 
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 70c4836e4a9f..fe6ac956550e 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -613,8 +613,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 extern int register_framebuffer(struct fb_info *fb_info);
 extern int unregister_framebuffer(struct fb_info *fb_info);
 extern int unlink_framebuffer(struct fb_info *fb_info);
-extern void remove_conflicting_framebuffers(struct apertures_struct *a,
-				const char *name, bool primary);
+extern int remove_conflicting_framebuffers(struct apertures_struct *a,
+					   const char *name, bool primary);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
 extern int fb_show_logo(struct fb_info *fb_info, int rotate);
 extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] drm/i915: Handle failure to kick out a conflicting fb driver
  2013-12-16 15:57 ` Chris Wilson
  (?)
@ 2013-12-16 15:57 ` Chris Wilson
  2013-12-17  7:33   ` Jani Nikula
  -1 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2013-12-16 15:57 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_dma.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 6364c503f97d..6de3a43e3acf 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1414,15 +1414,16 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
 }
 
 #ifdef CONFIG_DRM_I915_FBDEV
-static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
+static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
 {
 	struct apertures_struct *ap;
 	struct pci_dev *pdev = dev_priv->dev->pdev;
 	bool primary;
+	int ret;
 
 	ap = alloc_apertures(1);
 	if (!ap)
-		return;
+		return -ENOMEM;
 
 	ap->ranges[0].base = dev_priv->gtt.mappable_base;
 	ap->ranges[0].size = dev_priv->gtt.mappable_end;
@@ -1430,13 +1431,16 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
 	primary =
 		pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
 
-	remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
+	ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
 
 	kfree(ap);
+
+	return ret;
 }
 #else
-static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
+static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
 {
+	return 0;
 }
 #endif
 
@@ -1552,8 +1556,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto out_regs;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
-		i915_kick_out_firmware_fb(dev_priv);
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = i915_kick_out_firmware_fb(dev_priv);
+		if (ret) {
+			DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
+			goto out_gtt;
+		}
+	}
 
 	pci_set_master(dev->pdev);
 
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
  2013-12-16 15:57 ` Chris Wilson
@ 2013-12-17  7:33   ` Jani Nikula
  -1 siblings, 0 replies; 11+ messages in thread
From: Jani Nikula @ 2013-12-17  7:33 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx
  Cc: linux-fbdev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard, dri-devel

On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> If we fail to remove a conflicting fb driver, we need to abort the
> loading of the second driver to avoid likely kernel panics.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: linux-fbdev@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
>  include/linux/fb.h    |  4 ++--
>  2 files changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 010d19105ebc..e296967a3abb 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
>  static int do_unregister_framebuffer(struct fb_info *fb_info);
>  
>  #define VGA_FB_PHYS 0xA0000
> -static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> -				     const char *name, bool primary)
> +static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
> +					      const char *name, bool primary)
>  {
> -	int i;
> +	int i, ret;
>  
>  	/* check all firmware fbs and kick off if the base addr overlaps */
>  	for (i = 0 ; i < FB_MAX; i++) {
> @@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
>  			printk(KERN_INFO "fb: conflicting fb hw usage "
>  			       "%s vs %s - removing generic driver\n",
>  			       name, registered_fb[i]->fix.id);
> -			do_unregister_framebuffer(registered_fb[i]);
> +			ret = do_unregister_framebuffer(registered_fb[i]);
> +			if (ret)
> +				return ret;

An observation, this bails out early instead of trying to unregister all
the conflicting framebuffers regardless of errors like before. We're
probably doomed either way?

Reviewed-by: Jani Nikula <jani.nikula@intel.com>



>  		}
>  	}
> +
> +	return 0;
>  }
>  
>  static int do_register_framebuffer(struct fb_info *fb_info)
>  {
> -	int i;
> +	int i, ret;
>  	struct fb_event event;
>  	struct fb_videomode mode;
>  
>  	if (fb_check_foreignness(fb_info))
>  		return -ENOSYS;
>  
> -	do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
> -					 fb_is_primary_device(fb_info));
> +	ret = do_remove_conflicting_framebuffers(fb_info->apertures,
> +						 fb_info->fix.id,
> +						 fb_is_primary_device(fb_info));
> +	if (ret)
> +		return ret;
>  
>  	if (num_registered_fb = FB_MAX)
>  		return -ENXIO;
> @@ -1739,12 +1746,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
>  }
>  EXPORT_SYMBOL(unlink_framebuffer);
>  
> -void remove_conflicting_framebuffers(struct apertures_struct *a,
> -				     const char *name, bool primary)
> +int remove_conflicting_framebuffers(struct apertures_struct *a,
> +				    const char *name, bool primary)
>  {
> +	int ret;
> +
>  	mutex_lock(&registration_lock);
> -	do_remove_conflicting_framebuffers(a, name, primary);
> +	ret = do_remove_conflicting_framebuffers(a, name, primary);
>  	mutex_unlock(&registration_lock);
> +
> +	return ret;
>  }
>  EXPORT_SYMBOL(remove_conflicting_framebuffers);
>  
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 70c4836e4a9f..fe6ac956550e 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -613,8 +613,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
>  extern int register_framebuffer(struct fb_info *fb_info);
>  extern int unregister_framebuffer(struct fb_info *fb_info);
>  extern int unlink_framebuffer(struct fb_info *fb_info);
> -extern void remove_conflicting_framebuffers(struct apertures_struct *a,
> -				const char *name, bool primary);
> +extern int remove_conflicting_framebuffers(struct apertures_struct *a,
> +					   const char *name, bool primary);
>  extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
>  extern int fb_show_logo(struct fb_info *fb_info, int rotate);
>  extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
> -- 
> 1.8.5.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
@ 2013-12-17  7:33   ` Jani Nikula
  0 siblings, 0 replies; 11+ messages in thread
From: Jani Nikula @ 2013-12-17  7:33 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx
  Cc: linux-fbdev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard, dri-devel

On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> If we fail to remove a conflicting fb driver, we need to abort the
> loading of the second driver to avoid likely kernel panics.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: linux-fbdev@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
>  include/linux/fb.h    |  4 ++--
>  2 files changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 010d19105ebc..e296967a3abb 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
>  static int do_unregister_framebuffer(struct fb_info *fb_info);
>  
>  #define VGA_FB_PHYS 0xA0000
> -static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> -				     const char *name, bool primary)
> +static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
> +					      const char *name, bool primary)
>  {
> -	int i;
> +	int i, ret;
>  
>  	/* check all firmware fbs and kick off if the base addr overlaps */
>  	for (i = 0 ; i < FB_MAX; i++) {
> @@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
>  			printk(KERN_INFO "fb: conflicting fb hw usage "
>  			       "%s vs %s - removing generic driver\n",
>  			       name, registered_fb[i]->fix.id);
> -			do_unregister_framebuffer(registered_fb[i]);
> +			ret = do_unregister_framebuffer(registered_fb[i]);
> +			if (ret)
> +				return ret;

An observation, this bails out early instead of trying to unregister all
the conflicting framebuffers regardless of errors like before. We're
probably doomed either way?

Reviewed-by: Jani Nikula <jani.nikula@intel.com>



>  		}
>  	}
> +
> +	return 0;
>  }
>  
>  static int do_register_framebuffer(struct fb_info *fb_info)
>  {
> -	int i;
> +	int i, ret;
>  	struct fb_event event;
>  	struct fb_videomode mode;
>  
>  	if (fb_check_foreignness(fb_info))
>  		return -ENOSYS;
>  
> -	do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
> -					 fb_is_primary_device(fb_info));
> +	ret = do_remove_conflicting_framebuffers(fb_info->apertures,
> +						 fb_info->fix.id,
> +						 fb_is_primary_device(fb_info));
> +	if (ret)
> +		return ret;
>  
>  	if (num_registered_fb == FB_MAX)
>  		return -ENXIO;
> @@ -1739,12 +1746,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
>  }
>  EXPORT_SYMBOL(unlink_framebuffer);
>  
> -void remove_conflicting_framebuffers(struct apertures_struct *a,
> -				     const char *name, bool primary)
> +int remove_conflicting_framebuffers(struct apertures_struct *a,
> +				    const char *name, bool primary)
>  {
> +	int ret;
> +
>  	mutex_lock(&registration_lock);
> -	do_remove_conflicting_framebuffers(a, name, primary);
> +	ret = do_remove_conflicting_framebuffers(a, name, primary);
>  	mutex_unlock(&registration_lock);
> +
> +	return ret;
>  }
>  EXPORT_SYMBOL(remove_conflicting_framebuffers);
>  
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 70c4836e4a9f..fe6ac956550e 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -613,8 +613,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
>  extern int register_framebuffer(struct fb_info *fb_info);
>  extern int unregister_framebuffer(struct fb_info *fb_info);
>  extern int unlink_framebuffer(struct fb_info *fb_info);
> -extern void remove_conflicting_framebuffers(struct apertures_struct *a,
> -				const char *name, bool primary);
> +extern int remove_conflicting_framebuffers(struct apertures_struct *a,
> +					   const char *name, bool primary);
>  extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
>  extern int fb_show_logo(struct fb_info *fb_info, int rotate);
>  extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
> -- 
> 1.8.5.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] drm/i915: Handle failure to kick out a conflicting fb driver
  2013-12-16 15:57 ` [PATCH 2/2] drm/i915: Handle failure to kick out a conflicting fb driver Chris Wilson
@ 2013-12-17  7:33   ` Jani Nikula
  2014-07-14 15:15     ` Daniel Vetter
  0 siblings, 1 reply; 11+ messages in thread
From: Jani Nikula @ 2013-12-17  7:33 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_dma.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 6364c503f97d..6de3a43e3acf 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1414,15 +1414,16 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
>  }
>  
>  #ifdef CONFIG_DRM_I915_FBDEV
> -static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> +static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
>  {
>  	struct apertures_struct *ap;
>  	struct pci_dev *pdev = dev_priv->dev->pdev;
>  	bool primary;
> +	int ret;
>  
>  	ap = alloc_apertures(1);
>  	if (!ap)
> -		return;
> +		return -ENOMEM;
>  
>  	ap->ranges[0].base = dev_priv->gtt.mappable_base;
>  	ap->ranges[0].size = dev_priv->gtt.mappable_end;
> @@ -1430,13 +1431,16 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
>  	primary =
>  		pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
>  
> -	remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
> +	ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
>  
>  	kfree(ap);
> +
> +	return ret;
>  }
>  #else
> -static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> +static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
>  {
> +	return 0;
>  }
>  #endif
>  
> @@ -1552,8 +1556,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
>  	if (ret)
>  		goto out_regs;
>  
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> -		i915_kick_out_firmware_fb(dev_priv);
> +	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> +		ret = i915_kick_out_firmware_fb(dev_priv);
> +		if (ret) {
> +			DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
> +			goto out_gtt;
> +		}
> +	}
>  
>  	pci_set_master(dev->pdev);
>  
> -- 
> 1.8.5.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
  2013-12-17  7:33   ` Jani Nikula
@ 2013-12-17 12:14     ` Chris Wilson
  -1 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2013-12-17 12:14 UTC (permalink / raw)
  To: Jani Nikula
  Cc: intel-gfx, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, dri-devel

On Tue, Dec 17, 2013 at 09:33:08AM +0200, Jani Nikula wrote:
> On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > If we fail to remove a conflicting fb driver, we need to abort the
> > loading of the second driver to avoid likely kernel panics.
> >
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > Cc: linux-fbdev@vger.kernel.org
> > Cc: dri-devel@lists.freedesktop.org
> > ---
> >  drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
> >  include/linux/fb.h    |  4 ++--
> >  2 files changed, 23 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> > index 010d19105ebc..e296967a3abb 100644
> > --- a/drivers/video/fbmem.c
> > +++ b/drivers/video/fbmem.c
> > @@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
> >  static int do_unregister_framebuffer(struct fb_info *fb_info);
> >  
> >  #define VGA_FB_PHYS 0xA0000
> > -static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> > -				     const char *name, bool primary)
> > +static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
> > +					      const char *name, bool primary)
> >  {
> > -	int i;
> > +	int i, ret;
> >  
> >  	/* check all firmware fbs and kick off if the base addr overlaps */
> >  	for (i = 0 ; i < FB_MAX; i++) {
> > @@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> >  			printk(KERN_INFO "fb: conflicting fb hw usage "
> >  			       "%s vs %s - removing generic driver\n",
> >  			       name, registered_fb[i]->fix.id);
> > -			do_unregister_framebuffer(registered_fb[i]);
> > +			ret = do_unregister_framebuffer(registered_fb[i]);
> > +			if (ret)
> > +				return ret;
> 
> An observation, this bails out early instead of trying to unregister all
> the conflicting framebuffers regardless of errors like before. We're
> probably doomed either way?

Indeed. Early exit hopefully leaves the machine usable for bug reporting.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
@ 2013-12-17 12:14     ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2013-12-17 12:14 UTC (permalink / raw)
  To: Jani Nikula
  Cc: intel-gfx, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, dri-devel

On Tue, Dec 17, 2013 at 09:33:08AM +0200, Jani Nikula wrote:
> On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > If we fail to remove a conflicting fb driver, we need to abort the
> > loading of the second driver to avoid likely kernel panics.
> >
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > Cc: linux-fbdev@vger.kernel.org
> > Cc: dri-devel@lists.freedesktop.org
> > ---
> >  drivers/video/fbmem.c | 31 +++++++++++++++++++++----------
> >  include/linux/fb.h    |  4 ++--
> >  2 files changed, 23 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> > index 010d19105ebc..e296967a3abb 100644
> > --- a/drivers/video/fbmem.c
> > +++ b/drivers/video/fbmem.c
> > @@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
> >  static int do_unregister_framebuffer(struct fb_info *fb_info);
> >  
> >  #define VGA_FB_PHYS 0xA0000
> > -static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> > -				     const char *name, bool primary)
> > +static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
> > +					      const char *name, bool primary)
> >  {
> > -	int i;
> > +	int i, ret;
> >  
> >  	/* check all firmware fbs and kick off if the base addr overlaps */
> >  	for (i = 0 ; i < FB_MAX; i++) {
> > @@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
> >  			printk(KERN_INFO "fb: conflicting fb hw usage "
> >  			       "%s vs %s - removing generic driver\n",
> >  			       name, registered_fb[i]->fix.id);
> > -			do_unregister_framebuffer(registered_fb[i]);
> > +			ret = do_unregister_framebuffer(registered_fb[i]);
> > +			if (ret)
> > +				return ret;
> 
> An observation, this bails out early instead of trying to unregister all
> the conflicting framebuffers regardless of errors like before. We're
> probably doomed either way?

Indeed. Early exit hopefully leaves the machine usable for bug reporting.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
  2013-12-17 12:14     ` Chris Wilson
@ 2013-12-18  0:56       ` Dave Airlie
  -1 siblings, 0 replies; 11+ messages in thread
From: Dave Airlie @ 2013-12-18  0:56 UTC (permalink / raw)
  To: Chris Wilson, Jani Nikula, intel-gfx,
	Linux Fbdev development list, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, dri-devel

On Tue, Dec 17, 2013 at 10:14 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, Dec 17, 2013 at 09:33:08AM +0200, Jani Nikula wrote:
>> On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > If we fail to remove a conflicting fb driver, we need to abort the
>> > loading of the second driver to avoid likely kernel panics.
>> >
>> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> > Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> > Cc: linux-fbdev@vger.kernel.org
>> > Cc: dri-devel@lists.freedesktop.org

I'll merge this via the drm tree,

Dave.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb
@ 2013-12-18  0:56       ` Dave Airlie
  0 siblings, 0 replies; 11+ messages in thread
From: Dave Airlie @ 2013-12-18  0:56 UTC (permalink / raw)
  To: Chris Wilson, Jani Nikula, intel-gfx,
	Linux Fbdev development list, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, dri-devel

On Tue, Dec 17, 2013 at 10:14 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Tue, Dec 17, 2013 at 09:33:08AM +0200, Jani Nikula wrote:
>> On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > If we fail to remove a conflicting fb driver, we need to abort the
>> > loading of the second driver to avoid likely kernel panics.
>> >
>> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> > Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> > Cc: linux-fbdev@vger.kernel.org
>> > Cc: dri-devel@lists.freedesktop.org

I'll merge this via the drm tree,

Dave.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] drm/i915: Handle failure to kick out a conflicting fb driver
  2013-12-17  7:33   ` Jani Nikula
@ 2014-07-14 15:15     ` Daniel Vetter
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Vetter @ 2014-07-14 15:15 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Tue, Dec 17, 2013 at 09:33:27AM +0200, Jani Nikula wrote:
> On Mon, 16 Dec 2013, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Queued for -next, thanks for the patch.
-Daniel
> 
> > ---
> >  drivers/gpu/drm/i915/i915_dma.c | 21 +++++++++++++++------
> >  1 file changed, 15 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > index 6364c503f97d..6de3a43e3acf 100644
> > --- a/drivers/gpu/drm/i915/i915_dma.c
> > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > @@ -1414,15 +1414,16 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
> >  }
> >  
> >  #ifdef CONFIG_DRM_I915_FBDEV
> > -static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> > +static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> >  {
> >  	struct apertures_struct *ap;
> >  	struct pci_dev *pdev = dev_priv->dev->pdev;
> >  	bool primary;
> > +	int ret;
> >  
> >  	ap = alloc_apertures(1);
> >  	if (!ap)
> > -		return;
> > +		return -ENOMEM;
> >  
> >  	ap->ranges[0].base = dev_priv->gtt.mappable_base;
> >  	ap->ranges[0].size = dev_priv->gtt.mappable_end;
> > @@ -1430,13 +1431,16 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> >  	primary =
> >  		pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
> >  
> > -	remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
> > +	ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
> >  
> >  	kfree(ap);
> > +
> > +	return ret;
> >  }
> >  #else
> > -static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> > +static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
> >  {
> > +	return 0;
> >  }
> >  #endif
> >  
> > @@ -1552,8 +1556,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
> >  	if (ret)
> >  		goto out_regs;
> >  
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > -		i915_kick_out_firmware_fb(dev_priv);
> > +	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +		ret = i915_kick_out_firmware_fb(dev_priv);
> > +		if (ret) {
> > +			DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
> > +			goto out_gtt;
> > +		}
> > +	}
> >  
> >  	pci_set_master(dev->pdev);
> >  
> > -- 
> > 1.8.5.1
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-07-14 15:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-16 15:57 [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb Chris Wilson
2013-12-16 15:57 ` Chris Wilson
2013-12-16 15:57 ` [PATCH 2/2] drm/i915: Handle failure to kick out a conflicting fb driver Chris Wilson
2013-12-17  7:33   ` Jani Nikula
2014-07-14 15:15     ` Daniel Vetter
2013-12-17  7:33 ` [Intel-gfx] [PATCH 1/2] video/fb: Propagate error code from failing to unregister conflicting fb Jani Nikula
2013-12-17  7:33   ` Jani Nikula
2013-12-17 12:14   ` Chris Wilson
2013-12-17 12:14     ` Chris Wilson
2013-12-18  0:56     ` [Intel-gfx] " Dave Airlie
2013-12-18  0:56       ` Dave Airlie

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.