dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ast fix patches
@ 2017-07-18 14:47 Takashi Iwai
  2017-07-18 14:47 ` [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin() Takashi Iwai
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

Hi,

here is another clearance sale, a patchset containing fixes for ast
driver, dug from openSUSE / SUSE kernels.  All fixes came from
Egbert.


thanks,

Takashi

===

Egbert Eich (5):
  drm/ast: Simplify function ast_bo_unpin()
  drm/ast: Free container instead of member in
    ast_user_framebuffer_destroy()
  drm/ast: Fix memleak in error path in ast_bo_create()
  drm/ast: Add an crtc_disable callback to the crtc helper funcs
  drm/ast: Actually load DP501 firmware when required

 drivers/gpu/drm/ast/ast_dp501.c | 25 ++++++++++++++++---------
 drivers/gpu/drm/ast/ast_drv.h   |  3 +--
 drivers/gpu/drm/ast/ast_main.c  |  3 ++-
 drivers/gpu/drm/ast/ast_mode.c  | 16 ++++++++++++++++
 drivers/gpu/drm/ast/ast_ttm.c   | 19 ++++++++-----------
 5 files changed, 43 insertions(+), 23 deletions(-)

-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin()
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
@ 2017-07-18 14:47 ` Takashi Iwai
  2017-07-18 14:47 ` [PATCH 2/5] drm/ast: Free container instead of member in ast_user_framebuffer_destroy() Takashi Iwai
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

From: Egbert Eich <eich@suse.de>

Just a code refactoring, no functional change.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/ast/ast_ttm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 58084985e6cf..0b4c574defe7 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -376,7 +376,7 @@ int ast_bo_pin(struct ast_bo *bo, u32 pl_flag, u64 *gpu_addr)
 
 int ast_bo_unpin(struct ast_bo *bo)
 {
-	int i, ret;
+	int i;
 	if (!bo->pin_count) {
 		DRM_ERROR("unpin bad %p\n", bo);
 		return 0;
@@ -387,11 +387,7 @@ int ast_bo_unpin(struct ast_bo *bo)
 
 	for (i = 0; i < bo->placement.num_placement ; i++)
 		bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
-	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ttm_bo_validate(&bo->bo, &bo->placement, false, false);
 }
 
 int ast_bo_push_sysram(struct ast_bo *bo)
-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 2/5] drm/ast: Free container instead of member in ast_user_framebuffer_destroy()
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
  2017-07-18 14:47 ` [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin() Takashi Iwai
@ 2017-07-18 14:47 ` Takashi Iwai
  2017-07-18 14:47 ` [PATCH 3/5] drm/ast: Fix memleak in error path in ast_bo_create() Takashi Iwai
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

From: Egbert Eich <eich@suse.de>

Technically freeing ast_fb->base is the same as freeing ast_fb as 'base'
the first member of the data structure.
Still this makes it cleaner.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/ast/ast_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 262c2c0e43b4..50a8512ea646 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -389,7 +389,7 @@ static void ast_user_framebuffer_destroy(struct drm_framebuffer *fb)
 
 	drm_gem_object_unreference_unlocked(ast_fb->obj);
 	drm_framebuffer_cleanup(fb);
-	kfree(fb);
+	kfree(ast_fb);
 }
 
 static const struct drm_framebuffer_funcs ast_fb_funcs = {
-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 3/5] drm/ast: Fix memleak in error path in ast_bo_create()
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
  2017-07-18 14:47 ` [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin() Takashi Iwai
  2017-07-18 14:47 ` [PATCH 2/5] drm/ast: Free container instead of member in ast_user_framebuffer_destroy() Takashi Iwai
@ 2017-07-18 14:47 ` Takashi Iwai
  2017-07-18 14:47 ` [PATCH 4/5] drm/ast: Add an crtc_disable callback to the crtc helper funcs Takashi Iwai
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

From: Egbert Eich <eich@suse.de>

The allocated struct ast_bo was not freed in all error paths.
This patch consolidates error handling and fixes this.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/ast/ast_ttm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 0b4c574defe7..696a15dc2f3f 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -323,10 +323,8 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
 		return -ENOMEM;
 
 	ret = drm_gem_object_init(dev, &astbo->gem, size);
-	if (ret) {
-		kfree(astbo);
-		return ret;
-	}
+	if (ret)
+		goto error;
 
 	astbo->bo.bdev = &ast->ttm.bdev;
 
@@ -340,10 +338,13 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
 			  align >> PAGE_SHIFT, false, NULL, acc_size,
 			  NULL, NULL, ast_bo_ttm_destroy);
 	if (ret)
-		return ret;
+		goto error;
 
 	*pastbo = astbo;
 	return 0;
+error:
+	kfree(astbo);
+	return ret;
 }
 
 static inline u64 ast_bo_gpu_offset(struct ast_bo *bo)
-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 4/5] drm/ast: Add an crtc_disable callback to the crtc helper funcs
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
                   ` (2 preceding siblings ...)
  2017-07-18 14:47 ` [PATCH 3/5] drm/ast: Fix memleak in error path in ast_bo_create() Takashi Iwai
@ 2017-07-18 14:47 ` Takashi Iwai
  2017-07-18 14:47 ` [PATCH 5/5] drm/ast: Actually load DP501 firmware when required Takashi Iwai
  2017-08-02  2:21 ` [PATCH 0/5] ast fix patches Dave Airlie
  5 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

From: Egbert Eich <eich@suse.de>

Implement the proper CRTC disablement, just like done in mgag200
driver.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/ast/ast_mode.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index aaef0a652f10..3549a3356afe 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -613,7 +613,23 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc,
 
 static void ast_crtc_disable(struct drm_crtc *crtc)
 {
+	int ret;
+
+	DRM_DEBUG_KMS("\n");
+	ast_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+	if (crtc->primary->fb) {
+		struct ast_framebuffer *ast_fb = to_ast_framebuffer(crtc->primary->fb);
+		struct drm_gem_object *obj = ast_fb->obj;
+		struct ast_bo *bo = gem_to_ast_bo(obj);
+
+		ret = ast_bo_reserve(bo, false);
+		if (ret)
+			return;
 
+		ast_bo_push_sysram(bo);
+		ast_bo_unreserve(bo);
+	}
+	crtc->primary->fb = NULL;
 }
 
 static void ast_crtc_prepare(struct drm_crtc *crtc)
-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 5/5] drm/ast: Actually load DP501 firmware when required
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
                   ` (3 preceding siblings ...)
  2017-07-18 14:47 ` [PATCH 4/5] drm/ast: Add an crtc_disable callback to the crtc helper funcs Takashi Iwai
@ 2017-07-18 14:47 ` Takashi Iwai
  2017-08-02  2:21 ` [PATCH 0/5] ast fix patches Dave Airlie
  5 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2017-07-18 14:47 UTC (permalink / raw)
  To: dri-devel; +Cc: Egbert Eich, Dave Airlie, Daniel Vetter

From: Egbert Eich <eich@suse.de>

The ast driver has a code to load the DP501 firmware, but it's never
used.  This patch implements its actual usage by requesting the
firmware on demand, and release the firmware at exit as well.

Also the path contains a few cleanups and makes relevant functions
static.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/ast/ast_dp501.c | 25 ++++++++++++++++---------
 drivers/gpu/drm/ast/ast_drv.h   |  3 +--
 drivers/gpu/drm/ast/ast_main.c  |  1 +
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c
index 76f07f38b941..749646ae365f 100644
--- a/drivers/gpu/drm/ast/ast_dp501.c
+++ b/drivers/gpu/drm/ast/ast_dp501.c
@@ -4,16 +4,11 @@
 #include "ast_drv.h"
 MODULE_FIRMWARE("ast_dp501_fw.bin");
 
-int ast_load_dp501_microcode(struct drm_device *dev)
+static int ast_load_dp501_microcode(struct drm_device *dev)
 {
 	struct ast_private *ast = dev->dev_private;
-	static char *fw_name = "ast_dp501_fw.bin";
-	int err;
-	err = request_firmware(&ast->dp501_fw, fw_name, dev->dev);
-	if (err)
-		return err;
 
-	return 0;
+	return request_firmware(&ast->dp501_fw, "ast_dp501_fw.bin", dev->dev);
 }
 
 static void send_ack(struct ast_private *ast)
@@ -187,7 +182,7 @@ bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size)
 	return false;
 }
 
-bool ast_launch_m68k(struct drm_device *dev)
+static bool ast_launch_m68k(struct drm_device *dev)
 {
 	struct ast_private *ast = dev->dev_private;
 	u32 i, data, len = 0;
@@ -201,7 +196,11 @@ bool ast_launch_m68k(struct drm_device *dev)
 		if (ast->dp501_fw_addr) {
 			fw_addr = ast->dp501_fw_addr;
 			len = 32*1024;
-		} else if (ast->dp501_fw) {
+		} else {
+			if (!ast->dp501_fw &&
+			    ast_load_dp501_microcode(dev) < 0)
+				return false;
+
 			fw_addr = (u8 *)ast->dp501_fw->data;
 			len = ast->dp501_fw->size;
 		}
@@ -432,3 +431,11 @@ void ast_init_3rdtx(struct drm_device *dev)
 		}
 	}
 }
+
+void ast_release_firmware(struct drm_device *dev)
+{
+	struct ast_private *ast = dev->dev_private;
+
+	release_firmware(ast->dp501_fw);
+	ast->dp501_fw = NULL;
+}
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 8880f0b62e9c..7ded3b84237f 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -401,11 +401,10 @@ void ast_post_gpu(struct drm_device *dev);
 u32 ast_mindwm(struct ast_private *ast, u32 r);
 void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
 /* ast dp501 */
-int ast_load_dp501_microcode(struct drm_device *dev);
 void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
-bool ast_launch_m68k(struct drm_device *dev);
 bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
 bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
 u8 ast_get_dp501_max_clk(struct drm_device *dev);
 void ast_init_3rdtx(struct drm_device *dev);
+void ast_release_firmware(struct drm_device *dev);
 #endif
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 50a8512ea646..9a44cdec3bca 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -576,6 +576,7 @@ void ast_driver_unload(struct drm_device *dev)
 {
 	struct ast_private *ast = dev->dev_private;
 
+	ast_release_firmware(dev);
 	kfree(ast->dp501_fw_addr);
 	ast_mode_fini(dev);
 	ast_fbdev_fini(dev);
-- 
2.13.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/5] ast fix patches
  2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
                   ` (4 preceding siblings ...)
  2017-07-18 14:47 ` [PATCH 5/5] drm/ast: Actually load DP501 firmware when required Takashi Iwai
@ 2017-08-02  2:21 ` Dave Airlie
  5 siblings, 0 replies; 7+ messages in thread
From: Dave Airlie @ 2017-08-02  2:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Egbert Eich, Dave Airlie, dri-devel, Daniel Vetter

On 19 July 2017 at 00:47, Takashi Iwai <tiwai@suse.de> wrote:
> Hi,
>
> here is another clearance sale, a patchset containing fixes for ast
> driver, dug from openSUSE / SUSE kernels.  All fixes came from
> Egbert.

I've merged this set as is.

Thanks,
Dave.

>
>
> thanks,
>
> Takashi
>
> ===
>
> Egbert Eich (5):
>   drm/ast: Simplify function ast_bo_unpin()
>   drm/ast: Free container instead of member in
>     ast_user_framebuffer_destroy()
>   drm/ast: Fix memleak in error path in ast_bo_create()
>   drm/ast: Add an crtc_disable callback to the crtc helper funcs
>   drm/ast: Actually load DP501 firmware when required
>
>  drivers/gpu/drm/ast/ast_dp501.c | 25 ++++++++++++++++---------
>  drivers/gpu/drm/ast/ast_drv.h   |  3 +--
>  drivers/gpu/drm/ast/ast_main.c  |  3 ++-
>  drivers/gpu/drm/ast/ast_mode.c  | 16 ++++++++++++++++
>  drivers/gpu/drm/ast/ast_ttm.c   | 19 ++++++++-----------
>  5 files changed, 43 insertions(+), 23 deletions(-)
>
> --
> 2.13.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-08-02  2:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18 14:47 [PATCH 0/5] ast fix patches Takashi Iwai
2017-07-18 14:47 ` [PATCH 1/5] drm/ast: Simplify function ast_bo_unpin() Takashi Iwai
2017-07-18 14:47 ` [PATCH 2/5] drm/ast: Free container instead of member in ast_user_framebuffer_destroy() Takashi Iwai
2017-07-18 14:47 ` [PATCH 3/5] drm/ast: Fix memleak in error path in ast_bo_create() Takashi Iwai
2017-07-18 14:47 ` [PATCH 4/5] drm/ast: Add an crtc_disable callback to the crtc helper funcs Takashi Iwai
2017-07-18 14:47 ` [PATCH 5/5] drm/ast: Actually load DP501 firmware when required Takashi Iwai
2017-08-02  2:21 ` [PATCH 0/5] ast fix patches Dave Airlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).