From patchwork Tue May 15 07:58:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 135852 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp679876lji; Tue, 15 May 2018 01:11:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrhUbeSXk5h7R/ZGfJhSEVM+mWm1lCr+N3KoobMAowwIXWvdERBELUL9XGTQ8GTdDX/DksP X-Received: by 2002:a63:7d43:: with SMTP id m3-v6mr11497204pgn.117.1526371885565; Tue, 15 May 2018 01:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371885; cv=none; d=google.com; s=arc-20160816; b=iszXYLcDkaA1G9pNcxf8jQwxaKwfRBnlmYUNtr+BG7Pr8UNuhRVbBphdgCC/Ha/plp MYoUSanl07RMKL6Ti+nmNqTVcwznLohLcVmuKwHAcpfqWCwuQJYhA4iQU8olY93RrniW EgfJ0yVTD/mI66hQwY6CsZn4nFGMagcanmwuzuU7Z12sgBuwXyAUwuZB6NuEJ4AN0OvH iO8CsL/Cv0Z49xBX7S5cI8ADHOrBEXhbkBiPl/sHr2xjeIkxcj+l4ise3EpYSrUZywcM XeJsDw28I7Ef7nwqVJZkgv35+3wKQG+aJppa3UWKyeJ5oTQfUj4HB9a/ldWkfaIJ33Yu vr0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gpTu20L5z9V5o5cgXCp1We4KI3PsueUS0aOAcP1gpPc=; b=S8ZsqsSxkBfJRcbQRkDGi5PJ2Q3Uc2JGLGXXFPF8I724q1BcBa03jYQOg7N154Ek60 hSESNsi4OPG+FCooqi80Q8Rfs390RPEQrrUPIdDeFqOoMLsy16xPzgiaDpa4BWXNVGR6 EE9uQA5rfiKn1zh6JGIXOJHViyeV853eVpJQnTQWt8AWr4dOEIpnA3X6zbxxXXlJKEVn A96wLtCQy6C8TSlLDbg8ufG1GPThk0eQCl+SlCAcrZz0SYsViw33FZcf00B9U6vQ1ZnG G3R2NgOv5eoFaK4Ap1y7xEVpN4O33LS7vdip88eZvMVDHBwjUp35omNm1k+o+WnoVu5/ 96+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=imBVsFIB; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si11000402pfn.256.2018.05.15.01.11.25; Tue, 15 May 2018 01:11:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=imBVsFIB; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 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 S1752769AbeEOILY (ORCPT + 4 others); Tue, 15 May 2018 04:11:24 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35036 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752509AbeEOH7h (ORCPT ); Tue, 15 May 2018 03:59:37 -0400 Received: by mail-wm0-f68.google.com with SMTP id o78-v6so19723394wmg.0 for ; Tue, 15 May 2018 00:59:36 -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=gpTu20L5z9V5o5cgXCp1We4KI3PsueUS0aOAcP1gpPc=; b=imBVsFIB98fWCPs2KaUWW/VrTh6HJEOT2i7G/s7/RMbB7yXButXvKJlC6Y1WrU673J JBg0XN7B87SH9yqPnZVkZD11qJbeOlBXSEs2W3QV9Y4MCMcv1Hmlx8cq4SNGjcVsrodd ydJxYj9SbBIo0kNGkJzHmvyVBL3pfOLQGlGJo= 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=gpTu20L5z9V5o5cgXCp1We4KI3PsueUS0aOAcP1gpPc=; b=OK/DTGRlR/WHRc/KdzKWY6mG/IfFBvMVZAVpg+ewqvt9I+Y2W8CBPys2sorJov74Ol VxGTGOeG1BzCi0iypEUN9OwJtt1TLTIaiOFHXb9FoQvE+Mo0TKKF37pyEVrQMU87uZJf IN92ySd5m3DDyrn7l17aMZ74Mq5Lw523APtilUGyLohq8TXq/ywRCHt7UDzJZhqkSbRs svvW0KLNORbWHAoMvBERcGYo8bHNPF3bMr7o0LgyoYpQHCwg2R6leGfbtDqAF+P3YVH9 1o7qbHPiVgrNfJlEdUxcvWiNH3e0mLjON6rFSZXflhFxZEB4std+WWagF+TVL8QCQvuH Bz5w== X-Gm-Message-State: ALKqPwdhxzy0No1A9czcEcQP9q9/UulSSJffKfatfY7y7v2NUiGUrJ8R RDIdBZmRDu/H3Z8tzZH2yPgetQ== X-Received: by 2002:a1c:6787:: with SMTP id b129-v6mr7501736wmc.117.1526371175806; Tue, 15 May 2018 00:59:35 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 4-v6sm10918510wmg.40.2018.05.15.00.59.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 00:59:35 -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 v2 08/29] venus: hfi_venus: fix suspend function for venus 3xx versions Date: Tue, 15 May 2018 10:58:38 +0300 Message-Id: <20180515075859.17217-9-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180515075859.17217-1-stanimir.varbanov@linaro.org> References: <20180515075859.17217-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This fixes the suspend function for Venus 3xx versions by add a check for WFI (wait for interrupt) bit. This bit is on when the ARM9 is idle and entered in low power mode. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 59 ++++++++++++++++-------- drivers/media/platform/qcom/venus/hfi_venus_io.h | 1 + 2 files changed, 41 insertions(+), 19 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 53546174aab8..aac351f699a0 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1447,7 +1447,7 @@ static int venus_suspend_3xx(struct venus_core *core) { struct venus_hfi_device *hdev = to_hfi_priv(core); struct device *dev = core->dev; - u32 ctrl_status, wfi_status; + u32 ctrl_status, cpu_status; int ret; int cnt = 100; @@ -1463,29 +1463,50 @@ static int venus_suspend_3xx(struct venus_core *core) return -EINVAL; } - ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - if (!(ctrl_status & CPU_CS_SCIACMDARG0_PC_READY)) { - wfi_status = venus_readl(hdev, WRAPPER_CPU_STATUS); + /* + * Power collapse sequence for Venus 3xx and 4xx versions: + * 1. Check for ARM9 and video core to be idle by checking WFI bit + * (bit 0) in CPU status register and by checking Idle (bit 30) in + * Control status register for video core. + * 2. Send a command to prepare for power collapse. + * 3. Check for WFI and PC_READY bits. + */ + + while (--cnt) { + cpu_status = venus_readl(hdev, WRAPPER_CPU_STATUS); ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - ret = venus_prepare_power_collapse(hdev, false); - if (ret) { - dev_err(dev, "prepare for power collapse fail (%d)\n", - ret); - return ret; - } + if (cpu_status & WRAPPER_CPU_STATUS_WFI && + ctrl_status & CPU_CS_SCIACMDARG0_INIT_IDLE_MSG_MASK) + break; - cnt = 100; - while (cnt--) { - wfi_status = venus_readl(hdev, WRAPPER_CPU_STATUS); - ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - if (ctrl_status & CPU_CS_SCIACMDARG0_PC_READY && - wfi_status & BIT(0)) - break; - usleep_range(1000, 1500); - } + usleep_range(1000, 1500); } + if (!cnt) + return -ETIMEDOUT; + + ret = venus_prepare_power_collapse(hdev, false); + if (ret) { + dev_err(dev, "prepare for power collapse fail (%d)\n", ret); + return ret; + } + + cnt = 100; + while (--cnt) { + cpu_status = venus_readl(hdev, WRAPPER_CPU_STATUS); + ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); + + if (cpu_status & WRAPPER_CPU_STATUS_WFI && + ctrl_status & CPU_CS_SCIACMDARG0_PC_READY) + break; + + usleep_range(1000, 1500); + } + + if (!cnt) + return -ETIMEDOUT; + mutex_lock(&hdev->lock); ret = venus_power_off(hdev); diff --git a/drivers/media/platform/qcom/venus/hfi_venus_io.h b/drivers/media/platform/qcom/venus/hfi_venus_io.h index 76f47936d0fa..12e3d33a3d82 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus_io.h +++ b/drivers/media/platform/qcom/venus/hfi_venus_io.h @@ -108,6 +108,7 @@ #define WRAPPER_CPU_CGC_DIS (WRAPPER_BASE + 0x2010) #define WRAPPER_CPU_STATUS (WRAPPER_BASE + 0x2014) +#define WRAPPER_CPU_STATUS_WFI BIT(0) #define WRAPPER_SW_RESET (WRAPPER_BASE + 0x3000) /* Venus 4xx */