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 */ From patchwork Tue May 15 07:58:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 135853 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp680260lji; Tue, 15 May 2018 01:11:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo0KUX+CkVvFCq8EG3Vc6SPDM1hD8tlynHzln0grgzuG63/JL0EGOJuiK1sl3DOEbCFiqkP X-Received: by 2002:a65:64d9:: with SMTP id t25-v6mr10884471pgv.283.1526371906077; Tue, 15 May 2018 01:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371906; cv=none; d=google.com; s=arc-20160816; b=QEPKJVyu2M2NxJp+HFUjixsdmuRfB6Y6zw9ZIHRLRiwb58zO9nbmqxjngWxfLDv2ce IKXU3mr/arkDhHoNmaNu/2nrfhYyqiCZsmcLkMkCTCET45jH2Ts37bvB2lSSX27rxZ46 7YdrjVxUILhUcFBT/CoolcEDGIIYLLvOhIFn1ZTEh2uPDf5UvuhyR/uxe7sjsGQLh2eO fB9XVSqufD1+zaxnzzQXyH05mmev2m6wdsEodmKAFyChGQEEREvEIDDEdA+dzeLp8dlo kpUS4Kn4+mEdSkmDRI+0Bdh3wbjo0+4nC6/EZa99g9xgkqjMTUu7hBvjhb9KaopoAHeB Y4Ow== 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=avz9T8GOBPABhBmSIsHgU50Z7hweQE1QXsViuQmCEHE=; b=Hr2mFcF2koj42Bvf/PRLZVE/RIOUarFgYnr1s+4s98rfRbkOj0dujQ4PCLUFYz2vS+ rX6TbD6Yt5lc1rzuju1olvaHhluT7Df0Xin3HwmOqnRE2MQi42IhhsNcuanU3Y8EEVEC 0xLjtadp5+TMwV08WEBle94OF8A827RfxRkeh6sFZ2FkjhnSh+d5Dmk2piCETFvW6QDK pmmRwBlE/zZDE4SYpbR6xAsyQ467kOsGx0s7hKVjyAvypvSaqalTsXzLARZGGArg0QtH GZgxgKSE0hNU+6giH2J9A+1RwkjQn/wCl9w8elOvpJnJDLTMlXoOjMm5I/QxvumvPZKb gFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IigHg9hz; 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 u47-v6si9397235pgn.488.2018.05.15.01.11.45; Tue, 15 May 2018 01:11:46 -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=IigHg9hz; 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 S1752621AbeEOILX (ORCPT + 4 others); Tue, 15 May 2018 04:11:23 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50653 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752512AbeEOH7h (ORCPT ); Tue, 15 May 2018 03:59:37 -0400 Received: by mail-wm0-f65.google.com with SMTP id t11-v6so17686932wmt.0 for ; Tue, 15 May 2018 00:59:37 -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=avz9T8GOBPABhBmSIsHgU50Z7hweQE1QXsViuQmCEHE=; b=IigHg9hzKXInLNSazSlvzd/bR2qGTRL8G3P3bTltflzQol4TLeVwlUK/fmStO6Kt94 9Avid3NoLBo4pcJBifXhBGYACB0RmtgmRIwzBK82zZDx+DxpXBLxmprX9bDWpcac4ScY /2yovhVUEoMUnUW7RFuYhIO9VX5Ev0vf0d1As= 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=avz9T8GOBPABhBmSIsHgU50Z7hweQE1QXsViuQmCEHE=; b=jdKbcli0edv0Rh9pHN/Q71XpxMTsUMWY3gtuQyoQDXFoawaC1Hpby4dlhaXxT356+v XTJXQL8E/EdVnAIYVmqjaJ8NyK+5qR734CjDOVxLYJ/B26A5HfiNAnPUpfyiOpK4pWU2 bUcCcR9m6xhhoQGkpZYhGURlLLr6QC/Ow3p3DpVSQyllwhfPNiul/LVFIWqYtF5mVJp4 qQOPXOe9/DltHopZ4UZjtJp+u7N7lQ9LL/ZKW7piKHeYiBzRApBtkLFidLYox5CbOgOR GCa3HRGaeRvjMhEfyFBMdD6fiawj0WJXM5bAFFOLLyK5b0FyTlQ72Teds22pGmhFcXVJ yt/w== X-Gm-Message-State: ALKqPwf2VBwDzVGbwyDOWTC7rNFwC5iHVFZ3Ldqcm1Xg8CeLx6jDLEos NEY1NXxG+VJdRXmcUWwMw2UvAw== X-Received: by 2002:a1c:424f:: with SMTP id p76-v6mr6584366wma.15.1526371176773; Tue, 15 May 2018 00:59:36 -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.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 00:59:36 -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 09/29] venus: hfi_venus: move set of default properties to core init Date: Tue, 15 May 2018 10:58:39 +0300 Message-Id: <20180515075859.17217-10-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 moves setting of default properties (firmware debug, idle indicator and low power mode) from session init to core init. All of those properties are need to be enabled/disabled early so that they could be used before the clients are even initialized. The other reason is to set idle indicator property early before we enter into venus_suspend function where we need to check for ARM9 WFI. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 aac351f699a0..284da69eb81b 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1090,6 +1090,10 @@ static int venus_core_init(struct venus_core *core) if (ret) dev_warn(dev, "failed to send image version pkt to fw\n"); + ret = venus_sys_set_default_properties(hdev); + if (ret) + return ret; + return 0; } @@ -1134,10 +1138,6 @@ static int venus_session_init(struct venus_inst *inst, u32 session_type, struct hfi_session_init_pkt pkt; int ret; - ret = venus_sys_set_default_properties(hdev); - if (ret) - return ret; - ret = pkt_session_init(&pkt, inst, session_type, codec); if (ret) goto err; From patchwork Tue May 15 07:58:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 135832 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp668226lji; Tue, 15 May 2018 00:59:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqTrsYAsOkeKkQofODmDt5tEaVK185mfkofoY4UVxekJTGtk+ZbNeg8bw1BOR1HO659xWoa X-Received: by 2002:a63:6807:: with SMTP id d7-v6mr11337204pgc.332.1526371187789; Tue, 15 May 2018 00:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371187; cv=none; d=google.com; s=arc-20160816; b=A3AGK0nN8HEIcMkRZUlP0FFYDup9Og0aSdVuZgL8Oe/KYu2cT3WlYyQRgjrjS+yVTF DRT+ydCRBzioeeF6pwJ2w2ejhaET+KHTVl35hH2GhJKVRLtjzDRTYVIzUOH7Ujs/Dh7Z hHkM7U0vczw82ClSYXHGPXncjWBoekRaX5h5YzO95NvrG9JVcuH+JmRCEIcAIvImclfd AAedC5SMmo7rni2poHTBdq4QZuhixpBYiblcz435LFsblKvLyhwxfmmHjPfCKS1T7XBt 1W2xNtuTHnmKFBfPb0fS27yGP4VffX7z/GGspVqZgw6UJKcfu+tco7dVpQe1tf2xFW1e y/1A== 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=CFcHnBnr24I9Zi3qrvCW8fiEJK7L0zJPfCU7moSvXLI=; b=IM72SAFI4YURK3+N0Eb85qIDnrg40eyXQ0tRtrh71FE+esMZsajVkoh6IxuYDpMXaw crZlGWQEfYnQTq5ekyEl9lsJTMW/zRw+bWdYMUqPnS4Vc+yWijUtmSrH0vuCZHyrY295 HpZdFgqgKlf36MXc5WwwKungNnMaLMudpvZ2IRWANAbYz8HK+K8xs3Qypb2BJ4uAzY0h N/C9aK2kYnKwzGmA5PyR7TcEXccbubWpj3LNRPSW0zpqDP0iKwbJXbOu7h7w3Dt6ToGI GEnA5PT35iEWlUeN5kZWDJRpCz/A+0Ch5yEQDv9xCz0gpqwRIatOt0gvarhDRpTGW5jn xkww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jBpVM9CT; 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 v12-v6si6045050pgs.538.2018.05.15.00.59.47; Tue, 15 May 2018 00:59:47 -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=jBpVM9CT; 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 S1752554AbeEOH7o (ORCPT + 4 others); Tue, 15 May 2018 03:59:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39651 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752485AbeEOH7i (ORCPT ); Tue, 15 May 2018 03:59:38 -0400 Received: by mail-wm0-f68.google.com with SMTP id f8-v6so19700982wmc.4 for ; Tue, 15 May 2018 00:59:38 -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=CFcHnBnr24I9Zi3qrvCW8fiEJK7L0zJPfCU7moSvXLI=; b=jBpVM9CTcotG6mpDxL7iGFOac9d40Aa9eo5eeqO4MEiT6Un+vjSIZYNu2+b0armIHA EDCTssUlnV2DgyEBW9jE25XN3yyVGuqh8CoR0T8ufCbos7GWA/dz8Wuj01bnSw+mKCih qwjt+g4AoLk/CT6cepOwh+xIV22pFtFYv/Za0= 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=CFcHnBnr24I9Zi3qrvCW8fiEJK7L0zJPfCU7moSvXLI=; b=lMYfXIYUcSqNauyLJGznupSvioPch1TlLkAlyLRG7YT4YrCCQDxLraScCOWO9WynxS 17Iz048Tm7AcVHZwtQBN6oEzDDrwTV61TX++3jsM6lyHZsdIKZ755RRr9zzwhoSTmtjl uQ+FPNMXhuu7RNqn1wvVBosGYRalOn8Ijau6LABnOQ7ORrjp1gvF/cIOQ9yJ8tXf/AD5 FXy/qmz5OSGoFdVl9SxT637BdSzHmwXSf6WOHrnwn5Itl5w7WWUKunaLKAwImV++c5cO hSdoKfFapHMHwXeBgz69YuvHnAE3fTlnsB4pGN/O/uT9Mqyxm+565GmiTuoPULp+7gYs LFmA== X-Gm-Message-State: ALKqPweb3ZB+j0S2TuXqHUdcKay0rhtuwPKHn4FY6DI9FRD4xWPz0kdZ ZDWF5xnDcSEwzcclBWvPhlqEsw== X-Received: by 2002:a1c:1c85:: with SMTP id c127-v6mr7627441wmc.69.1526371177747; Tue, 15 May 2018 00:59:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 00:59:37 -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 10/29] venus: hfi_venus: add suspend functionality for Venus 4xx Date: Tue, 15 May 2018 10:58:40 +0300 Message-Id: <20180515075859.17217-11-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 adds suspend (power collapse) functionality by reusing the suspend function for Venus 3xx and also enables idle indicator property for Venus 4xx (where it is disabled by default). Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 284da69eb81b..109116e1545d 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -878,6 +878,14 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev) if (ret) dev_warn(dev, "setting fw debug msg ON failed (%d)\n", ret); + /* + * Idle indicator is disabled by default on some 4xx firmware versions, + * enable it explicitly in order to make suspend functional by checking + * WFI (wait-for-interrupt) bit. + */ + if (IS_V4(hdev->core)) + venus_sys_idle_indicator = true; + ret = venus_sys_set_idle_message(hdev, venus_sys_idle_indicator); if (ret) dev_warn(dev, "setting idle response ON failed (%d)\n", ret); @@ -1525,7 +1533,8 @@ static int venus_suspend_3xx(struct venus_core *core) static int venus_suspend(struct venus_core *core) { - if (core->res->hfi_version == HFI_VERSION_3XX) + if (core->res->hfi_version == HFI_VERSION_3XX || + core->res->hfi_version == HFI_VERSION_4XX) return venus_suspend_3xx(core); return venus_suspend_1xx(core); From patchwork Tue May 15 07:58:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 135847 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp674779lji; Tue, 15 May 2018 01:06:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq63qnOkamJlFCWoqBRd+BkzWxDQIBSTWnWRDbVWgK9tfecFghRN/1hi9dyOLKWulIK003g X-Received: by 2002:a65:510a:: with SMTP id f10-v6mr7679964pgq.93.1526371592347; Tue, 15 May 2018 01:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371592; cv=none; d=google.com; s=arc-20160816; b=zhaXL/4Uny3aunHdy101trHtUtPOx5CzdqtKyrLCnn8N/IEZJsiH1DgG9ZXHM+nYfx zX9Nr2klIMI0NcQRKMsuUhVV0t+RdGTLMXZHoeqy/weINw66m/16t+ShhwdfpoWeDhdX YgF/CY/J6hNCT6uDld0/MGtSAWvF1uQFJ0Ty2N8vs/pCLI7JPPhwgkikG4scPaffH3u+ ir0fKfTF5P2S+8zJNatH+uUXfLUsKrOJAh5xL037acMxnV4Rf9YiEeim6Zwx6uVukhW3 1xh04oGn7XzYj6PKyIwmV2vPt5Gi1/ZGs1w1YVv7uVJmf1YyU6ZHo5u2Ky2Wt2RCw7Sl CXKw== 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=AgTV2frz+JnsXbRehwAah0N6hQFx1qc3MEVpSuKS6yo=; b=PUaRFN65YivTD5I+cipFx/m+T3KEVirkALB1ilUYXVpucFBLxjpu7CDLUNYEk+1Hx/ IfK8z8ZurX/A3j0itRKZ7DndxtqhckjDvIvavtbmBJDBOxy9fbg6fFIu5jXKbWF6/Eah 6duDhaqBUSCT/gq6xqjEUt4A9hEHcqFJNIrVcJjNumoeMFRypzly27Tu4w95ZUeKGjGZ Tne6De3WpwthTb8JADwUycRpzopHdUC8mJyc9tNwaytOqJKgfYTFiVMwAOQnVznoaguN gJY5FF3xsoOqMXvSK7vo72g0IEYdu9kSjLV+z3Y+AkaBGStgnRjYogU36w+al6q2QA+N FXow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vp7Agj9r; 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 x12-v6si8952098pgv.556.2018.05.15.01.06.32; Tue, 15 May 2018 01:06:32 -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=Vp7Agj9r; 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 S1752672AbeEOIGa (ORCPT + 4 others); Tue, 15 May 2018 04:06:30 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52891 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752406AbeEOH7n (ORCPT ); Tue, 15 May 2018 03:59:43 -0400 Received: by mail-wm0-f66.google.com with SMTP id w194-v6so17604957wmf.2 for ; Tue, 15 May 2018 00:59:42 -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=AgTV2frz+JnsXbRehwAah0N6hQFx1qc3MEVpSuKS6yo=; b=Vp7Agj9r55QTUylf22aPaVCnsOoqN7gzjBr79YPqelDDl686HMqfdRgG5JdchcAkHn euGbxAxh0z5otqbRJiHewH/9cBvqEE2tzkGXn4ewOvssO09m4gzAPQRY3Hpk7Le8R2xt WRitdZfiEChTslvcWV5dEW8hiBw6pTMis9xZM= 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=AgTV2frz+JnsXbRehwAah0N6hQFx1qc3MEVpSuKS6yo=; b=IMkL+jlOU5+d9j9nGjm23iIqBHzuccLndo9AIdWc3zGNxbPSJ+Ahw7DUmtnSyvf18V ZZLyqxo2Z506cAGRqj/zAfpjffRh4T6FYreMxKdeYJImDfoI4HLqlMnwGS3gD+ehuzKb qrXqr/zZoPqs5SNPVlvHFB/HFucBgLqscf729jOynAg21gPosaX+KfX35DmCil7Gn254 WQOQE4CY7J/eTKJXr20Lg7WP505Y31hhQAFiDjY4ZLu5zrxfZLtUIH+L/bVHq94tHNp0 gWxyK8nbV3Uu5Z4ZG6YkA+9jgU7bgjo2FfbztV1HxrcmF8h4EHPQSlVXDnpswMrgcow7 6mxQ== X-Gm-Message-State: ALKqPwfvS06sVxi/wJd/ujx6aFnSDlLIGdFavGc92ucgiz6Py1y3M5yR z1lC5d5VYzer/yCaIwoz9PILnw== X-Received: by 2002:a1c:7c05:: with SMTP id x5-v6mr6605882wmc.7.1526371181646; Tue, 15 May 2018 00:59:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 00:59:40 -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 13/29] venus: helpers: make a commmon function for power_enable Date: Tue, 15 May 2018 10:58:43 +0300 Message-Id: <20180515075859.17217-14-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 Make common function which will enable power when enabling/disabling clocks and also covers Venus 3xx/4xx versions. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 25 ++++---------- drivers/media/platform/qcom/venus/venc.c | 25 ++++---------- 4 files changed, 67 insertions(+), 36 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index d9065cc8a7d3..2b21f6ed7502 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -13,6 +13,7 @@ * */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include "core.h" #include "helpers.h" #include "hfi_helper.h" +#include "hfi_venus_io.h" struct intbuf { struct list_head list; @@ -781,3 +783,52 @@ void venus_helper_init_instance(struct venus_inst *inst) } } EXPORT_SYMBOL_GPL(venus_helper_init_instance); + +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable) +{ + void __iomem *ctrl, *stat; + u32 val; + int ret; + + if (!IS_V3(core) && !IS_V4(core)) + return -EINVAL; + + if (IS_V3(core)) { + if (session_type == VIDC_SESSION_TYPE_DEC) + ctrl = core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL; + else + ctrl = core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL; + if (enable) + writel(0, ctrl); + else + writel(1, ctrl); + + return 0; + } + + if (session_type == VIDC_SESSION_TYPE_DEC) { + ctrl = core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; + } else { + ctrl = core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; + } + + if (enable) { + writel(0, ctrl); + + ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100); + if (ret) + return ret; + } else { + writel(1, ctrl); + + ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_power_enable); diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 971392be5df5..0e64aa95624a 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -43,4 +43,6 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable); #endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 3b38bd1241b0..2bd81de6328a 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1123,26 +1123,21 @@ static int vdec_remove(struct platform_device *pdev) static __maybe_unused int vdec_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); if (IS_V4(core)) clk_disable_unprepare(core->core0_bus_clk); clk_disable_unprepare(core->core0_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); - return 0; + return ret; } static __maybe_unused int vdec_runtime_resume(struct device *dev) @@ -1153,20 +1148,14 @@ static __maybe_unused int vdec_runtime_resume(struct device *dev) if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); - ret = clk_prepare_enable(core->core0_clk); + ret |= clk_prepare_enable(core->core0_clk); if (IS_V4(core)) ret |= clk_prepare_enable(core->core0_bus_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); return ret; } diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index be8ea3326386..f87d891325ea 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1267,26 +1267,21 @@ static int venc_remove(struct platform_device *pdev) static __maybe_unused int venc_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); if (IS_V4(core)) clk_disable_unprepare(core->core1_bus_clk); clk_disable_unprepare(core->core1_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); - return 0; + return ret; } static __maybe_unused int venc_runtime_resume(struct device *dev) @@ -1297,20 +1292,14 @@ static __maybe_unused int venc_runtime_resume(struct device *dev) if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); - ret = clk_prepare_enable(core->core1_clk); + ret |= clk_prepare_enable(core->core1_clk); if (IS_V4(core)) ret |= clk_prepare_enable(core->core1_bus_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); return ret; }