Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2160883iof; Tue, 7 Jun 2022 21:47:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc8MV7S6N0kzwXlY6Mviplz8hUu0EWaFJC38tCAl3/yC1RPHaPEaXAJIJs0YY9m5MsZmF8 X-Received: by 2002:a17:903:234a:b0:167:997f:bc4c with SMTP id c10-20020a170903234a00b00167997fbc4cmr5131223plh.120.1654663626046; Tue, 07 Jun 2022 21:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663626; cv=none; d=google.com; s=arc-20160816; b=Bn2+/8F6Wu/Nx3tjZ6jFvw/E3n1dQjVTd1by+tdtOyLG4Ml5NmSBUuEZoAOmSl7V5c Fpqrvjs8hYUMKVXLO36fXdFOP2qYPNz8KrO1im7erdIgAfWCKDWvUbBfwoUwRDu1kJwk zCHKYS5lbWx7EtqAwDN3kYXpmhO8WSX6z99EdYHcuguwBrU83ESNL2A4hTuXHq8uhryO n5ATQ3vh4bQGuvnEEaSzOPMIoBo13nuEVuKkOvxnbnD2hBmJZc0gj2SUtbZxz8mQdvOI gMIEKZNiub0U99QpXw0a2GPYx3aH0LfpYomnkZ77QIQgcjPa1raw1VuH/se0ZHf01JdX n3Eg== 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=mR4T1NopolnLLmEUtuotWrnhv8MuvkWwYq6V4n2/Qs7/La5YDemxcsn+EBkoyQR3d7 Zyyc5bHG/yBNZJKfqbdedcW8T9jx5awTVowkWBXpYe38ps2YlErdQD2hWSjm1xLiVnov YfoY7VN0TYfvbo/j2or/0HjzQk06r+rO38zMJQD+47OmQ2CCbaSgfSYpZDXWjQ4aQ/SM k1SUOiF+j5UaxsW6JZNO/Td8AQVAEocadx0bzJST2ib9M8qwpZBeDBlKtfVpjcT7VNQ3 J/kSlqyR82Wshtt3gh9qqfsBf/yF8h0HFmG5gQEvpYUrHjo7XcYB71vDXZ53NpB8xIwT lPyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wyg3jEV5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id pi13-20020a17090b1e4d00b001e67c8309a5si13703252pjb.9.2022.06.07.21.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:47:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wyg3jEV5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 7EBAC2DC212; Tue, 7 Jun 2022 21:17:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383848AbiFGWGk (ORCPT + 99 others); Tue, 7 Jun 2022 18:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379842AbiFGVGa (ORCPT ); Tue, 7 Jun 2022 17:06:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AE3211AB2; Tue, 7 Jun 2022 11:50:27 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8A6F16176D; Tue, 7 Jun 2022 18:50:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9135AC385A2; Tue, 7 Jun 2022 18:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627819; bh=MoPv6OhQx7EiRN060osT8VM3jcVMoppKxNbkWMOY8cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wyg3jEV5kVEdbhqLgwaquNYfchqfXC7a8uKuqtTlB0V8uGO6f6GP/RQlYi6868iL8 h0KGmTWQzOuNTR4nwSfzHMI1Gk4k4umnXNoVfb2ZzjevAOm4c7Ij3CEuHjQHx38QF3 XZV5p0i2T5YnKNIQ7RsNt0G0ZVKwRPpOxtdfxPYI= 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.18 103/879] media: venus: do not queue internal buffers from previous sequence Date: Tue, 7 Jun 2022 18:53:41 +0200 Message-Id: <20220607165005.685049958@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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