Received: by 10.192.165.148 with SMTP id m20csp267637imm; Tue, 1 May 2018 23:08:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5UdidoksjsndT6LyuqzXAkFUE/dqe3dOSKDY12Lbgd8hkCD4DwviCT7nxqEu5BGMTxHCQ X-Received: by 10.98.242.74 with SMTP id y10mr18224009pfl.75.1525241335511; Tue, 01 May 2018 23:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525241335; cv=none; d=google.com; s=arc-20160816; b=gDGTTOBkqj4agmZH7noEBxvr/b2BTkeOTLzTjhs3z9oBlYMY/YfiuQl734k6t8D5vz WNrIv4bPFjlK5HGWwmY2bZ110DQPBFqkrJRBMcyTPhnVZXv0FAPSz/oyxtpRi4pfa5s1 nqiR+Jbxs52f2BIigvjUEnLY4bTrQQo2mC9AzYkv6ssLnnJNXm+muHo5xjl5BbYBqsMz EkxJfQYthitMHJ2z5rWpQ0zStCsH8rGXU+34zcX5CPnsof5aAE/F7yoDdvY66u2u6+vn /ygiudlZ7V4gslwyINOHbt0SFS+Ras3s8Bg6XWXhrQaCXhqOyl9zVALKrLwkBEPJmjXC n8Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=wMQL3E9cQPQ1gZPEPx9AHKB/z45RKk1WQ8oGWMAUEwY=; b=YPXIonZAvyObrez4Rar7ffHCodVtuNhUlePVo3gvRruqjxKj/wwhni6IUVvguUkzHY QS6mEQYrI+HM3MJCnSYbSLzKat2/Arjhunz1HmdE5nKQUGD79H877wcUjnKVLjRIQvTR heZf6rS3tgqQMEqfFGAuHOD9Dp8mYgP75XDXE7LQ9RuiEGKp6J/dtuFE/mwF2x85KzEc IXQcGyq5WWDKCq5nQU2/NZkWs+kFaH7o8AS/buSb9JN7GGBR0De+FfYH61xI++KEwj9c dfnphJQmqTTKqQ2QJgas2GxCy/oR2oyEGnPjfvgborC8jg8ks+eAjiVUfBQ7+7hm4QPm Nobg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=E91igSbg; dkim=pass header.i=@codeaurora.org header.s=default header.b=E91igSbg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h27-v6si5045109pgn.147.2018.05.01.23.08.40; Tue, 01 May 2018 23:08:55 -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=@codeaurora.org header.s=default header.b=E91igSbg; dkim=pass header.i=@codeaurora.org header.s=default header.b=E91igSbg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751234AbeEBGHE (ORCPT + 99 others); Wed, 2 May 2018 02:07:04 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34232 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbeEBGHD (ORCPT ); Wed, 2 May 2018 02:07:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BFDF660AD4; Wed, 2 May 2018 06:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525241222; bh=9aOyWFHEBKtS+hUlgmhfRnM1ccVROPKLN6RDd2mjjh0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=E91igSbgS2srSSF43zOPsNFNOR06cT1+dtSi2OzdMWyIL/IKzdg7HqS0MSiW/Sh+m MHf4JVlnTWGBayoTiVOoGKJ0f1mP9qHCU29vRW/QtIcBzgOrma0nbMXmE08f9JazOx sONnUcQk+UXqxTClmiibgOOOtlNlonpJ3nNNi6gI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 2041360115; Wed, 2 May 2018 06:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525241222; bh=9aOyWFHEBKtS+hUlgmhfRnM1ccVROPKLN6RDd2mjjh0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=E91igSbgS2srSSF43zOPsNFNOR06cT1+dtSi2OzdMWyIL/IKzdg7HqS0MSiW/Sh+m MHf4JVlnTWGBayoTiVOoGKJ0f1mP9qHCU29vRW/QtIcBzgOrma0nbMXmE08f9JazOx sONnUcQk+UXqxTClmiibgOOOtlNlonpJ3nNNi6gI= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 02 May 2018 11:37:02 +0530 From: vgarodia@codeaurora.org To: Stanimir Varbanov Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 08/28] venus: hfi_venus: add suspend function for 4xx version In-Reply-To: <20180424124436.26955-9-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> <20180424124436.26955-9-stanimir.varbanov@linaro.org> Message-ID: <8f26cd748f283043b32da05b39f29348@codeaurora.org> X-Sender: vgarodia@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Stanimir, On 2018-04-24 18:14, Stanimir Varbanov wrote: > 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); > } Let me brief on the power collapse sequence for Venus_4xx 1. Host checks for ARM9 and Video core to be idle. This can be done by checking for WFI bit (bit 0) in CPU status register for ARM9 and by checking bit 30 in Control status reg for video core/s. 2. Host then sends command to ARM9 to prepare for power collapse. 3. Host then checks for WFI bit and PC_READY bit before withdrawing going for power off. As per this patch, host is preparing for power collapse without checking for #1. Update the code to handle #3. Thanks Vikash