From patchwork Fri Nov 20 00:10:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 329248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BE24C64E7D for ; Fri, 20 Nov 2020 00:11:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5F3622255 for ; Fri, 20 Nov 2020 00:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BG6u3FCS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgKTAKz (ORCPT ); Thu, 19 Nov 2020 19:10:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgKTAKy (ORCPT ); Thu, 19 Nov 2020 19:10:54 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59491C0613CF for ; Thu, 19 Nov 2020 16:10:54 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id y17so10409659ejh.11 for ; Thu, 19 Nov 2020 16:10:54 -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=8BqZDLR1KTW64ATacSPyzowe3YEGiz4Vofe4t7uU5S0=; b=BG6u3FCSYsvXsxcLJ3ptCA3WefTMqhq4F6JIdT1lsuAQQhPqfvAAkEvbQe3onfAuoW wMH7DDBnJjrzUoXss2CRC7QQZGOSikeyGenriG7/sdwnF0sKG33tLSnZ5kFv9x82G4+w kakz+fMlJ0fxG8b2dccrlKymBPLL0uSF4Fm2ucan75d4I+vrvtRo52A2a23zM/ByAshP 3CqNIEoXSTdKBb+fG1XKtd3ItgQ2foLUmmATksCcFPxgABepsgrpWo/hcwy1C3MuQ9Na omw7FxX3J0vYI/ba6yPSBBip9oc3EjTuQSsNZ1miu5YcZwZfdrXrUu8iYq1X/HjFuXfG UkPg== 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=8BqZDLR1KTW64ATacSPyzowe3YEGiz4Vofe4t7uU5S0=; b=UjPDnO08r4oc2dX4q47cig75YA6OlM70D+vq5uF5hHnJArTv2kTiz2OR8IA42Dra0j B0LSkzRSfEqj8fiTjbnPz1R5rWLssiMaxyX+pLqNxGxpZjJwXrt3D1//qxVYAef6XHF5 xUZGpsjIF13l9zjxuTWNQpuCjyLRQjkluYwpKfoDWKECLGKclwtLtrKPCjkg4l1XusAa iVhnEQ90VC0sVd7U25py/iLa3Ez9FT88V6BzJ0l3WVkfDUc8aPZLpa8JwqqCxiIUkhZt ivpPZqkAaFBBbSQbKoxt00m1oqOKvTgDw71qHFIanj0W7LActkKz5pN8yTDTF0UCoRBI pQPw== X-Gm-Message-State: AOAM5329o+gVyoMYXfxUJ6gVvwyzyohKusnTZx75ISRIDBi9o7Yt2v1K SGolKqJenF3c2D0y+VZPi9ggFeqnxr4LniB1 X-Google-Smtp-Source: ABdhPJySGdxMCiEw1PCMYgfl2sn85f7JCahwv/WnSPRnJWpsx6luiM58/wrwOiOE5F3J6rw+be0eIQ== X-Received: by 2002:a17:906:bc9a:: with SMTP id lv26mr29636980ejb.409.1605831053076; Thu, 19 Nov 2020 16:10:53 -0800 (PST) Received: from localhost.localdomain (hst-221-4.medicom.bg. [84.238.221.4]) by smtp.gmail.com with ESMTPSA id k23sm383556edv.97.2020.11.19.16.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 16:10:52 -0800 (PST) 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 , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 1/3] venus: venc: Init the session only once in queue_setup Date: Fri, 20 Nov 2020 02:10:35 +0200 Message-Id: <20201120001037.10032-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201120001037.10032-1-stanimir.varbanov@linaro.org> References: <20201120001037.10032-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Init the hfi session only once in queue_setup and also cover that with inst->lock. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/venc.c | 98 ++++++++++++++++++------ 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 4ecf78e30b59..3a2e449663d8 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -725,8 +725,10 @@ static int venc_init_session(struct venus_inst *inst) int ret; ret = hfi_session_init(inst, inst->fmt_cap->pixfmt); - if (ret) - return ret; + if (ret == -EINVAL) + return 0; + else if (ret) + goto deinit; ret = venus_helper_set_input_resolution(inst, inst->width, inst->height); @@ -762,17 +764,13 @@ static int venc_out_num_buffers(struct venus_inst *inst, unsigned int *num) struct hfi_buffer_requirements bufreq; int ret; - ret = venc_init_session(inst); + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); if (ret) return ret; - ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); - *num = bufreq.count_actual; - hfi_session_deinit(inst); - - return ret; + return 0; } static int venc_queue_setup(struct vb2_queue *q, @@ -781,7 +779,7 @@ static int venc_queue_setup(struct vb2_queue *q, { struct venus_inst *inst = vb2_get_drv_priv(q); unsigned int num, min = 4; - int ret = 0; + int ret; if (*num_planes) { if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && @@ -803,6 +801,17 @@ static int venc_queue_setup(struct vb2_queue *q, return 0; } + ret = mutex_lock_interruptible(&inst->lock); + if (ret) + return ret; + + ret = venc_init_session(inst); + + mutex_unlock(&inst->lock); + + if (ret) + return ret; + switch (q->type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: *num_planes = inst->fmt_out->num_planes; @@ -838,6 +847,54 @@ static int venc_queue_setup(struct vb2_queue *q, return ret; } +static int venc_buf_init(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + + inst->buf_count++; + + return venus_helper_vb2_buf_init(vb); +} + +static void venc_release_session(struct venus_inst *inst) +{ + int ret, abort = 0; + + mutex_lock(&inst->lock); + + ret = hfi_session_deinit(inst); + abort = (ret && ret != -EINVAL) ? 1 : 0; + + if (inst->session_error) + abort = 1; + + if (abort) + hfi_session_abort(inst); + + mutex_unlock(&inst->lock); + + venus_pm_load_scale(inst); + INIT_LIST_HEAD(&inst->registeredbufs); + venus_pm_release_core(inst); +} + +static void venc_buf_cleanup(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct venus_buffer *buf = to_venus_buffer(vbuf); + + mutex_lock(&inst->lock); + if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + if (!list_empty(&inst->registeredbufs)) + list_del_init(&buf->reg_list); + mutex_unlock(&inst->lock); + + inst->buf_count--; + if (!inst->buf_count) + venc_release_session(inst); +} + static int venc_verify_conf(struct venus_inst *inst) { enum hfi_version ver = inst->core->res->hfi_version; @@ -888,38 +945,28 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) inst->sequence_cap = 0; inst->sequence_out = 0; - ret = venc_init_session(inst); - if (ret) - goto bufs_done; - ret = venus_pm_acquire_core(inst); if (ret) - goto deinit_sess; - - ret = venc_set_properties(inst); - if (ret) - goto deinit_sess; + goto error; ret = venc_verify_conf(inst); if (ret) - goto deinit_sess; + goto error; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, inst->num_output_bufs, 0); if (ret) - goto deinit_sess; + goto error; ret = venus_helper_vb2_start_streaming(inst); if (ret) - goto deinit_sess; + goto error; mutex_unlock(&inst->lock); return 0; -deinit_sess: - hfi_session_deinit(inst); -bufs_done: +error: venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) inst->streamon_out = 0; @@ -940,7 +987,8 @@ static void venc_vb2_buf_queue(struct vb2_buffer *vb) static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, - .buf_init = venus_helper_vb2_buf_init, + .buf_init = venc_buf_init, + .buf_cleanup = venc_buf_cleanup, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, .stop_streaming = venus_helper_vb2_stop_streaming, From patchwork Fri Nov 20 00:10:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 328924 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp868968ils; Thu, 19 Nov 2020 16:12:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV9ByWJgFxQAX7wGJ50wdIBw9hCzekOvHDDbXphUk+SliKrq4rs51RZhdOioLeSwUtd/hQ X-Received: by 2002:a50:c40d:: with SMTP id v13mr33689228edf.1.1605831149370; Thu, 19 Nov 2020 16:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605831149; cv=none; d=google.com; s=arc-20160816; b=zrZzVSPGcfj/JTAYOrgC/+IC5c3WMliCY7Xm7Cj3ARsk5xrIQhS/zMrlmGA7rPI+1e ySrqAe14J/Mm/Q29A0gS6NtxPkFW5ZNS7EpVFrHvl2hw7j8VGix87ra1RlmZv/TyGtBU FAc24XLsHknuG7hGLiKgRDjQ1uNu42WSrGdFccl23AaCeOJvJRCahlJmfTyErrHXp3wr nJTP416jlrOOrmJetIs/35PjtrZ5TEYcniIOO7xQHb2CqrXtwuFz4JhqusogcrzJy4Sq DGD2xPOnmICHo3hARtDyBKxQHeq/MURxUlNLj/CsILi9zrKLdBTUFiI8oTxO5AIA9kiJ 5KJw== 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=XHTQ09ms588+UpKY9R43+BC+T+D0Aapxn3qmLnckRdI=; b=bsObJUKZYY2fED9teSIhth6LsL3RVxiy51n4v7CBydYcuGkM4kiZlNtOofj2JeB068 fiL9WoJdXTBSQVXSefsyLTICUfurFolPtNAdbwx7o0gf6yq3MHWRnNa3gqp8z4PsmZIe cfCUnE+SHVAGCo5YOcWGtSkT0qPPrIrtE+ZyuBbV32V5JcyUvieqekt4QfmAvbPii/qU J+ZSQalJ40NR0HCSkz20iFpYxx52EES2N+IdySqLOF5Gc2PWHzag/HiDlzCMaVhQNtw5 RYH38EfJ9O3+LAB0zV1VU4D4PWsdLBQCJQOp3HLiwKmKx9Mo8eYT8Fpx1tM4ujgY41qr OChw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XPlXiw46; 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 hs8si738377ejc.600.2020.11.19.16.12.29; Thu, 19 Nov 2020 16:12:29 -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=XPlXiw46; 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 S1726824AbgKTAK4 (ORCPT + 15 others); Thu, 19 Nov 2020 19:10:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbgKTAK4 (ORCPT ); Thu, 19 Nov 2020 19:10:56 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13FEC0613CF for ; Thu, 19 Nov 2020 16:10:55 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id o9so10498295ejg.1 for ; Thu, 19 Nov 2020 16:10:55 -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=XHTQ09ms588+UpKY9R43+BC+T+D0Aapxn3qmLnckRdI=; b=XPlXiw46FSemcBKRoOKNNQnGUdTBhsiSyqgouYR1IbEKgCJYNMz/FXHvSq4dJ6P7Xj pkwE7cCegNift3rcuFCdN+ArxEv6b1PbvvBebtRSBAUovmlY2fKenivK7xDb+E3LZEcA MWil0sBIeGCBrewI6yZI9tKI/2QKqqZ9SrWQ/6cAuvT9PYGi9JlzxnlXxgOW60I/hdQb uuuOiPXikS11Vj5bZ1zV2HvqD+f+XSaCx+Pw3WCNcTh5ub/B9Z+CqZAnTnCqYm9AH/Yd wvvwkaR66lE33F1MLn7BLAMsNy+DsufZE3s8MdQ2eKrOItJBYn7Wnu4Lt47qpP8EGwKY j+PQ== 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=XHTQ09ms588+UpKY9R43+BC+T+D0Aapxn3qmLnckRdI=; b=IGHjOju/1+P3z3zeD7eOw27CO+16mWcPF9mSTzejfdDxkqIaKQDfnfRscch/60/Oct lHKzhzTEGFOOcpThfTgbl036BTjPzQioONUxqh0RtBI1wgUcyQW7Pix1QAB35u9xsN7x wXd8FiLheiUYIRT6+Mrfdya7jQKO436DHePuIYPxIHEwl8m9N0hCOIhFGC1n02zYyUnf QZakePfAKQDtrmwPW1TBs0ez6ZM4E8YiL351zrKOXoWy4k6AplyFEyK0Q773uMgm0ISr 79DuiP22psurYLXL4L7roPkiJSiw+7o9EkWN84D1bKWj3bqu4pMl+LGKXLtIXE7ZWzZs 2hng== X-Gm-Message-State: AOAM53191OgDEjT5fV2G+2UkBtmvZkaHXbAA7/xDpFQEeZCahEzGB8Ra XhJPHqGMaQz+4DIn8Jd/Bd0now== X-Received: by 2002:a17:906:1b04:: with SMTP id o4mr17902421ejg.531.1605831054650; Thu, 19 Nov 2020 16:10:54 -0800 (PST) Received: from localhost.localdomain (hst-221-4.medicom.bg. [84.238.221.4]) by smtp.gmail.com with ESMTPSA id k23sm383556edv.97.2020.11.19.16.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 16:10:54 -0800 (PST) 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 , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 2/3] venus: Limit HFI sessions to the maximum supported Date: Fri, 20 Nov 2020 02:10:36 +0200 Message-Id: <20201120001037.10032-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201120001037.10032-1-stanimir.varbanov@linaro.org> References: <20201120001037.10032-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 | 19 +++++++++++++++---- .../media/platform/qcom/venus/hfi_parser.c | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Fritz Koenig diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index db0e6738281e..3a477fcdd3a8 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..8420be6d3991 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -175,6 +175,7 @@ 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; + int ret; if (!ops) return -EINVAL; @@ -183,12 +184,22 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) init_completion(&inst->done); inst->ops = ops; - mutex_lock(&core->lock); - list_add_tail(&inst->list, &core->instances); - atomic_inc(&core->insts_count); + ret = mutex_lock_interruptible(&core->lock); + if (ret) + return ret; + + ret = atomic_read(&core->insts_count); + if (ret + 1 > core->max_sessions_supported) { + ret = -EAGAIN; + } else { + atomic_inc(&core->insts_count); + 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; From patchwork Fri Nov 20 00:10: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: 328934 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp868987ils; Thu, 19 Nov 2020 16:12:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyh9X+qBldlrKQneytUnyx79j7HLGVHm7wtrwiIOzDCDiUuv4M6P+ZFuZ3G+3U3gzirsxOf X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr29672326ejg.503.1605831150618; Thu, 19 Nov 2020 16:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605831150; cv=none; d=google.com; s=arc-20160816; b=ZayeLpGZVKoEdwi0TfeaioC+HJyytyYveXUDw+lKcim3jUFrgqW1YHZpr4uCHhh+c/ 3VKPP2aQkyObHR7MreF0ZdaPYhSYM3JkpMFEe5faGARCw5gBoEcOo3ywM7vNMtPfg3DE leYNPNvKr9KrszPiWLSljrmCO+826KEdweuAjofBsZYCi9qUzdZxoiMnV85+dZ84EjS+ rCxjOi+4yKhPJZw4vkbEAs/e3XjmthfsTgmGwFs/JoHETe+drrKnzyw414fOQML3fnIM JEt/Sdnt5SJywbqzD03NKeRNOthXWXPRD0lPgg9bwN7CUPsMfwDOXNf7+afjfPCnSREe JsLg== 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=OVDKAEgKc07fjPVimTGuRqUwL4ug5893Az6X6hTx6dU=; b=mJO3IXXKtf27X4kdAFfxq85VtHv5FEx/KN/LghAzNPeHiFZWkYw4Hrvp21Myfg3kQ2 SaBohy9EVhn6MAs+jD15UO/0jHlz+H0dIMVDohVYun/ujmGe66NaBdAeswwmU13puXVX lrcrji5GmIKEQl7Jxo5vfJY3DNtXIfIJMryW6QLj18bN3Sav1j/D2Y2IPP7LZZTlcnjW RDy7UEjH+AY+sED8w5sP6zAEk6LAG3C21zMvLjkeZuDBIPDJk1YZp0rRWXoXD+1fUO4o 2O5cPbnSsXcAU3c8zyarq3j/dGyPWZ0kLZzw+fDcKl/LXzk21gjc+YMPegfKaq3xpqWz vzKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LCYHa3s5; 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 hs8si738377ejc.600.2020.11.19.16.12.30; Thu, 19 Nov 2020 16:12:30 -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=LCYHa3s5; 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 S1727037AbgKTAK6 (ORCPT + 15 others); Thu, 19 Nov 2020 19:10:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726848AbgKTAK6 (ORCPT ); Thu, 19 Nov 2020 19:10:58 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFA3C061A04 for ; Thu, 19 Nov 2020 16:10:57 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id bo9so4702823ejb.13 for ; Thu, 19 Nov 2020 16:10:57 -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=OVDKAEgKc07fjPVimTGuRqUwL4ug5893Az6X6hTx6dU=; b=LCYHa3s5hi3LRcErlQShjRYaJz+doMQoLZo/p/mxG/uDc0nBMaivzrdthh743YA/YK wYnJPhUcDX9UNY9tzp8cn9hTgZfQ5Ad973uZFITSvh+XnSLSfNJ4jAcufJZjZmyQfmjt TNgbfpZUozKA8LIpL1fq2IT4cJJaq9B2HNkM1r1oR4fgvLwc3J2VPPa/7iOiFu4Zt4YS +tg95Hs3fgn9LBMCcYpf/70Bi6QediQPEttewpM+3nuguBtAzP6fdgExsNjAdT2c6VSg M8ExixvZdbs9mZWqMhkxWjyJNsiHKZeQxH/r5M3M7L8AXERUUi3inJYJRxog6id9uvLJ OkHA== 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=OVDKAEgKc07fjPVimTGuRqUwL4ug5893Az6X6hTx6dU=; b=bZdkjW/AhGaB9HCP29yU26oQ/k41ApPSlgymMhgE/6Hioy9y9yp/qPMEnSIXpfvScs eWuluI8Op8Lcvrhgcc6e8UMSWr2WD8e81JWqzPabiNU9hf5It1NnVQItWu1HDlSUTF3d DsFY3ydHwc5H4J4OSIfeO+7+XgXQGb4j4IxQc9LSCnujshU9bUn1w4BLBjfy9SS49L3v i0mMkus1QSKchs10UiH6XGTwtWr/sSFD8PnKPO1LnQ01mEX9px+elnmYYkE+3zASwsqW 2j+LH9Q3bApXOZrbruLWfmUTZE8cQcTnwXXB0SLQQI4hPXMXTFDzUdLoPmfrzna5Tjgv GqIw== X-Gm-Message-State: AOAM531vC0e25xPD+S7AY3E/q5Nor5pU1dz2MKUdS1a9DWRmSs2zl929 ngDSdFpMIom4swZtAaNCFht2Dw== X-Received: by 2002:a17:906:13d2:: with SMTP id g18mr12142510ejc.76.1605831056278; Thu, 19 Nov 2020 16:10:56 -0800 (PST) Received: from localhost.localdomain (hst-221-4.medicom.bg. [84.238.221.4]) by smtp.gmail.com with ESMTPSA id k23sm383556edv.97.2020.11.19.16.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 16:10:55 -0800 (PST) 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 , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 3/3] media: hfi_venus: Request interrupt for sync cmds Date: Fri, 20 Nov 2020 02:10:37 +0200 Message-Id: <20201120001037.10032-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201120001037.10032-1-stanimir.varbanov@linaro.org> References: <20201120001037.10032-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vikash Garodia For synchronous commands, update the message queue variable. This would inform video firmware to raise interrupt on host CPU whenever there is a response for such commands. Signed-off-by: Vikash Garodia Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 4be4a75ddcb6..b8fdb464ba9c 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -372,7 +372,7 @@ static void venus_soft_int(struct venus_hfi_device *hdev) } static int venus_iface_cmdq_write_nolock(struct venus_hfi_device *hdev, - void *pkt) + void *pkt, bool sync) { struct device *dev = hdev->core->dev; struct hfi_pkt_hdr *cmd_packet; @@ -397,15 +397,23 @@ static int venus_iface_cmdq_write_nolock(struct venus_hfi_device *hdev, if (rx_req) venus_soft_int(hdev); + /* Inform video firmware to raise interrupt for synchronous commands */ + queue = &hdev->queues[IFACEQ_MSG_IDX]; + if (sync) { + queue->qhdr->rx_req = 1; + /* ensure rx_req is updated in memory */ + wmb(); + } + return 0; } -static int venus_iface_cmdq_write(struct venus_hfi_device *hdev, void *pkt) +static int venus_iface_cmdq_write(struct venus_hfi_device *hdev, void *pkt, bool sync) { int ret; mutex_lock(&hdev->lock); - ret = venus_iface_cmdq_write_nolock(hdev, pkt); + ret = venus_iface_cmdq_write_nolock(hdev, pkt, sync); mutex_unlock(&hdev->lock); return ret; @@ -428,7 +436,7 @@ static int venus_hfi_core_set_resource(struct venus_core *core, u32 id, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -778,7 +786,7 @@ static int venus_sys_set_debug(struct venus_hfi_device *hdev, u32 debug) pkt_sys_debug_config(pkt, HFI_DEBUG_MODE_QUEUE, debug); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -795,7 +803,7 @@ static int venus_sys_set_coverage(struct venus_hfi_device *hdev, u32 mode) pkt_sys_coverage_config(pkt, mode); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -816,7 +824,7 @@ static int venus_sys_set_idle_message(struct venus_hfi_device *hdev, pkt_sys_idle_indicator(pkt, enable); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -834,7 +842,7 @@ static int venus_sys_set_power_control(struct venus_hfi_device *hdev, pkt_sys_power_control(pkt, enable); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -885,14 +893,14 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev) return ret; } -static int venus_session_cmd(struct venus_inst *inst, u32 pkt_type) +static int venus_session_cmd(struct venus_inst *inst, u32 pkt_type, bool sync) { struct venus_hfi_device *hdev = to_hfi_priv(inst->core); struct hfi_session_pkt pkt; pkt_session_cmd(&pkt, pkt_type, inst); - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, sync); } static void venus_flush_debug_queue(struct venus_hfi_device *hdev) @@ -922,7 +930,7 @@ static int venus_prepare_power_collapse(struct venus_hfi_device *hdev, pkt_sys_pc_prep(&pkt); - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); if (ret) return ret; @@ -1064,13 +1072,13 @@ static int venus_core_init(struct venus_core *core) venus_set_state(hdev, VENUS_STATE_INIT); - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); if (ret) return ret; pkt_sys_image_version(&version_pkt); - ret = venus_iface_cmdq_write(hdev, &version_pkt); + ret = venus_iface_cmdq_write(hdev, &version_pkt, false); if (ret) dev_warn(dev, "failed to send image version pkt to fw\n"); @@ -1099,7 +1107,7 @@ static int venus_core_ping(struct venus_core *core, u32 cookie) pkt_sys_ping(&pkt, cookie); - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_core_trigger_ssr(struct venus_core *core, u32 trigger_type) @@ -1112,7 +1120,7 @@ static int venus_core_trigger_ssr(struct venus_core *core, u32 trigger_type) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_session_init(struct venus_inst *inst, u32 session_type, @@ -1130,7 +1138,7 @@ static int venus_session_init(struct venus_inst *inst, u32 session_type, if (ret) goto err; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, true); if (ret) goto err; @@ -1151,7 +1159,7 @@ static int venus_session_end(struct venus_inst *inst) dev_warn(dev, "fw coverage msg ON failed\n"); } - return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_END); + return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_END, true); } static int venus_session_abort(struct venus_inst *inst) @@ -1160,7 +1168,7 @@ static int venus_session_abort(struct venus_inst *inst) venus_flush_debug_queue(hdev); - return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_ABORT); + return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_ABORT, true); } static int venus_session_flush(struct venus_inst *inst, u32 flush_mode) @@ -1173,22 +1181,22 @@ static int venus_session_flush(struct venus_inst *inst, u32 flush_mode) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, true); } static int venus_session_start(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_START); + return venus_session_cmd(inst, HFI_CMD_SESSION_START, true); } static int venus_session_stop(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_STOP); + return venus_session_cmd(inst, HFI_CMD_SESSION_STOP, true); } static int venus_session_continue(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_CONTINUE); + return venus_session_cmd(inst, HFI_CMD_SESSION_CONTINUE, false); } static int venus_session_etb(struct venus_inst *inst, @@ -1205,7 +1213,7 @@ static int venus_session_etb(struct venus_inst *inst, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); } else if (session_type == VIDC_SESSION_TYPE_ENC) { struct hfi_session_empty_buffer_uncompressed_plane0_pkt pkt; @@ -1213,7 +1221,7 @@ static int venus_session_etb(struct venus_inst *inst, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); } else { ret = -EINVAL; } @@ -1232,7 +1240,7 @@ static int venus_session_ftb(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_session_set_buffers(struct venus_inst *inst, @@ -1252,7 +1260,7 @@ static int venus_session_set_buffers(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_unset_buffers(struct venus_inst *inst, @@ -1272,17 +1280,17 @@ static int venus_session_unset_buffers(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, true); } static int venus_session_load_res(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_LOAD_RESOURCES); + return venus_session_cmd(inst, HFI_CMD_SESSION_LOAD_RESOURCES, true); } static int venus_session_release_res(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_RELEASE_RESOURCES); + return venus_session_cmd(inst, HFI_CMD_SESSION_RELEASE_RESOURCES, true); } static int venus_session_parse_seq_hdr(struct venus_inst *inst, u32 seq_hdr, @@ -1299,7 +1307,7 @@ static int venus_session_parse_seq_hdr(struct venus_inst *inst, u32 seq_hdr, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -1320,7 +1328,7 @@ static int venus_session_get_seq_hdr(struct venus_inst *inst, u32 seq_hdr, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_set_property(struct venus_inst *inst, u32 ptype, @@ -1339,7 +1347,7 @@ static int venus_session_set_property(struct venus_inst *inst, u32 ptype, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_get_property(struct venus_inst *inst, u32 ptype) @@ -1352,7 +1360,7 @@ static int venus_session_get_property(struct venus_inst *inst, u32 ptype) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, true); } static int venus_resume(struct venus_core *core)