[{"id":39601,"web_url":"https://patchwork.libcamera.org/comment/39601/","msgid":"<178336196012.3416576.12099358361058245381@ping.linuxembedded.co.uk>","date":"2026-07-06T18:19:20","subject":"Re: [RFC PATCH] ipa: rkisp1: lsc: Workaround ISP stalls when\n\ttoggling LSC","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2026-07-02 16:24:27)\n> ISP stalls were observed by repeatedly toggling the LSC enable bit. The\n> probability of a lockup is quite high and easily reproducible by\n> manually toggling the LensShadingCorrectionEnable control in camshark.\n> \n> As no fix proper kernel side fix could be found, workaround the issue by\n> keeping LSC enabled and writing 1.0 to the gain table.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n> Hi all,\n> \n> The intention of this patch is merely to document the issue. A proper\n> fix on the kernel side would definitely be preferable. But although I\n> spent some time debugging the kernel interrupt handling I wasn't able to\n> come up with a fix.\n> \n> It looks like enabling the LSC module is somehow racy.\n> \n> One thing I was wondering but didn't spent the time to test: In the\n> driver the order of events is: RKISP1_CIF_ISP_FRAME ->\n> rkisp1_params_isr() -> ...  -> rkisp1_ext_params_lsc() -> \"write lsc\n> tables\" and then shortly after, the next frame starts with\n> RKISP1_CIF_ISP_V_START. I didn't test if writing the lsc tables actually\n> overlapped with the V_START signal. Should we possibly write the LSC\n> tables after the V_START interrupt, as these are ping pong maps anyways?\n\nRegardless of potential kernel fixes/improvements here - I think this\nsolves the current released kernels and so is worthy of being integrated\nalready.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Best regards,\n> Stefan\n> \n> ---\n> \n>  src/ipa/rkisp1/algorithms/lsc.cpp | 23 +++++++++++++++++++----\n>  1 file changed, 19 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> index faf88effde01..251a2714b617 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> @@ -532,13 +532,28 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n>         }\n>  \n>         auto config = params->block<BlockType::Lsc>();\n> -       config.setEnabled(frameContext.lsc.enabled);\n> -\n> -       if (!frameContext.lsc.enabled)\n> -               return;\n> +       /*\n> +        * ISP lockups were observed when toggling the LSC enable bit\n> +        * repeatedly. There is no known kernel side fix. Workaround the issue\n> +        * by leaving lsc enabled all the time and setting the gain values to\n> +        * 1.0 in case lsc should be disabled.\n> +        */\n> +       config.setEnabled(true);\n>  \n>         setParameters(*config);\n>  \n> +       if (!frameContext.lsc.enabled) {\n> +               for (int i = 0; i < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; i++) {\n> +                       for (int j = 0; j < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; j++) {\n> +                               config->r_data_tbl[i][j] = 1024;\n> +                               config->gr_data_tbl[i][j] = 1024;\n> +                               config->gb_data_tbl[i][j] = 1024;\n> +                               config->b_data_tbl[i][j] = 1024;\n> +                       }\n> +               }\n> +               return;\n> +       }\n> +\n>         const Components &set = sets_.getInterpolated(quantizedCt);\n>         copyTable(*config, set);\n>  \n> -- \n> 2.53.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7839BC330F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jul 2026 18:19:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8026066039;\n\tMon,  6 Jul 2026 20:19:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C846601C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jul 2026 20:19:23 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 81135838;\n\tMon,  6 Jul 2026 20:18:34 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"o5V1vYp9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783361914;\n\tbh=gIedYPynXcyumXonf5u3PtiK6bhTYXyMDdntaJqeYv8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=o5V1vYp9qa2WGPsQOxdYZiAEvyrjRTGo/AdsEROuGFwE/tXmq0y+Z054GEVTtFcu0\n\tRfhAPdLlxqiQdyMuT9uJnMFYAJot4FTV5LCB3XRrrGjBlPLeqX+Xr10YXK9pkMdydH\n\thIoNfw4YERxmfkI+2AXRxxGZuIQjlkbjbY/k1sZU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260702152434.1123571-1-stefan.klug@ideasonboard.com>","References":"<20260702152434.1123571-1-stefan.klug@ideasonboard.com>","Subject":"Re: [RFC PATCH] ipa: rkisp1: lsc: Workaround ISP stalls when\n\ttoggling LSC","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 06 Jul 2026 19:19:20 +0100","Message-ID":"<178336196012.3416576.12099358361058245381@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]