Received: by 10.192.165.148 with SMTP id m20csp5590197imm; Wed, 9 May 2018 07:27:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqIMUGbSzch3Yb17/3qUDhWr8FYcrgDJ6ZkeXBivZ2xp5dckPNG/ETTXCz90vfEDhlGdXtZ X-Received: by 2002:a65:4bc4:: with SMTP id p4-v6mr21571523pgr.53.1525876034101; Wed, 09 May 2018 07:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525876034; cv=none; d=google.com; s=arc-20160816; b=pf5mmDL0LLG3A4vPTX++gp7Xr1rWT/GvkDbsc9XORSINUhKxKl0195aJ8TtZQcfFEX s5vZhhIBoBBhtOPHfCK8XpdACOqpSxkvQgkbhKtVFJNhkG8e39w1v7EDJHu6/JvRc58m KqdRngs2biV23jvyn8qyanAEZ97dta5xPkEYpS7JMMf8YY+MvF50f03UW9Ip4aJP45Gm bRhNPm7QjyIwFlB8NDWAG6AKyqp2ugYLhlrY/aUzL13I1mbnL1XiCYgunR3IIwUPQXXn hQ03vmq4JvTJMaFMCwkvpag20yGJzvmQFUnFWa5+7jMhhJGSyiWBZgbtyTDGcrKiCzaj i9ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=IQOvFc032gb1lkZOi95Umc85K3E2sIqPC5KfHAzJHsU=; b=lYnfK2hhNKxhSTp1ZVrbd/S8kv+m7BRTv5p6zx6V7/EdyF//oajHbnUeu0LflCtWQ2 IZOvthM9hwWrAFGtf+aS1C/wJg9ncOpk1iugv9wXlWYDCTdAHc25GCUya3vX7V+eDmyM my/ABg3c+HZUuN9l/cC7a+13kx0YNHfyGmOWhSlQmogOb85NPRRYn0Vx56QfMIbwfL96 CVF96nh4LpKsaJ6cJ5g9G0CvgXoRMi3H/Jh0frjGNJl7XwPi367FZOUaSaERGcL7XPGR W1CTgxSFyfWSwjsMlnFhtkJ+8aFKSrUduDur157sxI25ob91lZtNK3DGKNYtqI6pPVsU Y6TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TIy7sWtq; 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 g11-v6si27043607plt.284.2018.05.09.07.26.58; Wed, 09 May 2018 07:27:14 -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=TIy7sWtq; 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 S935105AbeEIO0W (ORCPT + 99 others); Wed, 9 May 2018 10:26:22 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39302 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934617AbeEIO0T (ORCPT ); Wed, 9 May 2018 10:26:19 -0400 Received: by mail-wm0-f68.google.com with SMTP id f8-v6so28264888wmc.4 for ; Wed, 09 May 2018 07:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=IQOvFc032gb1lkZOi95Umc85K3E2sIqPC5KfHAzJHsU=; b=TIy7sWtqm3R13cNYOY6/Ax/tUWsCVvPGhTqpOk1W3yr0gLvQlHVo1Ixk3W7w/Cy4yt aFxHJ7oLT4kiS8X9nQ161GdcJq59YtCU7EtlChi3/oC1xwePRx9htBx1e7/6ZyWALZu6 7DrGbcaeMlWvL7cp8ECrkU7oyeR4ncz+DHAio= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IQOvFc032gb1lkZOi95Umc85K3E2sIqPC5KfHAzJHsU=; b=cisJeQviIlIGN4iAG9QBQDklK4SgjD/iDYe/vcWVr4siKPYg+nDzpWtvG5kack6L0M vZr/s3zVTQognYPL4F/0meY8iB6kGi92NLmv4qcJSscowbXBMPc7ai76qkEwPgclEQ3n nE5G8HmvP7mE6/PdsaTDUdfRHknqExxNGxZRWlMM8qLBauRVLD8bshLZqFFqin9KsvgI R9+wS8+hTxtH31No89YU6ZgyHk3TaqteGGwjdvRsCa4iJr5MOVpXmi8io/iq+VnZp/GP zoVlES2u0CvFOU5xKOj/so6OHN1J3gdP/NfxijhZEeMnwm1vODpdyFxWv/jShdrhZFxs fe2A== X-Gm-Message-State: ALQs6tCoEXfVt2GgDiZQZGsrd7n5tlOdrxZXqSEE27KKI4HzEg8bjwfK 8N3Q1/F4J+BXsTo9xRPDkd8Liw== X-Received: by 2002:a50:8743:: with SMTP id 3-v6mr51600921edv.218.1525875978688; Wed, 09 May 2018 07:26:18 -0700 (PDT) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id j5-v6sm4205571edd.37.2018.05.09.07.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 07:26:17 -0700 (PDT) Subject: Re: [PATCH 08/28] venus: hfi_venus: add suspend function for 4xx version To: Vikash Garodia , Stanimir Varbanov Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-media-owner@vger.kernel.org References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> <20180424124436.26955-9-stanimir.varbanov@linaro.org> <8f26cd748f283043b32da05b39f29348@codeaurora.org> <4bb351351a9725db42bf06da1e778290@codeaurora.org> From: Stanimir Varbanov Message-ID: <9f46bca2-4e86-bafc-198d-c7d2f001fbe6@linaro.org> Date: Wed, 9 May 2018 17:26:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <4bb351351a9725db42bf06da1e778290@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 05/09/2018 05:14 PM, Vikash Garodia wrote: > Hi Stanimir, > > On 2018-05-09 16:45, Stanimir Varbanov wrote: >> Hi Vikash, >> >> On 05/02/2018 09:07 AM, vgarodia@codeaurora.org wrote: >>> 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. >> >> This looks similar to suspend for Venus 3xx. Can you confirm that the >> sequence of checks for 4xx is the same as 3xx? > > Do you mean the driver implementation for Suspend Venus 3xx or the hardware > expectation for Venus 3xx ? If hardware expectation wise, the sequence is > same for 3xx and 4xx. > In the suspend implementation for 3xx, i see that the host just reads > the WFI > and idle status bits, but does not validate those bit value before > preparing > Venus for power collapse. Sequence #2 and #3 is followed for Venus 3xx > implementation. OK, than we can reuse venus_suspend_3xx function for 4xx, just need to fix WFI and idle bit for #1. -- regards, Stan