Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2142005iof; Tue, 7 Jun 2022 21:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOYqQggfBygkxwBsTDqD032xHyK7urccw28xqMg6KRKOrfSlCqliTTVw9NyR59fsFqJIfr X-Received: by 2002:a63:6b08:0:b0:3fd:1b8e:3932 with SMTP id g8-20020a636b08000000b003fd1b8e3932mr22577428pgc.552.1654661351862; Tue, 07 Jun 2022 21:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661351; cv=none; d=google.com; s=arc-20160816; b=UOrQuRzCjcYAhJ3EmXmI8Q4Iye7F+/LwDENM0ZLx3YOHhr99hJ1LA56whlTMeWTYah +wZq53KjOENxtwK6qZHK8Z63qORF5PssLGK/nHPVekUwJRsctGYaVDZbIDkdcfvpSG2C cg7qdtvx7ABaGp70PB1W/FUoex68qpSovlCTvU4JA6Tc8bya9bz9gtEinATIv32Bxso8 4QmZQos6pqsmKDMeWu3mmIfMnZ/iP0aD116jRXGb692dDHusNMr/7TyXX6jtVMh9iutW IVo56XnYdphGXBwAd46Bgc0cQzgv1wqFoOmsobCYDNHLOHhm03E4bCpvtlevvBDUWSmW 3cBg== 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=IOMyK1dlzfVPMkQ2rLTKbn7vUJPzzB5HNptQA3S0Ono=; b=VrQCzAkh2udIlhdJ1vmMh8e87VPncbrfp2mkFHoj+Sak4K5B1Spc3eUjauNTX1hYFq qbqWV/Q3r5RPijI1f1+E1ybwC4mjY7ALLmoMQUPWiUEddYsLb/Gqel4IFaoOFccya4oU E1TWDakNOEuRlbbvXLrDJMOKCpVb6qu7jom3UiYOO5rZ0W/PVGI8r3HVTjDbY2AKPM/R n+Q4MA1kvm4pZqb1phdWvL15WQ5vwbiNTqlmGDjgGPB1BrBgE3IOV9ILctePKyZq3Lcw lFcaeDBQo59jva1Bb0XuQDELqt8Dlj7HmgpJdoUWSyZX4sFQlxMbBNWfixOhiI5PRnyt 5SyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bRe5hQMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u8-20020a634708000000b003f61070e884si26620283pga.628.2022.06.07.21.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:09:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bRe5hQMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A88223146B; Tue, 7 Jun 2022 20:40:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377129AbiFGU23 (ORCPT + 99 others); Tue, 7 Jun 2022 16:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356412AbiFGTiY (ORCPT ); Tue, 7 Jun 2022 15:38:24 -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 656AA52533; Tue, 7 Jun 2022 11:13:56 -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 4D3B9B8233E; Tue, 7 Jun 2022 18:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8FFFC36B0B; Tue, 7 Jun 2022 18:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625634; bh=MoPv6OhQx7EiRN060osT8VM3jcVMoppKxNbkWMOY8cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRe5hQMIIDh8QkBZhnGrcSWt0DLDxU7cvFWI0UD9+CAcl2D3j3mWalpsk0IuBjP5a e2VdVkr4VM+IEfKuUIV68EzHnUGj2zWXlEXbrmx+DqeYw7y9S8Ik0CZNynnCAtZhR5 6lGcGsr4r82R4XTUK+m4n01zll5vWq04e2H/A4+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vikash Garodia , Fritz Koenig , Stanimir Varbanov , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.17 089/772] media: venus: do not queue internal buffers from previous sequence Date: Tue, 7 Jun 2022 18:54:41 +0200 Message-Id: <20220607164951.668432150@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Vikash Garodia [ Upstream commit 73664f107c0fafb59cd91e576b81c986adb74610 ] During reconfig (DRC) event from firmware, it is not guaranteed that all the DPB(internal) buffers would be released by the firmware. Some buffers might be released gradually while processing frames from the new sequence. These buffers now stay idle in the dpblist. In subsequent call to queue the DPBs to firmware, these idle buffers should not be queued. The fix identifies those buffers and free them. Signed-off-by: Vikash Garodia Tested-by: Fritz Koenig Signed-off-by: Stanimir Varbanov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/qcom/venus/helpers.c | 34 +++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 0bca95d01650..fa01edd54c03 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -90,12 +90,28 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_check_codec); +static void free_dpb_buf(struct venus_inst *inst, struct intbuf *buf) +{ + ida_free(&inst->dpb_ids, buf->dpb_out_tag); + + list_del_init(&buf->list); + dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da, + buf->attrs); + kfree(buf); +} + int venus_helper_queue_dpb_bufs(struct venus_inst *inst) { - struct intbuf *buf; + struct intbuf *buf, *next; + unsigned int dpb_size = 0; int ret = 0; - list_for_each_entry(buf, &inst->dpbbufs, list) { + if (inst->dpb_buftype == HFI_BUFFER_OUTPUT) + dpb_size = inst->output_buf_size; + else if (inst->dpb_buftype == HFI_BUFFER_OUTPUT2) + dpb_size = inst->output2_buf_size; + + list_for_each_entry_safe(buf, next, &inst->dpbbufs, list) { struct hfi_frame_data fdata; memset(&fdata, 0, sizeof(fdata)); @@ -106,6 +122,12 @@ int venus_helper_queue_dpb_bufs(struct venus_inst *inst) if (buf->owned_by == FIRMWARE) continue; + /* free buffer from previous sequence which was released later */ + if (dpb_size > buf->size) { + free_dpb_buf(inst, buf); + continue; + } + fdata.clnt_data = buf->dpb_out_tag; ret = hfi_session_process_buf(inst, &fdata); @@ -127,13 +149,7 @@ int venus_helper_free_dpb_bufs(struct venus_inst *inst) list_for_each_entry_safe(buf, n, &inst->dpbbufs, list) { if (buf->owned_by == FIRMWARE) continue; - - ida_free(&inst->dpb_ids, buf->dpb_out_tag); - - list_del_init(&buf->list); - dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da, - buf->attrs); - kfree(buf); + free_dpb_buf(inst, buf); } if (list_empty(&inst->dpbbufs)) -- 2.35.1