From patchwork Tue Nov 30 23:23:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12648619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FDE7C43217 for ; Tue, 30 Nov 2021 23:25:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC0D06E839; Tue, 30 Nov 2021 23:24:57 +0000 (UTC) Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6961A6E839 for ; Tue, 30 Nov 2021 23:24:12 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id n12so57982244lfe.1 for ; Tue, 30 Nov 2021 15:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z5LZNzGJpLsApxqpURZGyur77JxFewe+cdR7kou+Iuc=; b=MT3M7qcQvUCN+etyhHm6SGYEk0wsAkakVbCCkN4LmUYWMlc8zEByKa6v6ei2JG+Rk6 V2a9YfYSgIiCEMN2WmWuenkQ9Kai0ntIlVdClImsBJkKiFdcEV+KHo6YEecNDOpWsoON /ff7qTEryBQTwKT5k+5/YdXHPxIThNbdC8Si0ok3WTiqCisXXVoL4QCimpdEFz/MT9s/ NfNQ/AYNRZullNONFibpO4nJ8znsagfElFiwB0gz0zNaFaK7+mhMNrHMaIA+KVHrqfLV tp2v9rQe0zD3/XEP7Jg8Th4xYQSUnD78jZk6j6DgfCB+AhjLBC6+SUw3Y1aV0xpGvIu9 Jazg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z5LZNzGJpLsApxqpURZGyur77JxFewe+cdR7kou+Iuc=; b=RlDDSrB+pPOo1p6KhU9DJr4gddKH7KB98+YNlC16zOhimOKBruX7bbyxHOlnrKxLlk BTH7g84xVehzD0mvcd/oCkKVhkwBio++Pl0Y0HLQJZeDNI+xgRkSJh+/Ty4GROeUqg8p dQUpH1Zg7Y+Rdo36o7arAqLC6Qv2OPPwz0hXfmgXyoG93iFDBQ2cHP4eK6YafwoSsXBt cmdG6AawnipsJMR+TlE8Z9MrniE2dpg24PMtlqmwwXg5HNBV7YasuhUMj2Hr4olHI/ru 47HGyzc7n1zdRAV06d/02a3A0l4/fLfLocgmOaYd+sDZ2uM7M7XaYtqlta6R6gpWL98s MFGg== X-Gm-Message-State: AOAM533x4y+KL/k+HEQkx+FhBFU9SGnyYEjCv/25UX5qLzlI2O1XtcLb ihyu3dlluqKB0hJvTzRFfiQ= X-Google-Smtp-Source: ABdhPJyR8l7h/2KwKFk6RajKklSyPd7+Ig4dSGTAY3MmUXLu3/ZtsCMmMNhF60Ec91QzfRVXDHd3Tg== X-Received: by 2002:a05:6512:138a:: with SMTP id p10mr2276184lfa.508.1638314650820; Tue, 30 Nov 2021 15:24:10 -0800 (PST) Received: from localhost.localdomain (94-29-46-111.dynamic.spd-mgts.ru. [94.29.46.111]) by smtp.gmail.com with ESMTPSA id x199sm1860735lff.284.2021.11.30.15.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 15:24:10 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Ulf Hansson , Viresh Kumar , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Lee Jones , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Nishanth Menon , Adrian Hunter , Michael Turquette Subject: [PATCH v16 16/40] drm/tegra: nvdec: Stop channel on suspend Date: Wed, 1 Dec 2021 02:23:23 +0300 Message-Id: <20211130232347.950-17-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211130232347.950-1-digetx@gmail.com> References: <20211130232347.950-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-pm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Heidelberg , linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" CDMA must be stopped before hardware is suspended. Add channel stopping to RPM suspend callback. Add system level suspend-resume callbacks. Runtime PM initialization is moved to host1x client init phase because RPM callback now uses host1x channel that is available only when host1x client is registered. Reviewed-by: Ulf Hansson Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/nvdec.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/tegra/nvdec.c b/drivers/gpu/drm/tegra/nvdec.c index 791bf1acf5f0..15f036e09e5c 100644 --- a/drivers/gpu/drm/tegra/nvdec.c +++ b/drivers/gpu/drm/tegra/nvdec.c @@ -113,9 +113,13 @@ static int nvdec_init(struct host1x_client *client) goto free_channel; } + pm_runtime_enable(client->dev); + pm_runtime_use_autosuspend(client->dev); + pm_runtime_set_autosuspend_delay(client->dev, 500); + err = tegra_drm_register_client(tegra, drm); if (err < 0) - goto free_syncpt; + goto disable_rpm; /* * Inherit the DMA parameters (such as maximum segment size) from the @@ -125,7 +129,10 @@ static int nvdec_init(struct host1x_client *client) return 0; -free_syncpt: +disable_rpm: + pm_runtime_dont_use_autosuspend(client->dev); + pm_runtime_force_suspend(client->dev); + host1x_syncpt_put(client->syncpts[0]); free_channel: host1x_channel_put(nvdec->channel); @@ -150,10 +157,15 @@ static int nvdec_exit(struct host1x_client *client) if (err < 0) return err; + pm_runtime_dont_use_autosuspend(client->dev); + pm_runtime_force_suspend(client->dev); + host1x_syncpt_put(client->syncpts[0]); host1x_channel_put(nvdec->channel); host1x_client_iommu_detach(client); + nvdec->channel = NULL; + if (client->group) { dma_unmap_single(nvdec->dev, nvdec->falcon.firmware.phys, nvdec->falcon.firmware.size, DMA_TO_DEVICE); @@ -268,6 +280,8 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev) { struct nvdec *nvdec = dev_get_drvdata(dev); + host1x_channel_stop(nvdec->channel); + clk_disable_unprepare(nvdec->clk); return 0; @@ -412,10 +426,6 @@ static int nvdec_probe(struct platform_device *pdev) goto exit_falcon; } - pm_runtime_enable(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, 500); - pm_runtime_use_autosuspend(&pdev->dev); - return 0; exit_falcon: @@ -436,11 +446,6 @@ static int nvdec_remove(struct platform_device *pdev) return err; } - if (pm_runtime_enabled(&pdev->dev)) - pm_runtime_disable(&pdev->dev); - else - nvdec_runtime_suspend(&pdev->dev); - falcon_exit(&nvdec->falcon); return 0; @@ -448,6 +453,8 @@ static int nvdec_remove(struct platform_device *pdev) static const struct dev_pm_ops nvdec_pm_ops = { SET_RUNTIME_PM_OPS(nvdec_runtime_suspend, nvdec_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) }; struct platform_driver tegra_nvdec_driver = {