Skip to contentSkip to conversation

linux-next: kernel hangs at pwm bl probe

BUG Robert Jarzmik 2 participants 2 messages Aug 23, 2018 – Aug 24, 2018 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 3 lines · Enric Balletbo i Serra

Hi Robert,
Heiko reported me a similar issue yesterday, can you try if this patch fixes the issue?

Kind of ...

The good news : the kernel doesn't hang anymore.
The bad news :
- userspace compatibility is broken : from former 100 max brightness, now the max brightness is 682666 (see arch/arm/mach-pxa/mioa701.c:191)
- the brightness setting is eratic : a brightness of 300000 is brighter than a brightness of 600000

So in the current state, the backlight pwm is broken for my platforms, let's see what happens next.

Cheers.

Signature · 1 line
Robert
#3 lore raw

Hi Robert,

Quoted 5 lines · Robert Jarzmik
Quoted 3 lines · Enric Balletbo i Serra

Hi Robert,
Heiko reported me a similar issue yesterday, can you try if this patch fixes the issue?

Quoted 9 lines

Kind of ...

The good news : the kernel doesn't hang anymore.
The bad news :
- userspace compatibility is broken : from former 100 max brightness, now the max brightness is 682666 (see arch/arm/mach-pxa/mioa701.c:191)
- the brightness setting is eratic : a brightness of 300000 is brighter than a brightness of 600000

So, looks like I broke the non-dt case, sorry my bad. Could you test the attached patch? (note: applies with the patch applied before reverted)

I'll work on this and send a proper fix probably this afternoon.

Quoted 5 lines

So in the current state, the backlight pwm is broken for my platforms, let's see what happens next.

Cheers.

Thanks in advance,
Enric

drivers/video/backlight/pwm_bl.c +21 -12
index bdfcc0a71db1..b2e38b66ab14 100644
@@ -539,7 +539,20 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "got pwm for backlight\n");
 
-	if (!data->levels) {
+	/*
+	 * FIXME: pwm_apply_args() should be removed when switching to
+	 * the atomic PWM API.
+	 */
+	pwm_apply_args(pb->pwm);
+
+	if (data->levels) {
+		for (i = 0; i <= data->max_brightness; i++) {
+			if (data->levels[i] > pb->scale)
+				pb->scale = data->levels[i];
+
+			pb->levels = data->levels;
+		}
+	} else if (!data->levels && !data->max_brightness) {
 		/* Get the PWM period (in nanoseconds) */
 		pwm_get_state(pb->pwm, &state);
 
@@ -550,21 +563,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 				"failed to setup default brightness table\n");
 			goto err_alloc;
 		}
-	}
 
-	for (i = 0; i <= data->max_brightness; i++) {
-		if (data->levels[i] > pb->scale)
-			pb->scale = data->levels[i];
+		for (i = 0; i <= data->max_brightness; i++) {
+			if (data->levels[i] > pb->scale)
+				pb->scale = data->levels[i];
 
-		pb->levels = data->levels;
+			pb->levels = data->levels;
+		}
+	} else {
+		pb->scale = data->max_brightness;
 	}
 
-	/*
-	 * FIXME: pwm_apply_args() should be removed when switching to
-	 * the atomic PWM API.
-	 */
-	pwm_apply_args(pb->pwm);
-
 	/*
 	 * The DT case will set the pwm_period_ns field to 0 and store the
 	 * period, parsed from the DT, in the PWM device. For the non-DT case,