Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp412853pxu; Tue, 1 Dec 2020 14:39:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6hyHfGCOrNSuYZtNTnMrk91Z1gP66+832f9qY/rEf3yATaOEI+fGzsALtJehm9IeHU8TB X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr5494502edu.306.1606862397410; Tue, 01 Dec 2020 14:39:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862397; cv=none; d=google.com; s=arc-20160816; b=r9pQj2cYRU8NJKLDBSUf7Ax93o+vz7D/aFB+uRBkjaX6t8piiG0Excxa43ZkuLgKc0 qvsJ+/1fylXHdbY2PdkV/wI6BGkt80MotkAK1nUgoUIfYqp9n3c7Qhas56njaz2NCHP/ pWUU8C6/fMuoYK+wLVkQJ37RuLjAkYxHsx2IXIkJdtuUxpEJwHTedpI/GwIqR/PL/QU9 7sGhCKCfno+/mImXmxFLovCR2qsN9Bfvs8SyMJhYvWUkh6m4w2rug/FvxTeWh/Bm26S4 4f/c6iGq+49kgdV7LMovyi5sPObNUvWh8UHpdPTFA6LJWdy00AbtENf5V/i9cbVV+0Nl M4KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=Yvo9niEDaxPhTUXyHt8vt7CyJEGrV1jvtlgHeLTY/fc=; b=jTTd0Cd7ZhH0TadY9Cw5dt94Q9bkf8C6BYH8bLwHDevSuHIXbN853uQnt4zqgc3NsT AhrwfEF/hwMaGSOb3q0hwMim5O6z/h9Oxnl8/iBFunwfbi/Rqo+68r+eT3xpeHFZdJcA gPThSdrK+PX3laptzTE/XKT2V42aXAu9DmL9309+qcURH40fOyBZWpH43o75yjXhQIpV T1MLJrCcGo0ZA2GWCId0MYaLcC7c3tIkEQFbOfYebHOWxwMG4h3rfym1rxkpA1+SFB7V acHMCTFVfKL2vZzlvHlCBujCtZfbtDbGvcbklJtR48F0WGYcOc4NYeEgkSSzIC9Co/aL ZfZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GZb7zhGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si771674edx.70.2020.12.01.14.39.34; Tue, 01 Dec 2020 14:39:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GZb7zhGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726082AbgLAWfm (ORCPT + 99 others); Tue, 1 Dec 2020 17:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgLAWfl (ORCPT ); Tue, 1 Dec 2020 17:35:41 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5BBC0613CF for ; Tue, 1 Dec 2020 14:34:55 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id c7so5919794edv.6 for ; Tue, 01 Dec 2020 14:34:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Yvo9niEDaxPhTUXyHt8vt7CyJEGrV1jvtlgHeLTY/fc=; b=GZb7zhGb9fwx8s43+sxGE90a76Q6/tDxePSL/MYKMBMC96onF3fg8FBHyaiqMfG9HO bQAcivow12xDUN/BJJus/Po+QuipUMtrCOAtIscQ3OrXkKi4/qvL/u2vduE6qWmBzy4k qATUvgGjL3r/nW6PR5RjSJ0V9Z+fsHdfi2hdYvqhWOwWlk30fPPB2uAkCOOhZF5uNDLZ IhtUvFHajZDyklToVNTdzs98tpGvhOc6Fy8+Kc+FetVnQ1XfkcqRTOn7UNh/bXi/S1Ll DHxCAj61qkWg1RQZylxE3Jh/tcXziDzkERVIRNSJS70XiBHnb0ExxlaCFQFMMlSKzBg+ GXXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Yvo9niEDaxPhTUXyHt8vt7CyJEGrV1jvtlgHeLTY/fc=; b=VdhW7tpHb4PQFr803O4BPOp08rPC3fZL6RM0hGIlC2F3ww3X37lThRyrb1WP0RYREH NdOYKRzclDTwDV232gZGi8gKY4uHCoaLwLmJu/2/nXwrXvOx4+NC/tPn0ScftZRgNmJp AIIit6Bp5OLhfaZDyzchP7BBn+0RVb3PnVWiHJVLOfyz9Ta0a37GnqdB9gsCoh9qmeVu WIZdf7EI+H8pZQjiPVpJnDkWH/2JDd7CBNrBRDCTWAn8BFQDmnLvisP+BjpJ1EgBomde nzxWqmnyVsLQZCSks6DDOqyiuJInTynf3DHIqIhHvOpGr7/y8yPYKqZLcTCkBEAMFgOZ Ccqg== X-Gm-Message-State: AOAM5309725yTG+iSgulAnqzYx1pfvONRDXRcNvmBXxfCJutpBJWmElz MgEqtXnGD1R1o2Jh567gTnRDxZvWyd7HoL/o X-Received: by 2002:a50:9991:: with SMTP id m17mr5384860edb.48.1606862093621; Tue, 01 Dec 2020 14:34:53 -0800 (PST) Received: from [192.168.0.3] (hst-221-103.medicom.bg. [84.238.221.103]) by smtp.googlemail.com with ESMTPSA id k18sm546231edx.18.2020.12.01.14.34.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2020 14:34:53 -0800 (PST) Subject: Re: [PATCH v2] venus: vdec: Handle DRC after drain To: Fritz Koenig , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, vgarodia@codeaurora.org, dikshita@codeaurora.org, acourbot@chromium.org References: <20201201042322.3346817-1-frkoenig@chromium.org> From: Stanimir Varbanov Message-ID: <57cc5999-e54c-219c-812b-71b214dbe760@linaro.org> Date: Wed, 2 Dec 2020 00:34:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201201042322.3346817-1-frkoenig@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fritz, On 12/1/20 6:23 AM, Fritz Koenig wrote: > If the DRC is near the end of the stream the client > may send a V4L2_DEC_CMD_STOP before the DRC occurs. > V4L2_DEC_CMD_STOP puts the driver into the > VENUS_DEC_STATE_DRAIN state. DRC must be aware so > that after the DRC event the state can be restored > correctly. > > Signed-off-by: Fritz Koenig > --- > > v2: remove TODO > > drivers/media/platform/qcom/venus/core.h | 1 + > drivers/media/platform/qcom/venus/vdec.c | 17 +++++++++++++++-- > 2 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h > index 2b0899bf5b05f..1680c936c06fb 100644 > --- a/drivers/media/platform/qcom/venus/core.h > +++ b/drivers/media/platform/qcom/venus/core.h > @@ -406,6 +406,7 @@ struct venus_inst { > unsigned int core_acquired: 1; > unsigned int bit_depth; > bool next_buf_last; > + bool drain_active; Could you introduce a new codec state instead of adding a flag for such corner case. I think that we will need to handle at least one more corner case (DRC during seek operation), so then we have to introduce another flag, and this is not a good solution to me. These additional flags will complicate the state handling and will make the code readability worst I'd introduce: VENUS_DEC_STATE_DRC_DURING_DRAIN or something similar. > }; > > #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) > diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c > index 5671cf3458a68..1d551b4d651a8 100644 > --- a/drivers/media/platform/qcom/venus/vdec.c > +++ b/drivers/media/platform/qcom/venus/vdec.c > @@ -523,8 +523,10 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) > > ret = hfi_session_process_buf(inst, &fdata); > > - if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) > + if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) { > inst->codec_state = VENUS_DEC_STATE_DRAIN; > + inst->drain_active = true; > + } > } > > unlock: > @@ -976,10 +978,14 @@ static int vdec_start_capture(struct venus_inst *inst) > > inst->codec_state = VENUS_DEC_STATE_DECODING; > > + if (inst->drain_active) > + inst->codec_state = VENUS_DEC_STATE_DRAIN; > + > inst->streamon_cap = 1; > inst->sequence_cap = 0; > inst->reconfig = false; > inst->next_buf_last = false; > + inst->drain_active = false; > > return 0; > > @@ -1105,6 +1111,7 @@ static int vdec_stop_capture(struct venus_inst *inst) > /* fallthrough */ > case VENUS_DEC_STATE_DRAIN: > inst->codec_state = VENUS_DEC_STATE_STOPPED; > + inst->drain_active = false; > /* fallthrough */ > case VENUS_DEC_STATE_SEEK: > vdec_cancel_dst_buffers(inst); > @@ -1304,8 +1311,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, > > v4l2_event_queue_fh(&inst->fh, &ev); > > - if (inst->codec_state == VENUS_DEC_STATE_DRAIN) > + if (inst->codec_state == VENUS_DEC_STATE_DRAIN) { > + inst->drain_active = false; > inst->codec_state = VENUS_DEC_STATE_STOPPED; > + } > } > > if (!bytesused) > @@ -1429,9 +1438,13 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event, > case EVT_SYS_EVENT_CHANGE: > switch (data->event_type) { > case HFI_EVENT_DATA_SEQUENCE_CHANGED_SUFFICIENT_BUF_RESOURCES: > + if (inst->codec_state == VENUS_DEC_STATE_DRAIN) > + inst->codec_state = VENUS_DEC_STATE_DECODING; Could you move this state transition into vdec_event_change(). That way we will do it only once. > vdec_event_change(inst, data, true); > break; > case HFI_EVENT_DATA_SEQUENCE_CHANGED_INSUFFICIENT_BUF_RESOURCES: > + if (inst->codec_state == VENUS_DEC_STATE_DRAIN) > + inst->codec_state = VENUS_DEC_STATE_DECODING; ditto > vdec_event_change(inst, data, false); > break; > case HFI_EVENT_RELEASE_BUFFER_REFERENCE: > -- regards, Stan