From patchwork Tue Jun 8 11:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 455767 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3648492jae; Tue, 8 Jun 2021 04:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl66p2SC0RFXBwCrLT5CadDimasdeFutHTEFseKXXTHcl5iHyOFZS0G4GMqVhmsr0SwtJz X-Received: by 2002:a05:6402:2805:: with SMTP id h5mr8760505ede.379.1623152586662; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152586; cv=none; d=google.com; s=arc-20160816; b=ZK0hDpwwSxP+0ZviiW/uAs5BiR8wbtjGvHwtZebd+LXe1dc6P9E6YCoq8Nj35/3GUM /a6YDbd7Suyqs9h8rl/jAsgP7bHU61GdVce4OhFYyK29E6R2HOXSlIfNDVHt/PLOluQf K+R40+hcPEvbn0Rgg1Eh0Kv6ItIsDNXdyfYSAbdrIka8Rfl0rWGJHvATHEQmpKZHxIww WXxbuPLsFN7tgQb4hUsJEenQ2bfXpCUDzOeUxKfO00JUrxesckrENI8rYyjgl+QNN69+ dS/mkZPlDbRA2I0+/sJf2EGCBgBuo+UxuUeujRUM4SuDBdH5YIPFSZNpEvwwG+uuJusx uWKw== 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=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=Cha0H4DuZ/VwfRhvaNad9mG2m7A1XqyVEuOmthFbsr2+FfP9SkIzcPwenoMxVVcEuG Pwb5iFHglynp0LpGLrLs71LZbuVAAzZROGdWNch8wnTliwsKsRZJuvxF30eos3vuC97r nwi1Wttz1+0shX/OjER8qtqvRWEDHdtHPyofMDgjjO4Jd/BtTNCw4tw3zguWjkDlppN+ SLJbzjswoLSaUBthZemJ1Jjv5Cz8ggCjGqdGHp8jpv6FnyOQiwEYaj6o212sCq6lZ8F/ Y5jr4+X3YrpwiPGNbsyBKLltfq3A8E3t1xtsCu7GrjnOetzUxG9cowQC6awLoa7kL09s 7gKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QG/wJKFp"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-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 l10si7740928edq.534.2021.06.08.04.43.06; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-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="QG/wJKFp"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-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 S232063AbhFHLoZ (ORCPT + 4 others); Tue, 8 Jun 2021 07:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231952AbhFHLoY (ORCPT ); Tue, 8 Jun 2021 07:44:24 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6433EC06178B for ; Tue, 8 Jun 2021 04:42:31 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id u24so24115084edy.11 for ; Tue, 08 Jun 2021 04:42:31 -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=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=QG/wJKFpRPzOEUjVnHHgCiipF5S/uZflN9CSbI/EZ499HxfDH2LyWhCQGMaRwX63GR cyZVrASsK+yDEOcb6wp3S/B9P0iGLsUrZoky7sjPviqNrBYbgozMFxG5Ygc9XRPKtKkB Blic0n4W89QaSKySvQcZr8ua9PBBk958JeicyM7MlddGuX7L0WtVpjvz09jsgPwQuQi+ gU4u67SEkn01kb8FIRu4dDxlZiETFxTZ888peJK7suaY5tBf0nNkbgRDEBQA3aPD7cAZ EsWatH9P508SnFZpDc3aLzbNlJ7sObezxGWFlhf6kNrgiGo54VGYqZDmYUMHGncIdht/ dHgA== 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=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=Tqt709p/eLuH9MV78vZotNIGmXYJNV2zwRdH8hQ+We0kyAhrcG+7TaH/l3J2fN4TqA ct8bq1TjqNI2g15D74QQ62YjFi4nBgCfiO18rv1RVGXMuBQLM+4SnM1rznIb/vmMeGiY n+BaLiEo3EWQuYHkVYLauM+xjFhpy7rDIf8xMY3oxWPm9Uo4CHLmoE6lt1GbI4iSJEut gGpRif8LqcWqMb2fPNfKyZbumkH2aNQymxEvApy6dOt8vBrF1gF5zUfdYskPBaWtj4pF XKqxswwE8RFiTPBhYiEb3ayIg4COVu/JEcqOuGRTQdlGselwCGPElFNgB393UrjeSyCA c3Ow== X-Gm-Message-State: AOAM5330KpvM36yErbmUI5vVPgJRjZXILS3G/7NOvjco0lKyKBIhof9J z6whyHXph5OPyomL8+Jd6pxQkukTrZ76xin6 X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr24744852edd.111.1623152549669; Tue, 08 Jun 2021 04:42:29 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:29 -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 v2 2/5] venus: Make sys_error flag an atomic bitops Date: Tue, 8 Jun 2021 14:41:53 +0300 Message-Id: <20210608114156.87018-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make the sys_error flag an atomic bitops in order to avoid locking in sys_error readers. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 4 ++-- drivers/media/platform/qcom/venus/core.h | 3 ++- drivers/media/platform/qcom/venus/helpers.c | 2 +- drivers/media/platform/qcom/venus/hfi.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 91b15842c555..cc6195f2409c 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -65,7 +65,7 @@ static void venus_event_notify(struct venus_core *core, u32 event) } mutex_lock(&core->lock); - core->sys_error = true; + set_bit(0, &core->sys_error); list_for_each_entry(inst, &core->instances, list) inst->ops->event_notify(inst, EVT_SESSION_ERROR, NULL); mutex_unlock(&core->lock); @@ -161,7 +161,7 @@ static void venus_sys_error_handler(struct work_struct *work) dev_warn(core->dev, "system error has occurred (recovered)\n"); mutex_lock(&core->lock); - core->sys_error = false; + clear_bit(0, &core->sys_error); mutex_unlock(&core->lock); } diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 8df2d497d706..a625a8477f75 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -7,6 +7,7 @@ #ifndef __VENUS_CORE_H_ #define __VENUS_CORE_H_ +#include #include #include #include @@ -181,7 +182,7 @@ struct venus_core { unsigned int state; struct completion done; unsigned int error; - bool sys_error; + unsigned long sys_error; const struct hfi_core_ops *core_ops; const struct venus_pm_ops *pm_ops; struct mutex pm_lock; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 1fe6d463dc99..210c628ac8f4 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1477,7 +1477,7 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) ret |= venus_helper_intbufs_free(inst); ret |= hfi_session_deinit(inst); - if (inst->session_error || core->sys_error) + if (inst->session_error || test_bit(0, &core->sys_error)) ret = -EIO; if (ret) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 0f2482367e06..179b1f8b2650 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -214,7 +214,7 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt) * session_init() can't pass successfully */ mutex_lock(&core->lock); - if (!core->ops || core->sys_error) { + if (!core->ops || test_bit(0, &inst->core->sys_error)) { mutex_unlock(&core->lock); return -EIO; } diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 198e47eb63f4..68736359fc2c 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1211,7 +1211,7 @@ static void vdec_session_release(struct venus_inst *inst) ret = hfi_session_deinit(inst); abort = (ret && ret != -EINVAL) ? 1 : 0; - if (inst->session_error || core->sys_error) + if (inst->session_error || test_bit(0, &core->sys_error)) abort = 1; if (abort)