Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3087421rwb; Mon, 15 Aug 2022 17:49:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5pKiu1XKtvlKrkYrgejLk+604/ZyD1duU36piG8K8Jm6saX8I+eJ68ybEdAJ2KhCh9AX/j X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr11521957ejc.539.1660610962148; Mon, 15 Aug 2022 17:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610962; cv=none; d=google.com; s=arc-20160816; b=ahbW0iQgz+E73BaFNUN8J9L/q7l9fazwVVJXD+WObWNJ7UYQmWVeFRZ6HidBN1R/aD yUAifs3DRb/9WdU10tt3PMb3VHnyjLpMWsYAvgijVSNbqi3UT5YTyjzyvpOLW25TR4Yv 8Yk7ofwi2PyEazo/R5MDjZGlI7lLI6VTCKM74rKR622ygk8DrSOFQyg1oUzJj7LwbNar zLqiyE5EOMd/0b8o6GpR3IkqzliwoNIUDJEnkExYP78Mg8Gc5Xv/LyJKs2jymZfvLcOS cHuVqqme5a+kGIYKs9olatvZgx2ESxvvR1juu0PwcoGipPzQdc6trNnIvLoSH98EEc0F maRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6vfUbzmVGPAbZRUfyYWWiUMFce2WErIHn9duQ6YFv8g=; b=V9xnZSdbxdQ3P+4lTpW7mpJFhyaOMOD12/1KWP09jK72/Pj4+UluwW/HHL5WwONqHT 0XUkbnmXMRL4OcFANFG2wp2gzMu3F2qRP9IUIXXCc/EbrdFDJcuMXIOG8e6loDV7kxrv JhwpagV0IOcOq335nUfVPkojkv+ND9IlXq6JDGJICyoy9UizdeoD8KvtQV8w4N3DIHan pRme8b39oqN0hH1AGYVSZjwtAcCgsyH3qIgusSXyPIcgIqLXtaIFSptIwB+kkTA85Ken x4PBOJFDzr8u5Mra3i5ZikQMkszP5AXgyuLrHls8F2Dix4MZCy5Wqzg6LhSsKF5qvG3a wyTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gdJPcvda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc8-20020a170907168800b007331efb8a1asi9767641ejc.44.2022.08.15.17.48.56; Mon, 15 Aug 2022 17:49:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gdJPcvda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355007AbiHOXvP (ORCPT + 99 others); Mon, 15 Aug 2022 19:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354904AbiHOXqr (ORCPT ); Mon, 15 Aug 2022 19:46:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21963C2769; Mon, 15 Aug 2022 13:15:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 41A3DB80EA9; Mon, 15 Aug 2022 20:14:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71EA5C433D6; Mon, 15 Aug 2022 20:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594497; bh=8Hk5y3THfewdtbF9VTpJrfqNWBag9S8m1fnT5yd1cBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdJPcvda/DDAK13vq4I2T+0w4Qwy439Ia14AqfWR7cHaO97EIFQsCeux2mkaz54GI hka7GDl+vj9fKjDlqlW4Yl+6tTn17c7YaCyN4lK8pVu/SxVwsYfNOYbQS79WcHxkb5 UhlSZjSu7euPFzsEXCCN1BnsABA3vE6Ws1erbelM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Qian , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.19 0466/1157] media: amphion: sync buffer status with firmware during abort Date: Mon, 15 Aug 2022 19:57:02 +0200 Message-Id: <20220815180458.241114228@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Qian [ Upstream commit d8f1eb105eab7aab36323c6b488dda479d5bd2da ] 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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 a5bb997b000b..5e3b08d07abd 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) -- 2.35.1