Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sunxigpio vs. LOCKDEBUG (PR 54664)

Yeah don't commit that, that's pretty gross as-is:
 1) Silent failure in the kmem_alloc failure path.
 2) No comment describing _why_ it's doing this bad thing.

How about adding a struct fdtbus_regulator to struct fdtbus_regulator_controller? Then container_of() magic to derive the controller from the regulator handle in subsequent fdtbus_regulator_* calls, and we can avoid the allocation completely.

Take care,

On Thu, 5 Aug 2021, Tobias Nygren wrote:


sunxi boards can't boot LOCKDEBUG kernels. As I described
in the PR:

The problem is that sunxi_pinctrl_set_config() calls
fdtbus_regulator_acquire() with spin mutex
sunxi_gpio_softc.sc_lock held, but fdtbus_regulator_acquire()
calls kmem_alloc with flag KM_SLEEP. That's not permitted.

Refactoring sunxi_gpio to not hold it's sc lock seems
not straightforward. Any objections to this patch?
I'm not a fan of using KM_NOSLEEP, but don't have any
better ideas ...

--- sys/dev/fdt/fdt_regulator.c	27 May 2019 23:18:33 -0000	1.8
+++ sys/dev/fdt/fdt_regulator.c	5 Aug 2021 18:29:22 -0000
@@ -99,13 +99,16 @@ fdtbus_regulator_acquire(int phandle, co
		return NULL;

+	reg = kmem_alloc(sizeof(*reg), KM_NOSLEEP);
+	if (!reg) {
+		return NULL;
+	}
	error = rc->rc_funcs->acquire(rc->rc_dev);
	if (error) {
		aprint_error_dev(rc->rc_dev, "failed to acquire regulator: %d\n", error);
+		kmem_free(reg, sizeof(*reg));
		return NULL;
-	reg = kmem_alloc(sizeof(*reg), KM_SLEEP);
	reg->reg_rc = rc;

	return reg;

Home | Main Index | Thread Index | Old Index