From patchwork Thu Jul 30 11:46:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11692823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A78C13B6 for ; Thu, 30 Jul 2020 11:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01B1F208A9 for ; Thu, 30 Jul 2020 11:47:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uaEmjOC2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgG3Lre (ORCPT ); Thu, 30 Jul 2020 07:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727910AbgG3LrS (ORCPT ); Thu, 30 Jul 2020 07:47:18 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70212C0619D5 for ; Thu, 30 Jul 2020 04:47:18 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id r2so19515811wrs.8 for ; Thu, 30 Jul 2020 04:47:18 -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; bh=CTatHtGbJyhfIe07LyOFqsBAVFHXpCGvt0MRleoAwFM=; b=uaEmjOC2l9sHxKq7NHLH6ZQ/+FQ9P8LnKs3PJp993cAdhk0pREg2Wiryu6EtJVV4/t 9PSq1/5a8rp94P/DPRkFKBMb44gE/F5+TSyztqX0OSRMKgsNABOl8UacD1ia2FwnxeLI YnpfZ9Wprk8Sq/Q3DWDoXEd1Ba0uBG+DmAhlk/4OEygcCkGPbpuEwtXdrgKRRd1kSuSM gv9WSizuUKm8a6VOGRTObtnR6vZ142SDrrbiGt7lxr1PnoU4Mk2pOsQ+DWQeClt6T7CD WVHny8bvWrDgog3DcOj4SD4/341IqiLTqEPzTSgyEeueBPtpyyrq5iZSu7DmuO7TUz+U ahhA== 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=CTatHtGbJyhfIe07LyOFqsBAVFHXpCGvt0MRleoAwFM=; b=Arj48K7MsQHuC0QK8iWpDy9zFMjdLBQ8d7Eb4F11OFcdjW6MkqJLTvwejFeNhpkPDk NlsxshSywQBOxgLDuoyR3S6xA3VH9/1voIFJcdrJYl38Ygn35bNKonswCX3haVOTbXMQ acM24lLeWj8SsJNQo168ZkFTJxrf9DvLapZaprIbOxf7QCsOwZTmLpI82CieAhliecuK ijcKMzNE8vBxiZVMeXSCjaTZ7Ks9HK1MdQ1DhM0mgk47LJ05lHPX6Bb1UYV/n+SBqOfx WLyl478hu/RgTVP9pFrnXouizQujzL0v+Tt4phDiomGXnSUgN0NyM/AROdm3sD+JmPjR EW7Q== X-Gm-Message-State: AOAM5302OYlx6R0UJkRPalXMIgaFv4ucFqPoYmlzf9qMK9SxcuGoTRQA meV2idyAEHzC+/hH5ayF5c713w== X-Google-Smtp-Source: ABdhPJxSRZkvCIm8Zm439FWlOxBqCLeYktGV8+YQ++3WfHvvEz+Xf5CpMovL50+ZyWyEAs/WLFhMuw== X-Received: by 2002:adf:a192:: with SMTP id u18mr2704077wru.158.1596109637205; Thu, 30 Jul 2020 04:47:17 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id 32sm9636691wrn.86.2020.07.30.04.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 04:47:16 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stanimir Varbanov Subject: [PATCH 1/3] venus: parser: Prepare parser for multiple invocations Date: Thu, 30 Jul 2020 14:46:30 +0300 Message-Id: <20200730114632.6717-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730114632.6717-1-stanimir.varbanov@linaro.org> References: <20200730114632.6717-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Presently the hfi_parser has been called only once during driver probe. To prepare the parser function to be called multiple times from recovery we need to initialize few variables which are used during parsing time. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c index 7f515a4b9bd1..363ee2a65453 100644 --- a/drivers/media/platform/qcom/venus/hfi_parser.c +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -239,6 +239,9 @@ u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf, parser_init(inst, &codecs, &domain); + core->codecs_count = 0; + memset(core->caps, 0, sizeof(core->caps)); + while (words_count) { data = word + 1; From patchwork Thu Jul 30 11:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11692815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FB7413B6 for ; Thu, 30 Jul 2020 11:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 768B121744 for ; Thu, 30 Jul 2020 11:47:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jBo2saLD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727961AbgG3LrX (ORCPT ); Thu, 30 Jul 2020 07:47:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbgG3LrX (ORCPT ); Thu, 30 Jul 2020 07:47:23 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF2B7C061794 for ; Thu, 30 Jul 2020 04:47:21 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id g8so5438521wmk.3 for ; Thu, 30 Jul 2020 04:47:21 -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; bh=LWt2SD9BmU5MUG0bfq/HT/GSXil7yqUtBapdyAmDpx0=; b=jBo2saLDBGJvI+FbAVmxTQ+JCljGmhEYfNgRnHKXdJBPSecTUcAuY9msJm2ywtehtb nkdQboZilXVJ4otJI5uKQa1pW7H5YHoaZOArobwcODMa5sSDKkugrbZLg6CmCdVROBgt UfjLzh46Ppkm/6BlneR7KNbDuvLPSQuPfGW67cBlz1/742k28f+0UO37SRyDIYDBEpfL NRukNVkrDj31x7ABt2WEBxz7tK06VBPmyazflTiiSPDV/r0E3x4gcwFj/4vbTSKG7OYS xhKaSQKfwKeqD1QOc8Rc1l3f+dvKwtnQ3orlYje6puTR1/FJmU0rbXEsvaGqwBG4HeeI 3yDg== 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=LWt2SD9BmU5MUG0bfq/HT/GSXil7yqUtBapdyAmDpx0=; b=ePG2FUjMY3asKlHTXvdM+ikG2Ld6FVmNVvGVMbb6X+33Zt8ZabEcdhTZOoU0REQXPJ pSAsOe6+yvBFdtUTBXj1y4kIZ4+Ph+NmcKYu5S8V549xLeoaWQy5C4h9J3YNw4RYpdOO FWQ4FCGph0ztEtrzF9/G+JjUgZPzpY2B0aFeX9uyICYD28ReaToBOo8wPL5o0psDaqfC qOszTj54TKIVKck1CYxbGKj6J2u3gLOZPUBZPPFHJlcO544VKu90XrdjglZSIHWtktjW O0eyBHm1FiwpGVljjCGzVyDqitPpXDEh+VJQp+sE5S8DqIYjapoaJ8mhJDBdVl3+tp83 yvbg== X-Gm-Message-State: AOAM533QjWa7wHRqWLmTccTnKzOZ43804uSwXopiORKCwRMK/brYir+U UVJdOcsc91lLBudD+Uv+Zn022w6OHK1+yg== X-Google-Smtp-Source: ABdhPJy39PpVFdhGdsMZUAjDwr9YE8Cu0METZPN3g0qDfmM2uQfhs+fzdOOOZgq4ZSK0k8el4r84ng== X-Received: by 2002:a7b:c0c8:: with SMTP id s8mr13525676wmh.4.1596109640545; Thu, 30 Jul 2020 04:47:20 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id 32sm9636691wrn.86.2020.07.30.04.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 04:47:20 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stanimir Varbanov Subject: [PATCH 2/3] venus: Rework recovery mechanism Date: Thu, 30 Jul 2020 14:46:31 +0300 Message-Id: <20200730114632.6717-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730114632.6717-1-stanimir.varbanov@linaro.org> References: <20200730114632.6717-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org After power domains and clock restructuring the recovery for sdm845 and v4 did not work properly. Fix that by reworking the recovery function and the sequence. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/core.c | 24 ++++++++++--------- drivers/media/platform/qcom/venus/hfi_venus.c | 11 --------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 203c6538044f..46f6e34d435a 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -40,13 +41,7 @@ static void venus_event_notify(struct venus_core *core, u32 event) mutex_unlock(&core->lock); disable_irq_nosync(core->irq); - - /* - * Delay recovery to ensure venus has completed any pending cache - * operations. Without this sleep, we see device reset when firmware is - * unloaded after a system error. - */ - schedule_delayed_work(&core->work, msecs_to_jiffies(100)); + schedule_delayed_work(&core->work, msecs_to_jiffies(10)); } static const struct hfi_core_ops venus_core_ops = { @@ -59,23 +54,30 @@ static void venus_sys_error_handler(struct work_struct *work) container_of(work, struct venus_core, work.work); int ret = 0; - dev_warn(core->dev, "system error has occurred, starting recovery!\n"); - pm_runtime_get_sync(core->dev); hfi_core_deinit(core, true); - hfi_destroy(core); + + dev_warn(core->dev, "system error has occurred, starting recovery!\n"); + mutex_lock(&core->lock); + + while (pm_runtime_active(core->dev_dec) || pm_runtime_active(core->dev_enc)) + msleep(10); + venus_shutdown(core); pm_runtime_put_sync(core->dev); + while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0])) + usleep_range(1000, 1500); + + hfi_destroy(core); ret |= hfi_create(core, &venus_core_ops); pm_runtime_get_sync(core->dev); ret |= venus_boot(core); - ret |= hfi_core_resume(core, true); enable_irq(core->irq); diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 0d8855014ab3..3392fd177d22 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -986,13 +986,6 @@ static void venus_process_msg_sys_error(struct venus_hfi_device *hdev, venus_set_state(hdev, VENUS_STATE_DEINIT); - /* - * Once SYS_ERROR received from HW, it is safe to halt the AXI. - * With SYS_ERROR, Venus FW may have crashed and HW might be - * active and causing unnecessary transactions. Hence it is - * safe to stop all AXI transactions from venus subsystem. - */ - venus_halt_axi(hdev); venus_sfr_print(hdev); } @@ -1009,10 +1002,6 @@ static irqreturn_t venus_isr_thread(struct venus_core *core) res = hdev->core->res; pkt = hdev->pkt_buf; - if (hdev->irq_status & WRAPPER_INTR_STATUS_A2HWD_MASK) { - venus_sfr_print(hdev); - hfi_process_watchdog_timeout(core); - } while (!venus_iface_msgq_read(hdev, pkt)) { msg_ret = hfi_process_msg_packet(core, pkt); From patchwork Thu Jul 30 11:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11692817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1435D722 for ; Thu, 30 Jul 2020 11:47:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F12C121D95 for ; Thu, 30 Jul 2020 11:47:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jzg2hwb9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbgG3Lr0 (ORCPT ); Thu, 30 Jul 2020 07:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbgG3LrZ (ORCPT ); Thu, 30 Jul 2020 07:47:25 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E25C0619D2 for ; Thu, 30 Jul 2020 04:47:25 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id q76so4711970wme.4 for ; Thu, 30 Jul 2020 04:47:24 -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; bh=YqqkwlyeTqm8wK7NZ5whyaJb7lnPkkqR0DOowlryp8Y=; b=jzg2hwb9COuCcPenG5X/xHPyQOHLNtf2QtJlU5FLwtZ+lLCbvchX7MVPqmY9XTj1DR tRl3OzzMxFCFPudy4ugU7ga6eYI342MheKypEiZkx/8CSk0c/Tngm8E9MbE0dCThXxD4 FjQqLDapoxF6GgrBJijQ0//pN/MygWlG1bwdZdl9mV6LIsCwo/0d6NrLjPw1x4GnPInl gxvpccHvhUKBcOTZo5VkRx+FBgtM1IdpJ3F2CYv+S7eWTiGbJVDzsGNTVllBinqruSVh oVxOqvPFUcEQ8mDpT9DxVg38lK1sHBL/8p++zg00HL/+Quj3n7j6qNU5Cyqj0Lakd2dI 8m+w== 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=YqqkwlyeTqm8wK7NZ5whyaJb7lnPkkqR0DOowlryp8Y=; b=llxOZbyboXfx4hy579CXXTZ65/DtXsTikSqAtyk8YgdkR9hcnrS2d3CoOAG46ZI9CW GY/GGQwRpWFa22RgOxDrnPbRvul0Hr1Vij8uRZByRVDc8b5WU5JI4kJMMe0aXLO9851V DZtJsMaRBU76ctiAhwYq7Az+nY/m7Q86zcySTi1zNGi9+EEyesXX6avXWqQ1LMP8VQIe jL7E29DeB8MBhXKR2oK/wBVgAkJsLT04Fm/59RDl+LEyaFJpQaP1jO+4YAojREoXK22D m2/XRiaSIAZ8Ah4Okn7rx6bLf5obTQqqz4Zj2xTT8APT9574WHYjQPX3PPVWFney7NQa pWcw== X-Gm-Message-State: AOAM530Sj4nBbyD7i30dCtZXDWJiKBteW31beJ3vqCHVnwo03kF9lKvP IVMQX9vWM0Po0lf81mnaANqEDg== X-Google-Smtp-Source: ABdhPJy9g940Q1pXeQGLiZfG7tJ8qlcU4WWpYKS4Aod14FqDcb5Wep+xaCrl5hCoXwC4qbhs2S0BZw== X-Received: by 2002:a1c:6289:: with SMTP id w131mr4902033wmb.41.1596109643689; Thu, 30 Jul 2020 04:47:23 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id 32sm9636691wrn.86.2020.07.30.04.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 04:47:23 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stanimir Varbanov Subject: [PATCH 3/3] venus: Add new interface queues reinit Date: Thu, 30 Jul 2020 14:46:32 +0300 Message-Id: <20200730114632.6717-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730114632.6717-1-stanimir.varbanov@linaro.org> References: <20200730114632.6717-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Presently the recovery mechanism is using two hfi functions to destroy and create interface queues. For the purpose of recovery we don't need to free and allocate the memory used for interface message queues, that's why we introduce new function which just reinit the queues. Also this will give to the recovery procedure one less reason to fail (if for some reason we couldn't allocate memory). Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/core.c | 3 +- drivers/media/platform/qcom/venus/hfi.c | 5 ++ drivers/media/platform/qcom/venus/hfi.h | 1 + drivers/media/platform/qcom/venus/hfi_venus.c | 51 +++++++++++++++++++ drivers/media/platform/qcom/venus/hfi_venus.h | 1 + 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 46f6e34d435a..eda8f35425df 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -72,8 +72,7 @@ static void venus_sys_error_handler(struct work_struct *work) while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0])) usleep_range(1000, 1500); - hfi_destroy(core); - ret |= hfi_create(core, &venus_core_ops); + hfi_reinit(core); pm_runtime_get_sync(core->dev); diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index a211eb93e0f9..a59022adb14c 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -517,3 +517,8 @@ void hfi_destroy(struct venus_core *core) { venus_hfi_destroy(core); } + +void hfi_reinit(struct venus_core *core) +{ + venus_hfi_queues_reinit(core); +} diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platform/qcom/venus/hfi.h index 62c315291484..f25d412d6553 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -145,6 +145,7 @@ struct hfi_ops { int hfi_create(struct venus_core *core, const struct hfi_core_ops *ops); void hfi_destroy(struct venus_core *core); +void hfi_reinit(struct venus_core *core); int hfi_core_init(struct venus_core *core); int hfi_core_deinit(struct venus_core *core, bool blocking); diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 3392fd177d22..90067cd8c892 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1603,3 +1603,54 @@ int venus_hfi_create(struct venus_core *core) core->ops = NULL; return ret; } + +void venus_hfi_queues_reinit(struct venus_core *core) +{ + struct venus_hfi_device *hdev = to_hfi_priv(core); + struct hfi_queue_table_header *tbl_hdr; + struct iface_queue *queue; + struct hfi_sfr *sfr; + unsigned int i; + + mutex_lock(&hdev->lock); + + for (i = 0; i < IFACEQ_NUM; i++) { + queue = &hdev->queues[i]; + queue->qhdr = + IFACEQ_GET_QHDR_START_ADDR(hdev->ifaceq_table.kva, i); + + venus_set_qhdr_defaults(queue->qhdr); + + queue->qhdr->start_addr = queue->qmem.da; + + if (i == IFACEQ_CMD_IDX) + queue->qhdr->type |= HFI_HOST_TO_CTRL_CMD_Q; + else if (i == IFACEQ_MSG_IDX) + queue->qhdr->type |= HFI_CTRL_TO_HOST_MSG_Q; + else if (i == IFACEQ_DBG_IDX) + queue->qhdr->type |= HFI_CTRL_TO_HOST_DBG_Q; + } + + tbl_hdr = hdev->ifaceq_table.kva; + tbl_hdr->version = 0; + tbl_hdr->size = IFACEQ_TABLE_SIZE; + tbl_hdr->qhdr0_offset = sizeof(struct hfi_queue_table_header); + tbl_hdr->qhdr_size = sizeof(struct hfi_queue_header); + tbl_hdr->num_q = IFACEQ_NUM; + tbl_hdr->num_active_q = IFACEQ_NUM; + + /* + * Set receive request to zero on debug queue as there is no + * need of interrupt from video hardware for debug messages + */ + queue = &hdev->queues[IFACEQ_DBG_IDX]; + queue->qhdr->rx_req = 0; + + sfr = hdev->sfr.kva; + sfr->buf_size = ALIGNED_SFR_SIZE; + + /* ensure table and queue header structs are settled in memory */ + wmb(); + + mutex_unlock(&hdev->lock); +} diff --git a/drivers/media/platform/qcom/venus/hfi_venus.h b/drivers/media/platform/qcom/venus/hfi_venus.h index 57154832090e..1b656ef2bf07 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.h +++ b/drivers/media/platform/qcom/venus/hfi_venus.h @@ -10,5 +10,6 @@ struct venus_core; void venus_hfi_destroy(struct venus_core *core); int venus_hfi_create(struct venus_core *core); +void venus_hfi_queues_reinit(struct venus_core *core); #endif