Port-arm archive

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

Re: PocketCHIP can't boot.



On Tue, Oct 16, 2018 at 09:40:01AM +0900, Gmail TM wrote:
> Hi everyone!!
> 
> Now I try to boot PocketCHIP for upcoming event KOF2018 https://www.k-of.jp/2018/ at 2018/11/9,10.
> 
> But it halt at below:
> 
> [   1.0000000] tcakp0 at iic1 addr 0x34: TCA8418
> [   1.0000000] panic: kernel diagnostic assertion "sc->sc_inuse" failed: file "/usr/src/sys/dev/i2c/gttwsi_core.c", line 284 
> [   1.0000000] cpu0: Begin traceback...
> [   1.0000000] 0x8081b7ec: netbsd:db_panic+0x14
> [   1.0000000] 0x8081b804: netbsd:vpanic+0x194
> [   1.0000000] 0x8081b81c: netbsd:__aeabi_uldivmod
> [   1.0000000] 0x8081b864: netbsd:gttwsi_initiate_xfer+0x120
> [   1.0000000] 0x8081b8dc: netbsd:iic_exec+0x450
> [   1.0000000] 0x8081b944: netbsd:tcakp_attach+0x240
> [   1.0000000] 0x8081b97c: netbsd:config_attach_loc+0x1b4
> [   1.0000000] 0x8081b9ac: netbsd:config_found_sm_loc+0x54
> [   1.0000000] 0x8081ba44: netbsd:iic_attach+0x468
> [   1.0000000] 0x8081ba7c: netbsd:config_attach_loc+0x1b4
> [   1.0000000] 0x8081baac: netbsd:config_found_sm_loc+0x54
> [   1.0000000] 0x8081bac4: netbsd:config_found_ia+0x24
> [   1.0000000] 0x8081bafc: netbsd:fdtbus_attach_i2cbus+0xb4
> [   1.0000000] 0x8081bbd4: netbsd:sunxi_twi_attach+0x280
> [   1.0000000] 0x8081bc0c: netbsd:config_attach_loc+0x1b4
> [   1.0000000] 0x8081bc3c: netbsd:config_found_sm_loc+0x54
> [   1.0000000] 0x8081bdc4: netbsd:fdt_scan+0x188
> [   1.0000000] 0x8081bdf4: netbsd:fdt_attach+0xdc
> [   1.0000000] 0x8081be2c: netbsd:config_attach_loc+0x1b4
> [   1.0000000] 0x8081be5c: netbsd:config_found_sm_loc+0x54
> [   1.0000000] 0x8081be74: netbsd:config_found+0x2c
> [   1.0000000] 0x8081beac: netbsd:arm_fdt_attach+0x68
> [   1.0000000] 0x8081bee4: netbsd:config_attach_loc+0x1b4
> [   1.0000000] 0x8081bf0c: netbsd:config_rootfound+0x48
> [   1.0000000] 0x8081bf2c: netbsd:cpu_configure+0x58
> [   1.0000000] 0x8081bf9c: netbsd:main+0x2e8
> [   1.0000000] 0x8081bfac: netbsd:kernel_text+0x50
> [   1.0000000] cpu0: End traceback...
> Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        bx      r14
> 
> Full dmesg is at https://sacraya.610t.org/NetBSD/dmesg/dmesg.pocketchip.20181016.txt
> 
> Can this kernel panic fix easily?

The attached patch may work around the problem.
But we now have another problem: we may cv_wait() from interrupt context
in gttwsi_acquire_bus().

I don't think we can fix this without extending the interrupt API to allow
mask/unmask operation from drivers:
in a case like this, we want to process the device interrupt (tcakp interrupt
in this case) from thread context, so that the method to read/write registers
can itself use interrupts. For this we want to do something like:

tcakp_intr_thread()
{
	while (true) {
		mutex_enter(&sc->intr_lock);
		while (sc->sc_intr_pending == 0) {
			cv_wait(&sc->sc_intr_cv, &sc->sc_intr_lock);
		}
		mutex_exit(&sc->intr_lock);
		iic_acquire_bus();
		read/write registers via iic, posssibly using interrupts
		  this will ack the intrerrupt
		iic_release_bus();
		mutex_enter(&sc->intr_lock);
		sc->sc_intr_pending = 0;
		intr_unmask(sc->sc_intrh);
		mutex_exit(&sc->intr_lock);
	}
}

tcakp_intr()
{
	mutex_enter(&sc->intr_lock);
	sc->sc_intr_pending = 1;
	intr_mask(sc->sc_intrh);
	cv_broadcast(&sc->sc_intr_cv);
	mutex_exit(&sc->intr_lock);
}

We need to mask the interrupt at the pic level until the thread can process
and ack the interrupt at the device level. Otherwise, in case of
level-triggered interrupts, tcakp_intr() will be called again as soon
as it returns, and the thread won't have a chance to run.

The same problem exists for HID over I2C devices, e.g. ims(4). For now
ims() uses polling i2c transfers for this exact reason, but a general solution
for defereing interrupt processing to threads is really needed.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index