From patchwork Fri Dec 4 10:01:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 337747 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp111722ilb; Fri, 4 Dec 2020 02:04:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4ioQ/b3D6kFAZr8j08Mqlp4vbZBzBW7jMoWdGJ1h+kIr51LLh73pclu7r30Y9g6rtTQVl X-Received: by 2002:a17:906:5847:: with SMTP id h7mr6160229ejs.124.1607076291315; Fri, 04 Dec 2020 02:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607076291; cv=none; d=google.com; s=arc-20160816; b=QgBsZYwVr0Y3ncGrNs9PxtMecFucVceR4Hv09GxQJaJvtOvthDco6FpGzHIoFuSL5q nZlXR0Ax/WfLa+ql2I6jrrhs+MVfj103/nrjh1WIiOxl53p9c0seK0EXD+MtpzxJq73s 9eY+XQW2kUrCxAb3gT4HUvWxXYqRG8iOHJHBaYWmRNENqDgCLMG28egdUe9BZ/vRdq/R wha681sLYCQvk+k/lQuprVk6/n6rz3dK6jNnyQDWPbqu3XYL0o4scDERujsKW7s3ZC7T ft5vqjJ+WoXwMKh6E5czk6qfp/UUe2sx2oBxHlHoYyTPK5F/xXmEjqeyKJffFTtcoDVx wHxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=LyeOql6QYmpd/1nhWP8WR5ehn5BlBeFQlh24gAVBRhU=; b=FejIkfj8FTYLfIb3hXuViXCT5SCLQ+/zb09IPfQ5iXLFpBi9ljS0RqiwgVXwlGZ99e 9wmofvXgpu5ZAGVlVGvD1p2tiq9wH7U+Iuze1hWrjUQ2wSxwssqsNQ/Ve3cJ1Dfg/gzr 8yOutIOR155fEhIjXOfyIDaYGDBr/KHBlcaV5zzrObQCvyFtjjC2znIjb3g8pelIQL4J nUSVwq1G8EStZdImyE72gW8Zwf5R8Pi/w/p/im2BE82aRnoiTlMpM+3gdkXc5QUkTrMM T4pHmJRuEMPAY7hdtUrGdvPkla3YB46gSWTCUFSpNuyId6MHWGGy36y1CS+yPvm6nEWP N5eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qgzeAQEa; 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 nq7si1077203ejb.109.2020.12.04.02.04.51; Fri, 04 Dec 2020 02:04:51 -0800 (PST) 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=qgzeAQEa; 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 S2387867AbgLDKD3 (ORCPT + 15 others); Fri, 4 Dec 2020 05:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387832AbgLDKD2 (ORCPT ); Fri, 4 Dec 2020 05:03:28 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F35DC061A56 for ; Fri, 4 Dec 2020 02:02:09 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id v22so5200967edt.9 for ; Fri, 04 Dec 2020 02:02:09 -0800 (PST) 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; bh=LyeOql6QYmpd/1nhWP8WR5ehn5BlBeFQlh24gAVBRhU=; b=qgzeAQEaUfEMnYTzNM6py9Wnux2p0x09OoGjBhg6NOU+FMrXss1qgfQ2Uo9T7VGEFY 16Bg01jAAwONWqA+zIP0xQdFQ+WuV9G5+CWhheMyc0v/q9uLo9HhQldX2zN2V6chcSSs NFQ4OVqUn8nKlV5wiYdOnU+C7sXxPsTFJXehDaoz0XvfMVi8MDhNjTnuqxKT6/GjUOpj 5BipSy7smzfy9UHC2OpEr3RC/830bP9YW0DDPkivv2ZAoPd+i7x4Jbt/HrXKB6oWCXdI dcTHH0KTii8Jlnw61wrgR7lo7b6KuMu49VfvcBxEtQfd7RTrsAhboI0uD0dojTGwgNjp fDjA== 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; bh=LyeOql6QYmpd/1nhWP8WR5ehn5BlBeFQlh24gAVBRhU=; b=AOdjpNbJYQub6T5P2Wzd1LuJkMyVUjbOEE8/tHCPcLWyOKdF3DtP+RnhH6j5Oq6m7a vrqjTruDJ1e0BucnktbWf8wW5pb0AFSOz4dX5jy+OeCbLYWsdWnOBAgpsg8ubA4zB/9t ES1SacM6E46RmObe8bgFZBIVUJmgV3qR0Px2yVGvJ0vEzJg+5YlywJD85qpDaoX2Q1NN wlvZa4kpaY8uDIWtCiMlsPKZZrGnZiTWIC13zf7bjQxIZX74KrxtvA5AvhaMOV7+6+r3 dbl2/JU6j2x+R4cxig/l2SVVjuu41ScZ6wTmnFyDadm9YmArrfOIceMMCuo4T7HPfbjt UCKg== X-Gm-Message-State: AOAM532xxPc6GDaJdNHRyCQYhYW0YGakk3abM4p+e1HOUTpwr9wWokOk GHiQqxUNVGma+J4+pi3gifhkng== X-Received: by 2002:a50:b941:: with SMTP id m59mr6871336ede.371.1607076128347; Fri, 04 Dec 2020 02:02:08 -0800 (PST) Received: from localhost.localdomain (hst-221-106.medicom.bg. [84.238.221.106]) by smtp.gmail.com with ESMTPSA id p35sm3238242edd.58.2020.12.04.02.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 02:02:07 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dikshita@codeaurora.org, Alexandre Courbot , Vikash Garodia , Stanimir Varbanov Subject: [PATCH v2 2/4] venus: Limit HFI sessions to the maximum supported Date: Fri, 4 Dec 2020 12:01:37 +0200 Message-Id: <20201204100139.6216-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204100139.6216-1-stanimir.varbanov@linaro.org> References: <20201204100139.6216-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Currently we rely on firmware to return error when we reach the maximum supported number of sessions. But this errors are happened at reqbuf time which is a bit later. The more reasonable way looks like is to return the error on driver open. To achieve that modify hfi_session_create to return error when we reach maximum count of sessions and thus refuse open. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/hfi.c | 16 +++++++++++++--- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..775d7bf6587d 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -96,6 +96,7 @@ struct venus_format { #define MAX_CAP_ENTRIES 32 #define MAX_ALLOC_MODE_ENTRIES 16 #define MAX_CODEC_NUM 32 +#define MAX_SESSIONS 16 struct raw_formats { u32 buftype; diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 638ed5cfe05e..8786609d269e 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -175,6 +175,8 @@ static int wait_session_msg(struct venus_inst *inst) int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) { struct venus_core *core = inst->core; + bool max; + int ret; if (!ops) return -EINVAL; @@ -184,11 +186,19 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) inst->ops = ops; mutex_lock(&core->lock); - list_add_tail(&inst->list, &core->instances); - atomic_inc(&core->insts_count); + + max = atomic_add_unless(&core->insts_count, 1, + core->max_sessions_supported); + if (!max) { + ret = -EAGAIN; + } else { + list_add_tail(&inst->list, &core->instances); + ret = 0; + } + mutex_unlock(&core->lock); - return 0; + return ret; } EXPORT_SYMBOL_GPL(hfi_session_create); diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c index 363ee2a65453..52898633a8e6 100644 --- a/drivers/media/platform/qcom/venus/hfi_parser.c +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -276,6 +276,9 @@ u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf, words_count--; } + if (!core->max_sessions_supported) + core->max_sessions_supported = MAX_SESSIONS; + parser_fini(inst, codecs, domain); return HFI_ERR_NONE;