aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0105-sdk-qbman-fix-issue-in-qman_delete_cgr_safe.patch
blob: 830a2ec05b9920090e6ed5bf97cfb7add01d6272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pre { line-heig
From a16c129c9dfae01921faaed98587d318459d5cfc Mon Sep 17 00:00:00 2001
From: Zhao Qiang <qiang.zhao@nxp.com>
Date: Wed, 30 May 2018 17:09:02 +0800
Subject: [PATCH] sdk/qbman: fix issue in qman_delete_cgr_safe()

The wait_for_completion() call in qman_delete_cgr_safe()
was triggering a scheduling while atomic bug, replacing the
kthread with a smp_call_function_single() call to fix it.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
---
 drivers/staging/fsl_qbman/qman_high.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

--- a/drivers/staging/fsl_qbman/qman_high.c
+++ b/drivers/staging/fsl_qbman/qman_high.c
@@ -3075,36 +3075,19 @@ struct cgr_comp {
 	struct completion completion;
 };
 
-static int qman_delete_cgr_thread(void *p)
+static void qman_delete_cgr_smp_call(void *p)
 {
-	struct cgr_comp *cgr_comp = (struct cgr_comp *)p;
-	int res;
-
-	res = qman_delete_cgr((struct qman_cgr *)cgr_comp->cgr);
-	complete(&cgr_comp->completion);
-
-	return res;
+	qman_delete_cgr((struct qman_cgr *)p);
 }
 
 void qman_delete_cgr_safe(struct qman_cgr *cgr)
 {
-	struct task_struct *thread;
-	struct cgr_comp cgr_comp;
-
 	preempt_disable();
 	if (qman_cgr_cpus[cgr->cgrid] != smp_processor_id()) {
-		init_completion(&cgr_comp.completion);
-		cgr_comp.cgr = cgr;
-		thread = kthread_create(qman_delete_cgr_thread, &cgr_comp,
-					"cgr_del");
-
-		if (likely(!IS_ERR(thread))) {
-			kthread_bind(thread, qman_cgr_cpus[cgr->cgrid]);
-			wake_up_process(thread);
-			wait_for_completion(&cgr_comp.completion);
-			preempt_enable();
-			return;
-		}
+		smp_call_function_single(qman_cgr_cpus[cgr->cgrid],
+					 qman_delete_cgr_smp_call, cgr, true);
+		preempt_enable();
+		return;
 	}
 	qman_delete_cgr(cgr);
 	preempt_enable();
alse); break; case _DVORAK: oled_write_P(PSTR("Dvorak"), false); break; case _QWERTY: oled_write_P(PSTR("Qwerty"), false); break; default: oled_write_ln_P(PSTR("Undefined"), false); } } void oled_white_space(void){ oled_write_P(PSTR(" "), false); } void render_layer_state(void) { oled_write_P(PSTR("\nLayer:"), false); bool lower = layer_state_is(_LOWER) & !layer_state_is(_ADJUST); bool raise = layer_state_is(_RAISE) & !layer_state_is(_ADJUST); bool adjust = layer_state_is(_ADJUST); bool numpad = layer_state_is(_NUMPAD); if(lower){ oled_write_P(PSTR(" Lower "), true); } else if(raise){ oled_write_P(PSTR(" Raise "), true); } else if(adjust){ oled_write_P(PSTR(" Adjust "), true); } else if(numpad) { oled_write_P(PSTR(" Numpad "), true); } else { oled_write_P(PSTR(" Default"), false); } } void render_mod_state(uint8_t modifiers) { oled_write_P(PSTR("\nMods: "), false); oled_write_P(PSTR("SHF"), (modifiers & MOD_MASK_SHIFT)); oled_white_space(); oled_write_P(PSTR("CTL"), (modifiers & MOD_MASK_CTRL)); oled_white_space(); oled_write_P(PSTR("ALT"), (modifiers & MOD_MASK_ALT)); oled_white_space(); oled_write_P(PSTR("GUI"), (modifiers & MOD_MASK_GUI)); } void render_status(void){ render_layout_state(); oled_write_P(PSTR("\n"), false); render_layer_state(); render_mod_state(get_mods()|get_oneshot_mods()); } static void render_logo(void) { static const char PROGMEM qmk_logo[] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0}; oled_write_P(qmk_logo, false); } void oled_task_user(void) { if (timer_elapsed32(oled_timer) > 15000) { oled_off(); return; } #ifndef SPLIT_KEYBOARD else { oled_on(); } #endif if (is_master) { render_status(); } else { render_logo(); oled_write_P(PSTR("\n"), false); oled_scroll_left(); } } #endif