From patchwork Tue May 18 15:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441219 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352405jac; Tue, 18 May 2021 08:46:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+O/5/dWRIaAgR3XRAPyFor/BSHy7xRg9sNrBc1lGgm/iC5Ad82WCxJXVOi4Ht4chvCjac X-Received: by 2002:a05:6638:597:: with SMTP id a23mr6107924jar.27.1621352804254; Tue, 18 May 2021 08:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352804; cv=none; d=google.com; s=arc-20160816; b=nwq3t2zwJGiST9GmvaFcfzq3quq8Y+6Jj/dv4falmgvKptJ/e/9ItQZ1eOMVQC8nGj ulFr+M/zJ4fDgI1oGLoJhb5bQTSarl+tQ81r7ulGbs7jOHQ5Z73hzj1UG2CoyTSP2D4C Mp7roDXt+pEbhwHIKVbjj/SjM9NpRlCKmuzBj2UkKaWSeQ4tn9tUy290yBoCUS4ppVIN MgoYxhQu3kUU4+7nrdHQvWpw20F2jrXhLwLTwlhikmRWipjOA961f1yab1+iibOcKBd6 RRWf/WI0UxBnsaoJMqnRvBrgAwtN8ZW/kYNXyiVi7nEeAcYgO0hh/GInrRl3d8scSj6K pSLg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=I+uokykHZeMy2+feXn3LjsoQgLFsXUEkSOMV0oTIkUR9xFwsgPsg9/hEJtKPN+Kj/X xr9VY1IcTFn915gEJi0Qoo743xvLCCMlRzwBEDJgNKJx2DfXFhH4VqxVXIAMWH9ftNqJ gKbF1YvWcNQ821VIdELUZB5eHgGUaZeAo8aXy3PIhsqm79OdNWaE6kSbFdLdZJho728p r/ptKtkUJ5bVG+bPvI8uLY28uAtPTezZqpKMizDpZ8Okf3VD3V7iRTW8pMJvDKpe0GyR 94gZgKsAidiIBpuLzkYvW9hSdCqH4FFnnGOyyi07DTgvk3bfqwLpxylgkNfMDa0fcrCq oujQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NPEiXHCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v3si21970616ilq.36.2021.05.18.08.46.44; Tue, 18 May 2021 08:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=NPEiXHCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1350376AbhERPr4 (ORCPT + 17 others); Tue, 18 May 2021 11:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350307AbhERPrR (ORCPT ); Tue, 18 May 2021 11:47:17 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C2FFC06138E for ; Tue, 18 May 2021 08:45:28 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id z12so13873500ejw.0 for ; Tue, 18 May 2021 08:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=NPEiXHChn3WwgCCrlRDA2Pr9U8tOuNH538BPSpd6Al/XC/DBBtreV9h6ky5XUB8nar SKRS88Uz4OxHyDtGhi70CfQQw84mcg5CgFOXbRZ/3nhOfur2gOfyzHfItD/+3yEo5ksT 8FOHplGBOw1A/PSedhwiGZ5jhd+n9SV2IBCck01s8RYdVtV0VHZjFxKePBkBFZYGZBMv GoBZ6fyl11KKhuBmYnfURitHCDEGRjlfhze8TajoPf0I2M8mbXF6M/jQ9MjAPXC0wRXk u1mWPItXfjpfcEYModQmL9mWx1lfajVZ2ErNwFVeM5zjU4gS10tsFFyZJl+EOHJW2XHx Qgfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=mcui7oF+U3DDl4J8i2liLBn5lzMmbIPZLPs0jchPwBeWYKpmO/dw+9f5Dfp9y+I7mK BqM2apXdJAvd6VtCBKfxYdg7cQKpIz6Mp8FhsVwC6N+1YIdov2I4K55kJnbXN2/Swds1 3Uo16CEXjEnMcMZdPa7ByFDoC8zkzruMbIwzGrKbvb3QPEmVCSvFZZn1XzhpUvJa2MIw LBzG2NV11sJVN28lRbVby7+DW/gu4gr1lgdA0EqYLW1PiUbjhUVUKDV/DM6UqXMI+f5K FVX+wXDA6QiJTx4kf/0O4LMt7ozmi0/slBTp5U7dYT65nD3sONH/PFkLRcDaaQTROYvo EDuA== X-Gm-Message-State: AOAM533wz+VX1Vt9fM6y/csIiX4wMITjf/mG6rvPn2zap81Qnz6yVPkc ecaNOe5/ad/tu4RuzzXPJPAoTA== X-Received: by 2002:a17:906:2b57:: with SMTP id b23mr6625927ejg.294.1621352726608; Tue, 18 May 2021 08:45:26 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45:26 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH 3/5] venus: hfi: Check for sys error on session hfi functions Date: Tue, 18 May 2021 18:45:07 +0300 Message-Id: <20210518154509.602137-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Check sys error flag for all hfi_session_xxx functions and exit with EIO in case of an error. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi.c | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- 2.25.1 diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 179b1f8b2650..4e2151fb47f0 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -187,6 +187,11 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) mutex_lock(&core->lock); + if (test_bit(0, &inst->core->sys_error)) { + ret = -EIO; + goto unlock; + } + max = atomic_add_unless(&core->insts_count, 1, core->max_sessions_supported); if (!max) { @@ -196,6 +201,7 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) ret = 0; } +unlock: mutex_unlock(&core->lock); return ret; @@ -263,6 +269,9 @@ int hfi_session_deinit(struct venus_inst *inst) if (inst->state < INST_INIT) return -EINVAL; + if (test_bit(0, &inst->core->sys_error)) + goto done; + reinit_completion(&inst->done); ret = ops->session_end(inst); @@ -273,6 +282,7 @@ int hfi_session_deinit(struct venus_inst *inst) if (ret) return ret; +done: inst->state = INST_UNINIT; return 0; @@ -284,6 +294,9 @@ int hfi_session_start(struct venus_inst *inst) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state != INST_LOAD_RESOURCES) return -EINVAL; @@ -308,6 +321,9 @@ int hfi_session_stop(struct venus_inst *inst) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state != INST_START) return -EINVAL; @@ -331,6 +347,9 @@ int hfi_session_continue(struct venus_inst *inst) { struct venus_core *core = inst->core; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (core->res->hfi_version == HFI_VERSION_1XX) return 0; @@ -343,6 +362,9 @@ int hfi_session_abort(struct venus_inst *inst) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + reinit_completion(&inst->done); ret = ops->session_abort(inst); @@ -362,6 +384,9 @@ int hfi_session_load_res(struct venus_inst *inst) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state != INST_INIT) return -EINVAL; @@ -385,6 +410,9 @@ int hfi_session_unload_res(struct venus_inst *inst) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state != INST_STOP) return -EINVAL; @@ -409,6 +437,9 @@ int hfi_session_flush(struct venus_inst *inst, u32 type, bool block) const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + reinit_completion(&inst->done); ret = ops->session_flush(inst, type); @@ -429,6 +460,9 @@ int hfi_session_set_buffers(struct venus_inst *inst, struct hfi_buffer_desc *bd) { const struct hfi_ops *ops = inst->core->ops; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + return ops->session_set_buffers(inst, bd); } @@ -438,6 +472,9 @@ int hfi_session_unset_buffers(struct venus_inst *inst, const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + reinit_completion(&inst->done); ret = ops->session_unset_buffers(inst, bd); @@ -460,6 +497,9 @@ int hfi_session_get_property(struct venus_inst *inst, u32 ptype, const struct hfi_ops *ops = inst->core->ops; int ret; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state < INST_INIT || inst->state >= INST_STOP) return -EINVAL; @@ -483,6 +523,9 @@ int hfi_session_set_property(struct venus_inst *inst, u32 ptype, void *pdata) { const struct hfi_ops *ops = inst->core->ops; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (inst->state < INST_INIT || inst->state >= INST_STOP) return -EINVAL; @@ -494,6 +537,9 @@ int hfi_session_process_buf(struct venus_inst *inst, struct hfi_frame_data *fd) { const struct hfi_ops *ops = inst->core->ops; + if (test_bit(0, &inst->core->sys_error)) + return -EIO; + if (fd->buffer_type == HFI_BUFFER_INPUT) return ops->session_etb(inst, fd); else if (fd->buffer_type == HFI_BUFFER_OUTPUT ||