From patchwork Fri Jul 1 05:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12902732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD79FC43334 for ; Fri, 1 Jul 2022 05:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aL0ElBbocJH274uxAVhgmIPjL6zAq6IkB/1RPXr6Q9o=; b=kAtSSr0+/g5jCw tEEGPLuJxRZeYeBWw995q9nAMRg3Cf2Da3zT3DnSYkdJPc2y1NT9OcmcOGmP47ZaT95jIwr1MuULc vLH8qFR7UEM5P/QfbwGX+QUf1Ft4L8ovvHJkayRw9WzuHdCFrmqIiRdkYlwph9cu66AQY/+uwFh1b 3hCwtmVc7U8cgowcjiTYgh5kHn60tKbLU7XaK6MNRn65itXKzQtvDTlk5xuwTk1W1bE6MjwSInSHZ ZQyDVGM3VbEbxCJKJBKyRC1sILP1XBDaagSChLB60IrwynbEXLkWBo3ks1K+ZTnDWvqCLv1gVvDsC oVyJysraZ7gpo53Lo0pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o79Xy-0032Yl-Fg; Fri, 01 Jul 2022 05:50:30 +0000 Received: from mail-dbaeur03on2045.outbound.protection.outlook.com ([40.107.104.45] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o79Xv-0032Wy-5z for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 05:50:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cRqQhYd9bOMdgDwUfgW5DsCOY5xpuoxu7NhjwIX3vZ8SqfqLvny61nZeZ3CBArRJwGauFI7/Ln04KfJLrHcmK3Te429yXGh6iMnz1L87Jr7jPko/UgjyUDf+S7r9yKqdEpy/D1gzY+PT7xVlwu+etYDcEp1f0oc2LC2sdgJ82p0RL2JBw1OYdHIrIuwV3iOE8pdhnAHnCdQeVbsGTmLUta5CIDRt37iju/6U0VX54oE4gXskQyCjrAxY97ifO2QIiMuCkjLNBZPhi+fuHEATuLpvNR9M2pahrtWNrwoTwRyYa1ZBEV8Kb39wmFYyMrw1OvQeFfFEEiiVYWq4oFJzJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jA+HADzhEF6Fn8ezA15bycJ1Aza1BkJccOuGlbMkEaY=; b=kjtNI8cugAJZU2BOvnzXW+0Ecv6qjLujFJmxMLhC+siuoNm4SUTB0KHHpr2CQGlDtbw4durgNPC1mFTLAorWnTIWdlmc7rd+EKqlVmbHTeV/XdO9Kc6oGEJBrMcgNtMT+WuyTYQBxyC4Dcd1NZAajUd3toK7oxM6fdgaGv40Go5P0sorIqsMFUvvGzEJLF/5/BQtJ6sbDEwyTx9vXbm24L6USyByeP9RXiNHAj83H67tbaCAQs0LKYL6jGS3QYCp9eGWblqkfle6q8ECV8Fk7dPx9AKieSlCnPvruGv0/tCMAM551RRtdhbeO2iunIygKdBj2faBKGWZRewwCRA+lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jA+HADzhEF6Fn8ezA15bycJ1Aza1BkJccOuGlbMkEaY=; b=o9M0UaxyDMaDOk8PPeXsSNMKGZRWKyg1ZTXKW1RvzZLwzUZfouDAviFGJpeid6AtccILO9wuYV5Wf3DsACxl667+Z8aFjUoWVM1Wt0l4kGUko+7PmeYh30WkBoWDoL669Ju7pPc0SkOBUGis2sC3PwQ5uRJKBhd0gr71uFmAOuU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM0PR04MB5521.eurprd04.prod.outlook.com (2603:10a6:208:111::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Fri, 1 Jul 2022 05:50:20 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::3582:eb2f:9652:d98b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::3582:eb2f:9652:d98b%5]) with mapi id 15.20.5395.016; Fri, 1 Jul 2022 05:50:20 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: amphion: sync buffer status with firmware during abort Date: Fri, 1 Jul 2022 13:50:04 +0800 Message-Id: <20220701055004.20821-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.36.1 X-ClientProxiedBy: SG2PR06CA0224.apcprd06.prod.outlook.com (2603:1096:4:68::32) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 810cb3f6-11db-4ae2-6b11-08da5b259574 X-MS-TrafficTypeDiagnostic: AM0PR04MB5521:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c4OgPrdNUPyNMXMMDFYsc5D3PECH5v+3yuQkJIFpy0BAZnd1f8U2qThbfohUnCkGqqGmFamWva2b8lGD132G9NQfUMAW9q6SHofUgaDtOfLX8ADaNp4444kyw5Rptvtq34cB4Yi3sS2q/uQIk4v3XX2LzKUmI1nvsRe+85cnKSWzWWtCkTjW0VmnXUewbPrvUPucbx1YZaamvPGeC+x2A44rKWfQu9qJTE1/1AJxCx9Pcj35kYnt0TCPXzBH0LyXzcspf3wlQcymGzCg5/yGXQpRXxaeiutdGH9/37Z7WTBSBYFP3zm6F91CXZZyhLhWJO63rdVNh/ncHblRbUf94UYWXmb+OnJM6M8Q3dm9CYUsBfsm/75ThMB/pR/0OJj7DCBR5JiwHB7u9Pr33KnlCnYd+CdEMFXka3S/a3FpcPhqSYPkXKvjytJyzyXnyr2g7sWdmqlHHu+pGx/+ASRrlpilagXe8ndGLkwrGU6gb7sxbtFtWptekVaXPI1ibGGNnv3Y6y+1HbdjCQRLBH/JNUpni8yEt0tAEZ9Uz5sX1b802YNuUCR79ZOXNDyq4x/6PWgbwVgQfmTEQ126NiIAQVnu8KwwlQvIVvVUfvqZXbQCex8nbamKZwRTAjsdzAV8ch3ecdBRMERmDKw7St41RVt1VQ0iscUDVP8dwSlHKiu9ojkNx5bTfHXsFjMA85G/tisZP+oGcKCo+GztEReeJy5OJLkrnSlFCSIP7b6pbO/39xb7uDb9DKEv8pUNGAyRRAZLmnfxrwfk4wDir8KHw34qh975xNRyehMKpC4NreNNgweWa7jN0z+elkDzy2UZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB6341.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(39860400002)(366004)(346002)(376002)(36756003)(66556008)(5660300002)(44832011)(8676002)(66946007)(316002)(4326008)(6486002)(8936002)(2906002)(7416002)(66476007)(478600001)(2616005)(186003)(1076003)(41300700001)(52116002)(38350700002)(38100700002)(6506007)(6512007)(26005)(86362001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mD0Up64EL3Y/c69U61sJhLwFZVuRMClKuJM+MLyoGMs7yJonXKatDbzV56HBYYhQAoXglw2Gc+NyKztFiTnAjPP48WD3KBfOoqaGtoG+iTtDwYPQBf/9R2RrEpkTFjYeooMtySvTxf/MdL3vXu9/r7yRqCFa5bOdF8xYryQ0U3+tPcG5nwBhR51aEIot+H2RAbzN3K2LxOfAAwp9CFKMI9YFSc+kBYZ3UyKCYoz5f03bUGIfxps+I0LvvU6sBeS3jr5LM/Xu2X4Ow67JcHn9Viy9+tnfJk0poC8jeirPn+ZQ0m4ScKYL20D1SiWMEsrgZGOpUTU9KhCrU4GSb93ISRo7CyALh0vWzgzfn/tw95kQIKahQujPfHot5xO3L9vahYeK/PfYeSFRJ9aUwPhuXylXrJoRzMKO7kX+luYIbEElIHJ7geOqcaWb8eQKEBYpKh2nOMg7RTDnXu3ix+vjp/muqBFCJiSYsqbibyhZwMvTIgf6x5J1n7OOqBAMVLgMlZkKudboijubukZ6i23z/A2L3UTFPsyMbEBMY72XYDX0dUvEHCP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-4ae2-6b11-08da5b259574 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2022 05:50:20.7573 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MJDluRbkYHzX2bageSp5G5Cg3U23PK19dUW3gkWucp+hikcf/NNmDseSY7MHIlcVEVRSxvf+QUT0xAoeKoD+0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5521 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_225027_469243_4954F7B5 X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 1. prevent to allocate buffer to firmware during abort 2. release buffer when clear the slots Fixes: 6de8d628df6ef ("media: amphion: add v4l2 m2m vpu decoder stateful driver") Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vdec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c index 77a3a5c823f9..9e64041cc1c1 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -63,6 +63,7 @@ struct vdec_t { bool is_source_changed; u32 source_change; u32 drain; + bool aborting; }; static const struct vpu_format vdec_formats[] = { @@ -948,6 +949,9 @@ static int vdec_response_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vb if (inst->state != VPU_CODEC_STATE_ACTIVE) return -EINVAL; + if (vdec->aborting) + return -EINVAL; + if (!vdec->req_frame_count) return -EINVAL; @@ -1057,6 +1061,8 @@ static void vdec_clear_slots(struct vpu_inst *inst) vpu_buf = vdec->slots[i]; vbuf = &vpu_buf->m2m_buf.vb; + vpu_trace(inst->dev, "clear slot %d\n", i); + vdec_response_fs_release(inst, i, vpu_buf->tag); vdec_recycle_buffer(inst, vbuf); vdec->slots[i]->state = VPU_BUF_STATE_IDLE; vdec->slots[i] = NULL; @@ -1318,6 +1324,8 @@ static void vdec_abort(struct vpu_inst *inst) int ret; vpu_trace(inst->dev, "[%d] state = %d\n", inst->id, inst->state); + + vdec->aborting = true; vpu_iface_add_scode(inst, SCODE_PADDING_ABORT); vdec->params.end_flag = 1; vpu_iface_set_decode_params(inst, &vdec->params, 1); @@ -1341,6 +1349,7 @@ static void vdec_abort(struct vpu_inst *inst) vdec->decoded_frame_count = 0; vdec->display_frame_count = 0; vdec->sequence = 0; + vdec->aborting = false; } static void vdec_stop(struct vpu_inst *inst, bool free)