From d467fd9ece01b44cbb03027b3530da87ab255861 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 4 Jul 2023 14:32:21 +0000 Subject: [PATCH] Instead of waiting for the inbound item to show up in the interrupt handler, allocate it ourselves. The firmware doesn't seem to mind that it's us doing the allocation. This fixes a splassert, because the code that retrieves the item reaches through the shared memory driver, which acquires the hardware mutex, which in turn mallocs. ok kettenis@ --- sys/dev/fdt/qcsmptp.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/dev/fdt/qcsmptp.c b/sys/dev/fdt/qcsmptp.c index 50fe85786ac..40f68c97490 100644 --- a/sys/dev/fdt/qcsmptp.c +++ b/sys/dev/fdt/qcsmptp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcsmptp.c,v 1.1 2023/05/19 21:26:10 patrick Exp $ */ +/* $OpenBSD: qcsmptp.c,v 1.2 2023/07/04 14:32:21 patrick Exp $ */ /* * Copyright (c) 2023 Patrick Wildt * @@ -182,6 +182,18 @@ qcsmptp_deferred(struct device *self) return; } + if (qcsmem_alloc(sc->sc_remote_pid, sc->sc_smem_id[0], + sizeof(*sc->sc_in)) != 0) { + printf(": can't alloc smp2p item\n"); + return; + } + + sc->sc_in = qcsmem_get(sc->sc_remote_pid, sc->sc_smem_id[0], NULL); + if (sc->sc_in == NULL) { + printf(": can't get smp2p item\n"); + return; + } + if (qcsmem_alloc(sc->sc_remote_pid, sc->sc_smem_id[1], sizeof(*sc->sc_out)) != 0) { printf(": can't alloc smp2p item\n"); @@ -254,15 +266,6 @@ qcsmptp_intr(void *arg) uint32_t changed, val; int do_ack = 0, i; - /* Inbound item exists as soon as remoteproc is up. */ - if (sc->sc_in == NULL) - sc->sc_in = qcsmem_get(sc->sc_remote_pid, - sc->sc_smem_id[0], NULL); - if (sc->sc_in == NULL) { - printf("%s: can't get smp2p item\n", sc->sc_dev.dv_xname); - return 1; - } - /* Do initial feature negotiation if inbound is new. */ if (!sc->sc_negotiated) { if (sc->sc_in->version != sc->sc_out->version) -- 2.20.1