From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BBFBC43214 for ; Tue, 17 Aug 2021 12:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C06261029 for ; Tue, 17 Aug 2021 12:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237161AbhHQMFv (ORCPT ); Tue, 17 Aug 2021 08:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237004AbhHQMFt (ORCPT ); Tue, 17 Aug 2021 08:05:49 -0400 Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88204C0613C1 for ; Tue, 17 Aug 2021 05:05:16 -0700 (PDT) Received: by mail-vs1-xe2f.google.com with SMTP id f13so4585096vsl.13 for ; Tue, 17 Aug 2021 05:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zp99VySxCP/C+XoDYPyxq/KzXedadDuj5suqohF5Fvg=; b=nFsjYjBXuhreAiAOicko40FJ2Ek7yGZ95EL78+psS1PBgU/zV/hVvGucyeNGB/VHuA CZvLcibDFKv0his4Xlc/kKpRR4KmuVlfNPdCOjLa9yqFMDSVDsx+N86gbova/TWvfOvh UN5fcZIAF+gxZrptxSzZ1Ic8Wvj0+yF7hFtRm/gqHM41KJ03TLeAZhinYWrAoSrnataU dyVF+WhuUoCZmS68K3nFSjCbBWA101ONrhbvx8clVKf/1q6HwW6DBCFaGKFGnYrUqvgr aL45tUdh4eNundsr+ZCDy2CWtZ6BTR2SQU6gRUHinuEuOmjdznvPCL+5j+0D/G8oV6sT gR9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zp99VySxCP/C+XoDYPyxq/KzXedadDuj5suqohF5Fvg=; b=RGYyyrkaVobr/KTDk+Ozc8IZxhowNwi5ZDN0Xu7PaDkki3iY+x2l0xBSJflp4cLFYg MCU5Y/CWq3vUSV/sLYv2k/7fjsRk1KYcse97G358uVXq4LND4F6I8yAx9BwSZyMfhM2R sl6OD7Tbsalr27/ZU6ht8OZUGCRbfL9BxZvRLHZcOx0MkJVbxaSUDgArVWzvFEnrCxo+ oDE+HiO5WF4r29rl4JgK7xuvOhkXrluzSjoBu0NXxLNPh5c7bOxFSrCWJCAmDiq4Xs2E 2LRed3aY4DdaXb6/mqk9xmvCqa6ZKjB2SdM3MFJ2h/PyMG4Wp+pix+6dUGnPEyz5NXaf jJQw== X-Gm-Message-State: AOAM5334Z7jx6X4WuwWKi3HRNs1e2OrW4k6e93XV2mINGNx32+RrwDmO uD8qjHHJsKUAWsKfT1cVGAVxE9jiQCbfD1YGB2WkxA== X-Google-Smtp-Source: ABdhPJyAoDZB8D567sM7+DgXNNDfJZjhAOy3SVS/bltXL11iGgVxqJXFnX1rcCitBmOIa8V8M0KZWwa23CQNDRPlT28= X-Received: by 2002:a67:f6d8:: with SMTP id v24mr2357440vso.48.1629201915619; Tue, 17 Aug 2021 05:05:15 -0700 (PDT) MIME-Version: 1.0 References: <20210817012754.8710-1-digetx@gmail.com> <20210817012754.8710-12-digetx@gmail.com> In-Reply-To: <20210817012754.8710-12-digetx@gmail.com> From: Ulf Hansson Date: Tue, 17 Aug 2021 14:04:38 +0200 Message-ID: Subject: Re: [PATCH v8 11/34] gpu: host1x: Add runtime PM and OPP support To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Viresh Kumar , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Peter Chen , Mark Brown , Lee Jones , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Nishanth Menon , Vignesh Raghavendra , Richard Weinberger , Miquel Raynal , Lucas Stach , Stefan Agner , Adrian Hunter , Mauro Carvalho Chehab , Rob Herring , Michael Turquette , Linux Kernel Mailing List , linux-tegra , Linux PM , Linux USB List , linux-staging@lists.linux.dev, linux-spi@vger.kernel.org, linux-pwm@vger.kernel.org, linux-mtd@lists.infradead.org, linux-mmc , Linux Media Mailing List , dri-devel , DTML , linux-clk Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Aug 2021 at 03:30, Dmitry Osipenko wrote: > > Add runtime PM and OPP support to the Host1x driver. It's required for > enabling system-wide DVFS and supporting dynamic power management using > a generic power domain. For the starter we will keep host1x always-on > because dynamic power management require a major refactoring of the driver > code since lot's of code paths will need the RPM handling and we're going > to remove some of these paths in the future. Host1x doesn't consume much > power so it is good enough, we at least need to resume Host1x in order > to initialize the power state. > > Tested-by: Peter Geis # Ouya T30 > Tested-by: Paul Fertser # PAZ00 T20 > Tested-by: Nicolas Chauvet # PAZ00 T20 and TK1 T124 > Tested-by: Matt Merhar # Ouya T30 > Signed-off-by: Dmitry Osipenko > --- [...] > + > static int host1x_probe(struct platform_device *pdev) > { > struct host1x *host; > @@ -394,6 +423,10 @@ static int host1x_probe(struct platform_device *pdev) > /* set common host1x device data */ > platform_set_drvdata(pdev, host); > > + err = devm_tegra_core_dev_init_opp_table_simple(&pdev->dev); > + if (err) > + return err; > + > host->regs = devm_ioremap_resource(&pdev->dev, regs); > if (IS_ERR(host->regs)) > return PTR_ERR(host->regs); > @@ -423,12 +456,9 @@ static int host1x_probe(struct platform_device *pdev) > return err; > } > > - host->rst = devm_reset_control_get(&pdev->dev, "host1x"); > - if (IS_ERR(host->rst)) { > - err = PTR_ERR(host->rst); > - dev_err(&pdev->dev, "failed to get reset: %d\n", err); > + err = host1x_get_resets(host); > + if (err) > return err; > - } > > err = host1x_iommu_init(host); > if (err < 0) { > @@ -443,22 +473,10 @@ static int host1x_probe(struct platform_device *pdev) > goto iommu_exit; > } > > - err = clk_prepare_enable(host->clk); > - if (err < 0) { > - dev_err(&pdev->dev, "failed to enable clock\n"); > - goto free_channels; > - } > - > - err = reset_control_deassert(host->rst); > - if (err < 0) { > - dev_err(&pdev->dev, "failed to deassert reset: %d\n", err); > - goto unprepare_disable; > - } > - Removing the clk_prepare_enable() and reset_control_deassert() from host1x_probe(), might not be a good idea. See more about why, below. > err = host1x_syncpt_init(host); > if (err) { > dev_err(&pdev->dev, "failed to initialize syncpts\n"); > - goto reset_assert; > + goto free_channels; > } > > err = host1x_intr_init(host, syncpt_irq); > @@ -467,10 +485,14 @@ static int host1x_probe(struct platform_device *pdev) > goto deinit_syncpt; > } > > - host1x_debug_init(host); > + pm_runtime_enable(&pdev->dev); > > - if (host->info->has_hypervisor) > - host1x_setup_sid_table(host); > + /* the driver's code isn't ready yet for the dynamic RPM */ > + err = pm_runtime_resume_and_get(&pdev->dev); If the driver is being built with the CONFIG_PM Kconfig option being unset, pm_runtime_resume_and_get() will return 0 to indicate success - and without calling the ->runtime_resume() callback. In other words, the clock will remain gated and the reset will not be deasserted, likely causing the driver to be malfunctioning. If the driver isn't ever being built with CONFIG_PM unset, feel free to ignore my above comments. Otherwise, if it needs to work both with and without CONFIG_PM being set, you may use the following pattern in host1x_probe() to deploy runtime PM support: "Enable the needed resources to probe the device" pm_runtime_get_noresume() pm_runtime_set_active() pm_runtime_enable() "Before successfully completing probe" pm_runtime_put() > + if (err) > + goto deinit_intr; > + > + host1x_debug_init(host); > > err = host1x_register(host); > if (err < 0) > @@ -486,13 +508,13 @@ static int host1x_probe(struct platform_device *pdev) > host1x_unregister(host); > deinit_debugfs: > host1x_debug_deinit(host); > + > + pm_runtime_put(&pdev->dev); > + pm_runtime_disable(&pdev->dev); > +deinit_intr: > host1x_intr_deinit(host); > deinit_syncpt: > host1x_syncpt_deinit(host); > -reset_assert: > - reset_control_assert(host->rst); > -unprepare_disable: > - clk_disable_unprepare(host->clk); > free_channels: > host1x_channel_list_free(&host->channel_list); > iommu_exit: [...] Kind regards Uffe