Skip to contentSkip to conversation

drm/msm: Fix gpu recovery path

PATCH In review Sharat Masetty 2 participants 5 messages Oct 12, 2018 2 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover drm/msm: Fix gpu recovery path

A few fixes for issues that I have seen in recovery path. The fix in lib/string is probably not needed anymore with the fixes in drm/msm, but I added it here nonetheless as it is good to have.

Sharat Masetty (3):
lib/string: Pass the input gfp flags to kmalloc drm/msm: Check if target supports crash dump capture drm/msm: Fix task dump in gpu recovery

 drivers/gpu/drm/msm/msm_gpu.c | 13 ++++++++-----
 lib/string_helpers.c          |  4 ++--
 2 files changed, 10 insertions(+), 7 deletions(-)

--
1.9.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 1539334616-11723-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#2 lore raw

PATCH 1/3 lib/string: Pass the input gfp flags to kmalloc

Pass the user sent gfp flags to kmalloc() calls. This helps calling the functions in user desired contexts.

---
 lib/string_helpers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/string_helpers.c +2 -2
index 29c490e..60f9015 100644
@@ -576,7 +576,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
 	char *buffer, *quoted;
 	int i, res;
 
-	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	buffer = kmalloc(PAGE_SIZE, gfp);
 	if (!buffer)
 		return NULL;
 
@@ -612,7 +612,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
 		return kstrdup("<unknown>", gfp);
 
 	/* We add 11 spaces for ' (deleted)' to be appended */
-	temp = kmalloc(PATH_MAX + 11, GFP_KERNEL);
+	temp = kmalloc(PATH_MAX + 11, gfp);
 	if (!temp)
 		return kstrdup("<no_memory>", gfp);
 
Signature · 6 lines
1.9.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 1539334616-11723-2-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#4 lore raw

Re: [PATCH 1/3] lib/string: Pass the input gfp flags to kmalloc

Thanks, I've pushed 2 and 3 to msm-next, since these should probably go in a -fixes pr for 4.20

This one, you might want to resend w/ --cc-cmd=./scripts/get_maintainer.pl so that it gets seen by someone who could apply it

fwiw, I use

git config sendemail.cccmd './scripts/get_maintainer.pl -i'

to make that automatic, but to give me a way to edit the list of cc's that get_maintainer.pl adds

BR,
-R

Quoted 34 lines · Sharat Masetty

Pass the user sent gfp flags to kmalloc() calls. This helps calling the functions in user desired contexts.

---
 lib/string_helpers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/string_helpers.c +2 -3
index 29c490e..60f9015 100644
@@ -576,7 +576,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
        char *buffer, *quoted;
        int i, res;
 
-       buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       buffer = kmalloc(PAGE_SIZE, gfp);
        if (!buffer)
                return NULL;
 
@@ -612,7 +612,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
                return kstrdup("<unknown>", gfp);
 
        /* We add 11 spaces for ' (deleted)' to be appended */
-       temp = kmalloc(PATH_MAX + 11, GFP_KERNEL);
+       temp = kmalloc(PATH_MAX + 11, gfp);
        if (!temp)
                return kstrdup("<no_memory>", gfp);
 
--

1.9.1

Quoted 4 lines

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

#5 lore raw

PATCH 2/3 drm/msm: Check if target supports crash dump capture

In reply to a message not in the archive

This patch simply checks first to see if the target can support crash dump capture before proceeding.

---
 drivers/gpu/drm/msm/msm_gpu.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/msm_gpu.c +4 -0
index 19b4afe..da63d3d 100644
@@ -345,6 +345,10 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu,
 {
 	struct msm_gpu_state *state;
 
+	/* Check if the target supports capturing crash state */
+	if (!gpu->funcs->gpu_state_get)
+		return;
+
 	/* Only save one crash state at a time */
 	if (gpu->crashstate)
 		return;
Signature · 6 lines
1.9.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#6 lore raw

PATCH 3/3 drm/msm: Fix task dump in gpu recovery

In reply to a message not in the archive

The current recovery code gets a pointer to the task struct and does a few things all within the rcu_read_lock. This puts constraints on the types of gfp flags that can be used within the rcu lock. This patch instead gets a reference to the task within the rcu lock and releases the lock immediately, this way the task stays afloat until we need it and we also get to use the desired gfp flags.

---
 drivers/gpu/drm/msm/msm_gpu.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/msm_gpu.c +4 -5
index da63d3d..ca573f6 100644
@@ -438,10 +438,9 @@ static void recover_worker(struct work_struct *work)
 	if (submit) {
 		struct task_struct *task;
 
-		rcu_read_lock();
-		task = pid_task(submit->pid, PIDTYPE_PID);
+		task = get_pid_task(submit->pid, PIDTYPE_PID);
 		if (task) {
-			comm = kstrdup(task->comm, GFP_ATOMIC);
+			comm = kstrdup(task->comm, GFP_KERNEL);
 
 			/*
 			 * So slightly annoying, in other paths like
@@ -454,10 +453,10 @@ static void recover_worker(struct work_struct *work)
 			 * about the submit going away.
 			 */
 			mutex_unlock(&dev->struct_mutex);
-			cmd = kstrdup_quotable_cmdline(task, GFP_ATOMIC);
+			cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL);
+			put_task_struct(task);
 			mutex_lock(&dev->struct_mutex);
 		}
-		rcu_read_unlock();
 
 		if (comm && cmd) {
 			dev_err(dev->dev, "%s: offending task: %s (%s)\n",
Signature · 6 lines
1.9.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno