Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp939812pxb; Wed, 27 Oct 2021 15:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTrKKxhJG2yFedvkzjiylJJwD2rSrV/ieR/YogVCNa8v96WC5xuK3MHMZV6eyR/aCLZq3m X-Received: by 2002:a17:90b:224a:: with SMTP id hk10mr8766482pjb.139.1635374433237; Wed, 27 Oct 2021 15:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635374433; cv=none; d=google.com; s=arc-20160816; b=oYfZmMks39fiRsh9eovLLe2d1q5sWxUPBpKK7I7KChL+5EFq3/SgHjbiKqpEjXP22s Q7MdyXzVbibuNT/XYgjzCWpNiguodwdrfQhpQSnP33ayKDtkwwrULLmqwSF5snwkQ+aU xY76DjbWnzV2aWA6MT8KV3A2U8P3+5HRngFu2A1iTDmcVOCoX4JRVtmn35NeTjHzueWl b3L7bcNsS8PJyvS+jItPp/ktSD0tknufMeeITBJfLbTBqycARDb8xvIUgQ87K3B2sSss i+/XcwNxeZQe6ws3gdpdcCUO/CD1UF0r/rG1OOQ06aEHd+hidpMRmRJ5yW8e7zv8xD2T zsZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9oSytowWKNwBBfMwPK2z8OUTJ/DV6Vi07ePItefhWPA=; b=v2sziSzqEbFEs0rSu60wEP0S8DFUrGwZJYHixMbrheqtRCDDZuQknFb2qEKQ5x45o0 I5valfrdL/D5g4J29mBNyttaUd35zMnVdnHQst1XoTX9tPWhORgqP+WgwZEaa5HQSkUo gDxPIpp0X5eR6CB0W9xRcqEQzogVubvZB9XCNTrP4RO561cJfvRiqyIJf9lkLwiGO7k9 nr2L9osrS+Lmq4D6gPKsNDE7K2o9NSfdPCKIHEnSnab/+Bbb4opOg7exM63u8j5WymiG y0mJqRtn11SedCjgD/+4djTNBCj4HiYf5D2YlF3tzVIdGsGgOL2wk9AdxrDimm/W54hA Bh2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=avoig4YK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l184si1492264pgd.496.2021.10.27.15.40.20; Wed, 27 Oct 2021 15:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=avoig4YK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229836AbhJ0Wkh (ORCPT + 99 others); Wed, 27 Oct 2021 18:40:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbhJ0Wkg (ORCPT ); Wed, 27 Oct 2021 18:40:36 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC19EC061570 for ; Wed, 27 Oct 2021 15:38:10 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id i65so10295715ybb.2 for ; Wed, 27 Oct 2021 15:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9oSytowWKNwBBfMwPK2z8OUTJ/DV6Vi07ePItefhWPA=; b=avoig4YK8GBf9CAkkiPstN495H8ufgsgLmycuwhIIcKQlChKBArOq3T7H08ISwbkZP b1PMg4Ox60dyWE6lCMObvITqTxbOWx7qItChFwJt3dxA05vzHSH6OFMuG9qobd7E+HeY IUlvslIN37ITjz9mW0+IcwO9HlspVWj1T2Dhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9oSytowWKNwBBfMwPK2z8OUTJ/DV6Vi07ePItefhWPA=; b=1WIc7woEEB8uiLI2ULe0xLqpuDEOr9mN/XNL/hNIkEgL0tX2f1uDA4SYe7JUNSIfGE wCDd3ghXbeMAESpsOiPKxcJLHdl0hNvFpASkj8f9SpfZYqQnOBCFBZGOLch0A1JjBKhi RIgkRXuT/HiXQ4luGB2Nxg3jMZSXW6i+pkjdAarkXL3oKQPpqJwQiQZ4INyUYXGh97z1 RQ3Ze/tUiI7e1rVwu0JzzPdKYpVj5hxWCaVJ1Cd9hiIEmE32pA+i+ySufZvTh7Ky6yNn Iol1smKUDA0jhLcPjwTymWh3w+HAsctwWkCscboWQyuA/dvWP9vI5gewv1LOrJRqiwrO 0jVw== X-Gm-Message-State: AOAM532x10y6gaD8dwAn0Xx7DcQpM+20B1mjvEao8FmglrRn8C7QzgMw ZbRCl28J98PR8P3pw6JAev6zjDkJTgmIv/j3x67TRg== X-Received: by 2002:a25:23cc:: with SMTP id j195mr506259ybj.508.1635374290200; Wed, 27 Oct 2021 15:38:10 -0700 (PDT) MIME-Version: 1.0 References: <20211026145622.v4.1.I9d81c3b44f350707b5373d00524af77c4aae862b@changeid> In-Reply-To: From: Philip Chen Date: Wed, 27 Oct 2021 15:37:59 -0700 Message-ID: Subject: Re: [PATCH v4 1/2] drm/bridge: parade-ps8640: Enable runtime power management To: Doug Anderson Cc: LKML , Stephen Boyd , Andrzej Hajda , Daniel Vetter , David Airlie , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Neil Armstrong , Robert Foss , dri-devel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Doug, On Wed, Oct 27, 2021 at 3:08 PM Doug Anderson wrote: > > Hi, > > On Tue, Oct 26, 2021 at 2:56 PM Philip Chen wrote: > > > > Fit ps8640 driver into runtime power management framework: > > > > First, break _poweron() to 3 parts: (1) turn on power and wait for > > ps8640's internal MCU to finish init (2) check panel HPD (which is > > proxied by GPIO9) (3) the other configs. As runtime_resume() can be > > called before panel is powered, we only add (1) to _resume() and leave > > (2)(3) to _pre_enable(). We also add (2) to _aux_transfer() as we want > > to ensure panel HPD is asserted before we start AUX CH transactions. > > > > Second, the original driver has a mysterious delay of 50 ms between (2) > > and (3). Since Parade's support can't explain what the delay is for, > > and we don't see removing the delay break any boards at hand, remove > > the delay to fit into this driver change. > > > > In addition, rename "powered" to "pre_enabled" and don't check for it > > in the pm_runtime calls. The pm_runtime calls are already refcounted > > so there's no reason to check there. The other user of "powered", > > _get_edid(), only cares if pre_enable() has already been called. > > > > Lastly, change some existing DRM_...() logging to dev_...() along the > > way, since DRM_...() seem to be deprecated in [1]. > > > > [1] https://patchwork.freedesktop.org/patch/454760/ > > > > Signed-off-by: Philip Chen > > Reviewed-by: Douglas Anderson > > Reviewed-by: Stephen Boyd > > --- > > In v3, I also added pm_suspend_ignore_children() in the ps8640_probe() > > but forgot to mention that in the v3 change log. > > > > Changes in v4: > > - Make ps8640_ensure_hpd() return int (This change was mis-added to > > another patch [2] in this patch series: > > [2] https://patchwork.kernel.org/project/dri-devel/patch/20211026121058.v3.2.I09899dea340f11feab97d719cb4b62bef3179e4b@changeid/) > > > > Changes in v3: > > - Fix typo/wording in the commit message. > > - Add ps8640_aux_transfer_msg() for AUX operation. In > > ps8640_aux_transfer(), wrap around ps8640_aux_transfer_msg() > > with PM operations and HPD check. > > - Document why autosuspend_delay is set to 500ms. > > > > drivers/gpu/drm/bridge/parade-ps8640.c | 186 +++++++++++++++---------- > > 1 file changed, 115 insertions(+), 71 deletions(-) > > Unfortunately, your patch no longer applies to drm-misc/drm-misc-next. > Commit 7abbc26fd667 ("drm/bridge: ps8640: Register and attach our DSI > device at probe") landed and that causes a merge conflict. Can you > rebase and resend? Yes, I will rebase and resend. > > This will also cause a conflict when Sam's change lands [1] so I guess > we can see whose lands first. Let me review that now and maybe you add > a Tested-by? If it lands that'll make it easier and you can just > rebase on both of them? As per your latest reply, I'll just rebase atop drm-misc-next for now. > > > > + pm_runtime_enable(dev); > > + /* > > + * In practice, ps8640_aux_transfer_msg() takes ~300ms to complete in > > + * the worst case. Set autosuspend_delay to 500ms. > > + */ > > + pm_runtime_set_autosuspend_delay(dev, 500); > > To be a little nitpicky, this makes it sound as if the 500 ms needs to > be greater than the 300 ms for correctness. That's not _really_ the > case. During the whole ps8640_aux_transfer_msg() we're holding a PM > Runtime reference (so it won't autosuspend no matter what) and at the > end of it we mark that we were busy so the timer won't start ticking > until then. Yeah....sorry, looking again, I agree the comment I added in v3 is pretty misleading. I think autosuspend_delay just needs to be consistently longer than the interval between each aux_transfer call during EDID read. I'll measure the interval and add the number to the comment. > > Really the 500 ms is because we're quite slow to power up (~300 ms) > and so we want to avoid powering down and powering up constantly. We > definitely need to avoid a power down / power up when reading the EDID > and an EDID read involves _several_ calls in a row to the AUX transfer > function. We also expect that after userspace reads the EDID it will > call us again "soon" to turn the power on and it's nice to not have to > wait the 300 ms again. The 500 ms here is really just a number that's > not too short but not too long. I suppose it's roughly related to the > 300 ms because that's the delay we're trying to avoid, but otherwise > they are unrelated. NOTE: the code will still be _correct_ if we miss > the 500 ms window, it'll just be a lot slower. > > [1] https://lore.kernel.org/r/20211020181901.2114645-2-sam@ravnborg.org > > -Doug