Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10614922ybi; Thu, 25 Jul 2019 02:27:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO9/qcqYOb1WX4rlA2HXF+Td3AVfAbxwDVO8MAsv9GUgr/kOJwX78cyTYe78tLPK1+zUjF X-Received: by 2002:a63:4041:: with SMTP id n62mr14375152pga.312.1564046851050; Thu, 25 Jul 2019 02:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564046851; cv=none; d=google.com; s=arc-20160816; b=TxHhgH7OOJTbY/C/xvRLZaXtGiQiab5pjr9Tp6sERczMgSe6lnn5ppVVm3caTsmAex wfb0UQAF3wbxk3h0fLWXxJ7fANfkDNpaoXrm+X4efoPa4kggy7PD3nYBbCva/3amLVKh t82S5Af/dRKOmYAwHubBJY9GVE64ASbISLbAkBBjk4imzDz6HFIKYKaRip8dM5NIQw0Q mPDQRXG65EwKcmqv/2vqJu3pW5rTe1TtnXHPk9qzaJzBkNpDD1++2Ck05mphRgUyHMnJ Rok9NjgANN2BscADvbTeYcAR0hjb+9K0khG0TYJ7qKF3kQxKdwfOtYcxQjbWN7YQTXbG QJsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bgGQY3qTmwhd0VZTTXRmLWKxdPWrE5zU2GEYGC4lYOA=; b=S/gzO3T8+hlGOwYoVJXCoHjr9kRfNG3arQPWJa+ObLl5x3w3eOWGPAjxZcUcYs29y+ QyLDU9TA/XQTPUHVoeQa6O50c8W8HbbT6O5/P/QA1grwZWAg8NXWeMQN8hIEpVx90FAV o6cSi0yGeAtg8u+fDfBsOWGwq3UaTpmg4I+UP+I7E7WfZKL3A3VBCVU1h8CnBjJamtqk TiiFJP57wvQNwaknOxuLZ2PDUPbIWysw8MEgkEuWNPj9BIoERCklK9z0rMSKbHl1yROn r4vl69oCYeZ8IadeoTUu0lxBcwMGpcf+q21krL5M3ESpitiwI/dNXQ3kkousP1ZhKcCG Onkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ku7TSkg1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si16007148pgh.219.2019.07.25.02.27.12; Thu, 25 Jul 2019 02:27:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ku7TSkg1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388687AbfGXUeV (ORCPT + 99 others); Wed, 24 Jul 2019 16:34:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727422AbfGXT1H (ORCPT ); Wed, 24 Jul 2019 15:27:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE583218F0; Wed, 24 Jul 2019 19:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996426; bh=TcI0KtqJ6S5x+qOrxbfvT28giSgQcp0x9Mb7ZFhOaC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ku7TSkg1YcA2oKsOKHnZKobPxzumWoe/SaDYtwAwJD+aUdRBgWeL8bn8g252yoQ3a P4yrheImJLncmZ925VxBJhCy8qQAoOUDYvltIUOerEolC0+AwvbMEi4EfRt0WPQZ3L yhu3SitKX8BU2hSTGqQ0id54Cu9/TlUgouBDpPIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.2 093/413] media: s5p-mfc: fix reading min scratch buffer size on MFC v6/v7 Date: Wed, 24 Jul 2019 21:16:24 +0200 Message-Id: <20190724191741.672459619@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit be22203aec440c1761ce8542c2636ac6c8951e3a ] MFC v6 and v7 has no register to read min scratch buffer size, so it has to be read conditionally only if hardware supports it. This fixes following NULL pointer exception on SoCs with MFC v6/v7: 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = f25837f9 [00000000] *pgd=bd93d835 Internal error: Oops: 17 [#1] PREEMPT SMP ARM Modules linked in: btmrvl_sdio btmrvl bluetooth mwifiex_sdio mwifiex ecdh_generic ecc Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) PC is at s5p_mfc_get_min_scratch_buf_size+0x30/0x3c LR is at s5p_mfc_get_min_scratch_buf_size+0x28/0x3c ... [] (s5p_mfc_get_min_scratch_buf_size) from [] (s5p_mfc_irq+0x814/0xa5c) [] (s5p_mfc_irq) from [] (__handle_irq_event_percpu+0x64/0x3f8) [] (__handle_irq_event_percpu) from [] (handle_irq_event_percpu+0x2c/0x7c) [] (handle_irq_event_percpu) from [] (handle_irq_event+0x38/0x5c) [] (handle_irq_event) from [] (handle_fasteoi_irq+0xc4/0x180) [] (handle_fasteoi_irq) from [] (generic_handle_irq+0x24/0x34) [] (generic_handle_irq) from [] (__handle_domain_irq+0x7c/0xec) [] (__handle_domain_irq) from [] (gic_handle_irq+0x58/0x9c) [] (gic_handle_irq) from [] (__irq_svc+0x70/0xb0) Exception stack(0xe73ddc60 to 0xe73ddca8) ... [] (__irq_svc) from [] (console_unlock+0x5a8/0x6a8) [] (console_unlock) from [] (vprintk_emit+0x118/0x2d8) [] (vprintk_emit) from [] (vprintk_default+0x20/0x28) [] (vprintk_default) from [] (printk+0x30/0x54) [] (printk) from [] (s5p_mfc_init_decode_v6+0x1d4/0x284) [] (s5p_mfc_init_decode_v6) from [] (vb2_start_streaming+0x24/0x150) [] (vb2_start_streaming) from [] (vb2_core_streamon+0x11c/0x15c) [] (vb2_core_streamon) from [] (vidioc_streamon+0x64/0xa0) [] (vidioc_streamon) from [] (__video_do_ioctl+0x28c/0x45c) [] (__video_do_ioctl) from [] (video_usercopy+0x260/0x8a4) [] (video_usercopy) from [] (do_vfs_ioctl+0xb0/0x9fc) [] (do_vfs_ioctl) from [] (ksys_ioctl+0x34/0x58) [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28) Exception stack(0xe73ddfa8 to 0xe73ddff0) ... ---[ end trace 376cf5ba6e0bee93 ]--- Signed-off-by: Marek Szyprowski Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 4e936b95018a..481088a83212 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -523,7 +523,8 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx, dev); ctx->mv_count = s5p_mfc_hw_call(dev->mfc_ops, get_mv_count, dev); - ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops, + if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) + ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops, get_min_scratch_buf_size, dev); if (ctx->img_width == 0 || ctx->img_height == 0) ctx->state = MFCINST_ERROR; -- 2.20.1