Received: by 10.213.65.68 with SMTP id h4csp1025394imn; Tue, 27 Mar 2018 13:15:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48fJBB3lWTq2u7EFO81Srk9aNMB9SnXucyztYTKB7F/Egm0iVaKv+G74oVwnw/+OVVp+7p8 X-Received: by 2002:a17:902:5a4e:: with SMTP id f14-v6mr744775plm.116.1522181748009; Tue, 27 Mar 2018 13:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522181747; cv=none; d=google.com; s=arc-20160816; b=txIjRs7dpA7jONf+bWMWrD3lm+GBahwagzd6zIwv9KyFUEWGZx8NM7EAgBuTqz5RA7 eMT5n507gOAOxNa0O1uBhfwLPXQ6Vwv0VzqO4aajhM6DNAoqq1B0SoAgyptgVlpRU2Bu os40Q6sAthJWiLBFWuOhWTa/NiFlzbNuuYFHAqWoktQ2YVponDVoIEe6n6UsH5/CqO6H BMresMNe7oOv5+ifSl5yrk7nvFG/EDXzXLgCkjqD3Q8nRW+oEqogUZuIwEwCDfu9If86 D/MNISZNiakp2dmZFVEGxUP58oXlrAxDT99131fKBQ3OTkLNY/OMqEd9zxq+6H2HDzyv n9Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=ooMmOvZ1SO8yhnDKbHPwCfHPeLlwjLHb6v28xICzSCE=; b=ogH3Rsgdnq+JQbsDJcU8NqJ26GASrb6dtmwxtkMh6pgAnwnPunXWEKJyPEx9Doo/Fv jiKTjaWv94jNlkpaYgFTqO/o6vvHfaouaOmW0wCkkYTkew6g6lpj4CuS0hCutRFgvZo5 aAOzkP/gWgXHC1yoGsU9h6ebf6b4iN2oF2yx71Djgb/DJFpfBA4K1rpmGJ6gZGY5mKwJ eYvlrW+itO5Bi1pQOMGL/LS3s4zODL2kgukprVXvXzlpELUPx3fmpuHJImn0iggm20C5 KydsvyICCcAYo5fGUSg8fZXPvxhr6Vwvdo5DgqOd1Hs3+lZ2Alje/RbpAOsd0xtRXVdf fLeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=vSDwrHQq; dkim=fail header.i=@chromium.org header.s=google header.b=UxeAJrP5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19-v6si2194583pli.88.2018.03.27.13.15.33; Tue, 27 Mar 2018 13:15:47 -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=fail header.i=@google.com header.s=20161025 header.b=vSDwrHQq; dkim=fail header.i=@chromium.org header.s=google header.b=UxeAJrP5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751249AbeC0UOh (ORCPT + 99 others); Tue, 27 Mar 2018 16:14:37 -0400 Received: from mail-vk0-f46.google.com ([209.85.213.46]:41739 "EHLO mail-vk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751101AbeC0UOe (ORCPT ); Tue, 27 Mar 2018 16:14:34 -0400 Received: by mail-vk0-f46.google.com with SMTP id l123so94624vke.8 for ; Tue, 27 Mar 2018 13:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ooMmOvZ1SO8yhnDKbHPwCfHPeLlwjLHb6v28xICzSCE=; b=vSDwrHQqLWmiClYND7qxaTfIlTrY2m0Mv8wLKbLOeVYLNjLEgSzxbN/ReTKe+mVbpH Y/QjA5yoCMtW2CTyc7PYdAjinSLG+I9I2vbiIv15ZPg+w5vJDaoP/EBNv+W3av9XXHJA ddbBPzB9Ll1hSV02kur7J8CN+5ZfUZNYqPT4Gws2r3bX124lhq8o30QtnbLhJRMgSYIz TQziFYpJivSJx4RAoU5MTWmZeC4t0xtWoxWTUWhZ7zHWuKHnSIHPEz1oCIi8PMz41XZX 0nvZ7wPHQaBpS7T5wgrzsJzsQZ0TWi0hpjA3qh00IgChxe2op5zWHYu7/iwsMx9kQ6zJ qfrg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ooMmOvZ1SO8yhnDKbHPwCfHPeLlwjLHb6v28xICzSCE=; b=UxeAJrP5P0LrpPd3HbBXNO9TPg1suNlrZfMhx8ZREA+KZyyCiyizGjcFL6p5kAO5Wd MJUj2NZ85TOOfsN/7VVL/8R6N8I5+jE1SKK3Gk/uhL1D7KbIQika7FQh8KSddXXsMI20 JuSGRHMNeXIMNcHh+CFIXG1usZTH1xJwF2Rj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ooMmOvZ1SO8yhnDKbHPwCfHPeLlwjLHb6v28xICzSCE=; b=AqdPsZkbH2fPR8E4NTqoJP+RSmufTM90r0Sp1lBwPD8NXsx49lvarufDAhuwk+b+H6 cM/0Wd+LkU5BiwYJWO8J6u1U8hguRFD4ieF6S7NFZMtp22+JQSodi3Iecr1sdl1alrB8 C24nrdAWLHsnXd55wZE2/icgIAHR2NWauooeYYDOjVuJxCG6Oes1ug1Lo7X0Jh0BpQlU P38cbhQH9AsaBNSPM2mOMTJbEymcYhagfEgOEAsygay+BqBAI4NQKtxib543F2ZKDhmy omYLi7ImisG9OOUhHqyIXo5DFrW/eimrKlVoPCf8CjOuAuEgEE2Y4YMHeag/NnIoGwdW szUA== X-Gm-Message-State: AElRT7EG3SWKa/hNK+zAmPxl9chQVs61j2Jco0vMT2ddTOzpD/FWJTch hCBKBM7iFpIkqTCInUq2p8QTmKUxKcXoYJ0qCJ+1lw== X-Received: by 10.31.103.69 with SMTP id m5mr569449vki.160.1522181672501; Tue, 27 Mar 2018 13:14:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.4.8 with HTTP; Tue, 27 Mar 2018 13:14:31 -0700 (PDT) In-Reply-To: <2e26f672-c6d4-6f8f-00ec-231df3f71802@codeaurora.org> References: <1521785487-29866-1-git-send-email-mgautam@codeaurora.org> <1521785487-29866-2-git-send-email-mgautam@codeaurora.org> <8724ae37-5d71-4d5f-f750-da0cb8838f47@codeaurora.org> <921929e2-405e-703a-038e-732f8c790a2c@codeaurora.org> <2e26f672-c6d4-6f8f-00ec-231df3f71802@codeaurora.org> From: Doug Anderson Date: Tue, 27 Mar 2018 13:14:31 -0700 X-Google-Sender-Auth: 1Ffjqi5wgEiCHD33KulPrxOQcuk Message-ID: Subject: Re: [PATCH v3 1/6] phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS To: Manu Gautam Cc: Vivek Gautam , Kishon Vijay Abraham I , LKML , devicetree@vger.kernel.org, Rob Herring , linux-arm-msm@vger.kernel.org, Varadarajan Narayanan , Viresh Kumar , Wei Yongjun , Fengguang Wu , Amit Nischal Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Mar 27, 2018 at 12:50 AM, Manu Gautam wrote: > Hi, > > > On 3/27/2018 12:26 PM, Vivek Gautam wrote: >> >> >> On 3/27/2018 10:37 AM, Manu Gautam wrote: >>> Hi Doug, >>> >>> >>> On 3/27/2018 9:56 AM, Doug Anderson wrote: >>>> Manu >>>> >>>> On Thu, Mar 22, 2018 at 11:11 PM, Manu Gautam wrote: >>>>> QMP PHY for USB mode requires pipe_clk for calibration and PLL lock >>>>> to take place. This clock is output from PHY to GCC clock_ctl and then >>>>> fed back to QMP PHY and is available from PHY only after PHY is reset >>>>> and initialized, hence it can't be enabled too early in initialization >>>>> sequence. >>>>> >>>>> Signed-off-by: Manu Gautam >>>>> --- >>>>> drivers/phy/qualcomm/phy-qcom-qmp.c | 33 ++++++++++++++++++++++++++++++++- >>>>> 1 file changed, 32 insertions(+), 1 deletion(-) >>>> So it's now new with this patch, but it's more obvious with this >>>> patch. It seems like "UFS/PCIE" is kinda broken w/ respect to how it >>>> controls its clock. Specifically: >>>> >>>> * If you init the PHY but don't power it on, then you "exit" the PHY: >>>> you'll disable/unprepare "pipe_clk" even though you never >>>> prepare/enabled it. >>>> >>>> * If you init the PHY, power it on, power it off, power it on, and >>>> exit the PHY: you'll leave the clock prepared one extra time. >>>> >>>> Specifically I'd expect: for UFS/PCIE the disable/unprepare should be >>>> symmetric with the enable/prepare and should be in "power off", not in >>>> exit. >>>> >>>> ...or did I miss something? >>>> >>>> >>>> Interestingly, your patch fixes this problem for USB3 (where init/exit >>>> are now symmetric), but leaves the problem there for UFS/PCIE. >>>> >>> Thanks for review. >>> One of the reason why pipe_clk is disabled as part of phy_exit is that >>> halt_check from clk_disable reports error if called after PHY has been >>> powered down or phy_exit. >>> I believe that warning should be ignored in qcom gcc-clock driver >>> (for applicable platforms) by using BRANCH_HALT_DELAY as halt_check >>> for pipe_clk and performing clk_disable from power_off for UFS/PCIE. >> UFS doesn't use PIPE clock. Just to confirm: we no longer need to do this "BRANCH_HALT_DELAY" now that we've figured everything out, right? > Yes, UFS PHY doesn't use one. But similar to pipe_clk there are rx/tx symbol_clk > output from PHY that is used by UFS controller. I will update code comments > to not refer UFS for pipe_clk. > >> But considering for PCIe, if we disable pipe clock when phy is still running, then >> it shouldn't be a problem. We should also not see the halt warning as the gcc >> driver should be able to just turn the gate off. >> The reason why it will throw that error is when the parent clock to that gate >> is gated, i.e. the pipe clock is not flowing on that branch. > > I got the confirmation that pipe_clk is needed for PCIE as well for its > initialization to happen successfully. So we do need clock driver change > to fix this in PHY driver. So basically if I'm understanding this correctly: * Both USB and PCIE need the clk_enable() in qcom_qmp_phy_init() * UFS doesn't even use a pipe clock (pipe_clk is NULL and thus these calls are no-ops). So that means the next version of this code will simply get rid of qcom_qmp_phy_poweron() and we can now use the same phy_ops for both everything again? That also makes everything symmetric and gets rid of the possible imbalance of clock enable/disable, so I'm happy. Actually: I'll also throw out a drastic idea here. Maybe instead of having a NULL power_on/power_off, we should have a NULL init/exit. Does anything break if all the stuff that happens today in qcom_qmp_phy_com_init() happens at power_on() time instead of init() time? I suggest this because: * It sounds like init() is supposed to be for initialization that can happen _before_ power on of the PHY. * Any initialization that happens after the PHY has been powered on seems expected to just be in the power_on() function after the regulator was enabled. Presumably moving this stuff to power_on could save you some power in some cases (since the client of the PHY presumably turns power off to the PHY with the idea of saving power). -Doug