Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5932712pxb; Thu, 27 Jan 2022 02:47:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGbwE3xY1U1lyo2tlXmiIUJ4lWk8fyPp/w0Zh7pwrq1XRZECT9Kh8PJqf/UD/TnRAGmSqU X-Received: by 2002:a17:90b:1d84:: with SMTP id pf4mr13498516pjb.106.1643280456688; Thu, 27 Jan 2022 02:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643280456; cv=none; d=google.com; s=arc-20160816; b=jXMn+qf+/9X27WsLR4NcEdnm/2UA6S4wpECJd+cHskLnjI82eW0HHKdvvIVg3XqGdp zAV/GZFj6MLw5OQsYzfu9BMJc9YpNSN9qbrQxzGoIK4z0TnAXvUHqTbq/hKm6Hx+iRRV 6SlwrqSa+eSwcsklZJ6jgRyPBcaD2GzSTo5OL76+uDdLtXsRfnYOsp+/W0bQvWPTeCN+ cfupa+a7kd/6RmKA/lBfHSEIgxiUWGl9aW2VU6nN+pyzZSm6YQ5BdPq0/DDmBJOsQxX+ dVLlmZwNbG9HTQpCyPKot4e2i8+dxZQJNGvzB3rJG4bBilDBzA9A+eZi5cF/qzZUSOW9 SRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ShRaO5IB0xEWZcUJQsiyw3XpADi1hmcoem0Sf7RqbNE=; b=dvKUPSFp/czT9s9eZxAVGPEUq/LPxahRLJ87OkB7zlETEtxK9vuu7mlIRqgO7TBtUR u+kCPTutuVYXjtKPIzyBDpcO/ukdQUd8q3Ox/LGZXBv/j1UJCa4kIUVbiosgFMIGjB2C geL7o2ZT2K/W+4McEGwsJz0JU9GRfmDc9wUIKGgZ/bmGBu71G4m+2IVL1697qtTXt0SV toG7Ijnb4eAAl+EfyQs8o5r5lrGDNYoYUEz3GCVCED/0qPxQ2ls8KrjY2/Fo9Lq5k8Om wx5wLgX2dEP4OSuWdR9jS/ifGYvpPWNQs4bg/Ndt67aQjpbjXzmy5sppZ8ztTNzGr9QR s2tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si1836192pgi.290.2022.01.27.02.47.24; Thu, 27 Jan 2022 02:47:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235568AbiA0C4O (ORCPT + 99 others); Wed, 26 Jan 2022 21:56:14 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:53602 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235523AbiA0C4D (ORCPT ); Wed, 26 Jan 2022 21:56:03 -0500 X-UUID: fe9b2be4975341bbbd40f9d71f2647b7-20220127 X-UUID: fe9b2be4975341bbbd40f9d71f2647b7-20220127 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 208223140; Thu, 27 Jan 2022 10:56:00 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Thu, 27 Jan 2022 10:55:58 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 27 Jan 2022 10:55:57 +0800 From: Yunfei Dong To: Yunfei Dong , Alexandre Courbot , Hans Verkuil , "Tzung-Bi Shih" , AngeloGioacchino Del Regno , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa CC: George Sun , Xiaoyong Lu , Hsin-Yi Wang , Fritz Koenig , Dafna Hirschfeld , Benjamin Gaignard , Daniel Vetter , dri-devel , Irui Wang , Steve Cho , , , , , , , Subject: [PATCH v1, 6/8] media: mtk-vcodec: prevent kernel crash when scp ipi timeout Date: Thu, 27 Jan 2022 10:55:42 +0800 Message-ID: <20220127025544.10854-7-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127025544.10854-1-yunfei.dong@mediatek.com> References: <20220127025544.10854-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tinghan Shen When SCP timeout during playing video, kernel crashes with following message. It's caused by accessing NULL pointer in vpu_dec_ipi_handler. This patch doesn't solve the root cause of NULL pointer, but merely prevent kernel crashed when encounter the NULL pointer. After applied this patch, kernel keeps alive, only the video player turns to green screen. [67242.065474] pc : vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec] [67242.065485] [MTK_V4L2] level=0 fops_vcodec_open(),334: 18000000.vcodec_dec decoder [135] [67242.065523] lr : scp_ipi_handler+0x11c/0x244 [mtk_scp] [67242.065540] sp : ffffffbb4207fb10 [67242.065557] x29: ffffffbb4207fb30 x28: ffffffd00a1d5000 [67242.065592] x27: 1ffffffa0143aa24 x26: 0000000000000000 [67242.065625] x25: dfffffd000000000 x24: ffffffd0168bfdb0 [67242.065659] x23: 1ffffff76840ff74 x22: ffffffbb41fa8a88 [67242.065692] x21: ffffffbb4207fb9c x20: ffffffbb4207fba0 [67242.065725] x19: ffffffbb4207fb98 x18: 0000000000000000 [67242.065758] x17: 0000000000000000 x16: ffffffd042022094 [67242.065791] x15: 1ffffff77ed4b71a x14: 1ffffff77ed4b719 [67242.065824] x13: 0000000000000000 x12: 0000000000000000 [67242.065857] x11: 0000000000000000 x10: dfffffd000000001 [67242.065890] x9 : 0000000000000000 x8 : 0000000000000002 [67242.065923] x7 : 0000000000000000 x6 : 000000000000003f [67242.065956] x5 : 0000000000000040 x4 : ffffffffffffffe0 [67242.065989] x3 : ffffffd043b841b8 x2 : 0000000000000000 [67242.066021] x1 : 0000000000000010 x0 : 0000000000000010 [67242.066055] Call trace: [67242.066092] vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec 12220d230d83a7426fc38c56b3e7bc6066955bae] [67242.066119] scp_ipi_handler+0x11c/0x244 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066145] mt8192_scp_irq_handler+0x70/0x128 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066172] scp_irq_handler+0xa0/0x114 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066200] irq_thread_fn+0x84/0xf8 [67242.066220] irq_thread+0x170/0x1ec [67242.066242] kthread+0x2f8/0x3b8 [67242.066264] ret_from_fork+0x10/0x30 [67242.066292] Code: 38f96908 35003628 91004340 d343fc08 (38f96908) Signed-off-by: Tinghan Shen Signed-off-by: Yunfei Dong --- drivers/media/platform/mtk-vcodec/vdec_vpu_if.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c index 35f4d5583084..1041dd663e76 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c @@ -91,6 +91,11 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv) struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) (unsigned long)msg->ap_inst_addr; + if (!vpu) { + mtk_v4l2_err("ap_inst_addr is NULL"); + return; + } + mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id); vpu->failure = msg->status; -- 2.25.1