From patchwork Tue Apr 24 12:44:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 10359619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0333601BE for ; Tue, 24 Apr 2018 12:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2B4128DB4 for ; Tue, 24 Apr 2018 12:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9752B28DB2; Tue, 24 Apr 2018 12:55:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2526F28DB2 for ; Tue, 24 Apr 2018 12:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757823AbeDXMyk (ORCPT ); Tue, 24 Apr 2018 08:54:40 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44199 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757822AbeDXMpR (ORCPT ); Tue, 24 Apr 2018 08:45:17 -0400 Received: by mail-wr0-f196.google.com with SMTP id o15-v6so49795462wro.11 for ; Tue, 24 Apr 2018 05:45:16 -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=tXBb5tYdSbXkg5a6q0eFfK/urVaFEKtwD4nw6O+n0Dw=; b=F4CgnLgm0e0sJKuvkyC6UCBNumBvHO4YzWHD/JmYD8jFYBP7sT+XIDaNrW/rrac1o8 xkPmf05pSBNUd6plY2/G6+W54i9tcjx4uE5ulVfaC8mb9GnHR1BOiX4whxv4xUwMLZzU ISmPq0lt1cmgHSCxVpsjzGE7jxzJ5dz6UGXoU= 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=tXBb5tYdSbXkg5a6q0eFfK/urVaFEKtwD4nw6O+n0Dw=; b=CLnoXkHaKJBZx1iggqXo9GjEEfZPe1hspFD/VTB/bCNDOvaqUOro/AeHPwdfFVYRmc 8/k4EC7VMHKdwoBIU+T4SJGvXnkZAqv1cLtP1nS6FiKK3njPd7OGX3ZyGoOoSbbsYUO6 zHrJ2AQX1HQeATCa4WrzpKpJAoIw1VlGzToNPhKed2eNX59WGsbLHoBeQFbP/ab5X7/C +N5zD05eTqzBn/NszaAz4dntJCp/NkYqzQjOMPOCBc6D8XZy2CM5c5o8t/Cu+To1OlQt N5SwavVGACebTwSTY8jwx/p1DhYKZ8hdjmbYxvfK9EtjNy9O0XhkNUbSgn7MRGXtCaIM O36w== X-Gm-Message-State: ALQs6tCj0xHJErDOaX2j5FihawsunDWliH5LLhxWDq/cMXXTiVivWszv E5311G/MRAXl+MYxr4xUCbZwrQ== X-Google-Smtp-Source: AIpwx4+tHylpHaYnKLJ8FGubJ5M7axtOA45B62+JpyD2m9EsiCbur4fV8si6a05pMEwl4Eki49+DOQ== X-Received: by 2002:adf:82ce:: with SMTP id 72-v6mr20436848wrc.60.1524573915722; Tue, 24 Apr 2018 05:45:15 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:15 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Stanimir Varbanov Subject: [PATCH 08/28] venus: hfi_venus: add suspend function for 4xx version Date: Tue, 24 Apr 2018 15:44:16 +0300 Message-Id: <20180424124436.26955-9-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds suspend (power collapse) function with slightly different order of calls comparing with Venus 3xx. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 53546174aab8..f61d34bf61b4 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1443,6 +1443,55 @@ static int venus_suspend_1xx(struct venus_core *core) return 0; } +static int venus_suspend_4xx(struct venus_core *core) +{ + struct venus_hfi_device *hdev = to_hfi_priv(core); + struct device *dev = core->dev; + u32 val; + int ret; + + if (!hdev->power_enabled || hdev->suspended) + return 0; + + mutex_lock(&hdev->lock); + ret = venus_is_valid_state(hdev); + mutex_unlock(&hdev->lock); + + if (!ret) { + dev_err(dev, "bad state, cannot suspend\n"); + return -EINVAL; + } + + ret = venus_prepare_power_collapse(hdev, false); + if (ret) { + dev_err(dev, "prepare for power collapse fail (%d)\n", ret); + return ret; + } + + ret = readl_poll_timeout(core->base + CPU_CS_SCIACMDARG0, val, + val & CPU_CS_SCIACMDARG0_PC_READY, + POLL_INTERVAL_US, 100000); + if (ret) { + dev_err(dev, "Polling power collapse ready timed out\n"); + return ret; + } + + mutex_lock(&hdev->lock); + + ret = venus_power_off(hdev); + if (ret) { + dev_err(dev, "venus_power_off (%d)\n", ret); + mutex_unlock(&hdev->lock); + return ret; + } + + hdev->suspended = true; + + mutex_unlock(&hdev->lock); + + return 0; +} + static int venus_suspend_3xx(struct venus_core *core) { struct venus_hfi_device *hdev = to_hfi_priv(core); @@ -1507,6 +1556,9 @@ static int venus_suspend(struct venus_core *core) if (core->res->hfi_version == HFI_VERSION_3XX) return venus_suspend_3xx(core); + if (core->res->hfi_version == HFI_VERSION_4XX) + return venus_suspend_4xx(core); + return venus_suspend_1xx(core); }