Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp58366pxb; Tue, 12 Apr 2022 16:45:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZaEh2yFpJazmBnLlg4DS6QjHpuwShKN5wWumHhi8fzddmBwpQxli4seuMtaiFvbPbueky X-Received: by 2002:a17:902:bd05:b0:158:544d:6557 with SMTP id p5-20020a170902bd0500b00158544d6557mr14913182pls.70.1649807106206; Tue, 12 Apr 2022 16:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649807106; cv=none; d=google.com; s=arc-20160816; b=YjzVX8/R9YrACqihBfYg1ZlVSp8iVymNkSEYh/ZtDf4y+Wg6oSp9tAUbzmL3RFYmM4 Trju/prSMtuj+lBtl/20wXUGiWOAyQ0OGTfkTzvPAgWPAnW6Kms1tvpbe3pq8dYMHPVG fbWaNywdbrdDsdz9yUZBzB/dPBuWZ144obfvYzVJctIDCMAD6fHIsxko4QZDn9swWJgb F1aHYxDIcBRlUO6I3iL5Ar4nfRxFQ9f8BmANMQKLwIy1Rzst5eRvIptv1gjFbTCtzCb6 oayuYAhMb/xdDeURNirTAtMUbD5RHym+si/1GLhk5nyZS/oLBojOs78wv400w5s9/C99 vYYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=N4ulgrYlIfenBw7Hm6+VMNDmIviNdtjf6yJOdqnjax0=; b=dMwXFhu3iSqmu+X2GJ0q2PxdFMbTCATgZVVgaWbOV1oMmbovrG1akg62CoIiBNUB/R RgGR5ENs/8KsiSxR6pxyxh2qb90EYpuD5J93b6SvtjpCK9+9N+OzuzlatomsQ5+WBG9a s64SsWKzP78Ssg1DtnfCzp0euYSn+nSTydTGWmFPrrYdI6k7kEPB88iKy4Ywb5QGeETc EBs/eJ/cCkX1l9RuJNRgq+rr+dyv+bLLtgoRqwG4xhCyzQA6fenSSnpBmu41ZkA6lamS RFeNHp4PHTdnaKhRXY28xbpxLUon6Rm/K4VqJa4A6B6G221Zb8SXFg/e08DYjyPhu2Tu Dkvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=pwKd5NL3; 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=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k8-20020a056a00134800b004fa3a8dff83si13880271pfu.58.2022.04.12.16.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:45: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=@quicinc.com header.s=qcdkim header.b=pwKd5NL3; 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=quicinc.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 456011CFF8B; Tue, 12 Apr 2022 14:37:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387997AbiDLJVa (ORCPT + 99 others); Tue, 12 Apr 2022 05:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356581AbiDLHi7 (ORCPT ); Tue, 12 Apr 2022 03:38:59 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C9551E5D; Tue, 12 Apr 2022 00:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649747389; x=1681283389; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=N4ulgrYlIfenBw7Hm6+VMNDmIviNdtjf6yJOdqnjax0=; b=pwKd5NL3CjRgKRD1FGYF8TrJqmOxKscs4VQVKtU0LsvOUUMjQzqUBE+X NC5pdNOj6j26l+mhTXajMW8tKkc6yZQ2J64lPC8dZcEhcp7gxMcGYAqDO 3slKCbOk0kVYmezTT0amYsPu4QoEGODffSnTfG6oNM7HzivvLms/RhvJ6 Y=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 12 Apr 2022 00:09:48 -0700 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 00:09:48 -0700 Received: from hu-vgarodia-hyd.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Apr 2022 00:09:46 -0700 From: Vikash Garodia To: , CC: , Subject: [PATCH 1/2] media: venus: do not queue internal buffers from previous sequence Date: Tue, 12 Apr 2022 12:39:15 +0530 Message-ID: <1649747356-3207-2-git-send-email-quic_vgarodia@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1649747356-3207-1-git-send-email-quic_vgarodia@quicinc.com> References: <1649747356-3207-1-git-send-email-quic_vgarodia@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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=no 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 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. --- drivers/media/platform/qcom/venus/helpers.c | 37 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 0bca95d..0602f03 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -90,12 +90,31 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_check_codec); +static int venus_helper_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); + + return 0; +} + 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 +125,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) { + venus_helper_free_dpb_buf(inst, buf); + continue; + } + fdata.clnt_data = buf->dpb_out_tag; ret = hfi_session_process_buf(inst, &fdata); @@ -127,13 +152,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); + venus_helper_free_dpb_buf(inst, buf); } if (list_empty(&inst->dpbbufs)) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project