Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp271876imm; Tue, 15 May 2018 01:13:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo+J7WuYzdtLuRH78NQUeUAgipCIBQCyzdZiLolSU7bsaJbOzLhaUahoe//Uzb5BRy6fbHd X-Received: by 2002:a62:d044:: with SMTP id p65-v6mr14213282pfg.64.1526372017161; Tue, 15 May 2018 01:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526372017; cv=none; d=google.com; s=arc-20160816; b=Vs29zBDylBO1l4IwlWXmEcqSI1nzngbRJf5hgdOfKD3xK8Aazl9j3DeqTrRcz9ISfO Ad4xF+NSmAWZpMCp7WkyIMe5vbWtq4OBG6uRz7cQa5OCDe9alRFcyYa+SPL1laNwHoMd U4b6tjqTHtFwZV+n805kwzqeuvS6ZPN5Dl+VueSp0HAwKsGo+xZawXOtrScS4+oJhUdA BMafTTfUoQwSa6e3Zq3v/qhvr08tBl7BQhL+YADg+cLLeAC31F411PqInGMs210Rq4Td odjpLFnwwwrW5YBvtxRwcKkMClf/fWNT57kyyTOXA/6wBtEjloXPcxNCfWg05Jn4l/Lu jgsg== 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=d9Q+MSfFos/o+3ItFVnqik+9chEpkiTtlIET8Lc1zhdwi+EmiIxryH4QwzhR5p3YRy /4o2SRX+03HT/ctHoJrCvuJPoACOZlcQbsiznHTbL16t6BIlIG+wqci+U/TLtBIW3Rrt arjnKG9CnU/c/rxYx+EzHFYUPCoZUSpkhD1JmMT2skmzesvI/08sLM0F8Pe4xgPTyzJT h3Ow2eY3p1masTjQd5Io9T5ZcrowAFIyCY9eOgfxlHy5EThLtj+NuJ4JaCcN1FamdfSe 8QrqBb9l4SAfTgIOrWL3LzhP/Iru2RGei0YzdHW3LfQWaGJCOSIaWFCWbCceKtzUtx0C mEGQ== 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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 69-v6si11459297pla.548.2018.05.15.01.13.23; Tue, 15 May 2018 01:13:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1752749AbeEOILX (ORCPT + 99 others); Tue, 15 May 2018 04:11:23 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36849 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510AbeEOH7h (ORCPT ); Tue, 15 May 2018 03:59:37 -0400 Received: by mail-wm0-f66.google.com with SMTP id n10-v6so19606713wmc.1 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=bb02mS+ieX/RyryKMO+h+TEr4NAAW4pWUwZWzb2jMtZfTkEGkSN/CSVPQr7+Zyq5O2 ey20zR0aXhF0pEb+pLbc+WJHe3ytFKowvEkldkExXnhpY7V2TAI6gdbVyXMuFrpgPn/t zCNUMzJbrzxYQ/KRRahRqovljzYvFn2k9HJ8Tr+QydhWyrUMSbN255uHXsuPjpe9W1JU a8Lfzz9KE6VVXdyRNd5Cj8xfc1FUpPWeoIDGnKLNDRHjZi085Dg+CQcApQmeePEgxWID bqD17B7LOMr1r/saD4wbA8n7JROyY7Yqta0woH4HvLtWdDUeCuISeFxrM1k+7HXZtQJi JYXg== X-Gm-Message-State: ALKqPwddXyvtU0+E4aJy6GlAndEfK54W2ZcN8OIVzdJNP9iA0P8qEdqM Jyoy3oLHhS3s8I+ZFowZ0+qZ2g== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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 */ -- 2.14.1