dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Liviu Dudau <Liviu.Dudau@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Marty E . Plummer" <hanetzer@startmail.com>,
	"Rob Herring" <robh@kernel.org>,
	"Clément Péron" <peron.clem@gmail.com>,
	"Nicolas Boichat" <drinkcat@chromium.org>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Faith Ekstrand" <faith.ekstrand@collabora.com>,
	"Daniel Stone" <daniels@collabora.com>,
	"Steven Price" <steven.price@arm.com>,
	"Robin Murphy" <robin.murphy@arm.com>,
	kernel@collabora.com, "Heiko Stuebner" <heiko@sntech.de>,
	"Tatsuyuki Ishi" <ishitatsuyuki@gmail.com>,
	"Chris Diamand" <chris.diamand@foss.arm.com>,
	"Ketil Johnsen" <ketil.johnsen@arm.com>,
	"Grant Likely" <grant.likely@linaro.org>
Subject: Re: [PATCH v4 03/14] drm/panthor: Add the device logical block
Date: Thu, 8 Feb 2024 15:55:36 +0000	[thread overview]
Message-ID: <ZcT5ePyWlie4YyAG@e110455-lin.cambridge.arm.com> (raw)
In-Reply-To: <20240208161459.7dd42bcd@collabora.com>

On Thu, Feb 08, 2024 at 04:14:59PM +0100, Boris Brezillon wrote:
> On Thu, 8 Feb 2024 14:30:02 +0000
> Liviu Dudau <Liviu.Dudau@arm.com> wrote:
> 
> > > +int panthor_device_init(struct panthor_device *ptdev)
> > > +{
> > > +	struct resource *res;
> > > +	struct page *p;
> > > +	int ret;
> > > +
> > > +	ptdev->coherent = device_get_dma_attr(ptdev->base.dev) == DEV_DMA_COHERENT;
> > > +
> > > +	init_completion(&ptdev->unplug.done);
> > > +	ret = drmm_mutex_init(&ptdev->base, &ptdev->unplug.lock);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = drmm_mutex_init(&ptdev->base, &ptdev->pm.mmio_lock);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	atomic_set(&ptdev->pm.state, PANTHOR_DEVICE_PM_STATE_SUSPENDED);
> > > +	p = alloc_page(GFP_KERNEL | __GFP_ZERO);
> > > +	if (!p)
> > > +		return -ENOMEM;
> > > +
> > > +	ptdev->pm.dummy_latest_flush = page_address(p);
> > > +	ret = drmm_add_action_or_reset(&ptdev->base, panthor_device_free_page,
> > > +				       ptdev->pm.dummy_latest_flush);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	/*
> > > +	 * Set the dummy page holding the latest flush to 1. This will cause the
> > > +	 * flush to avoided as we know it isn't necessary if the submission
> > > +	 * happens while the dummy page is mapped. Zero cannot be used because
> > > +	 * that means 'always flush'.
> > > +	 */
> > > +	*ptdev->pm.dummy_latest_flush = 1;
> > > +
> > > +	INIT_WORK(&ptdev->reset.work, panthor_device_reset_work);
> > > +	ptdev->reset.wq = alloc_ordered_workqueue("panthor-reset-wq", 0);
> > > +	if (!ptdev->reset.wq)
> > > +		return -ENOMEM;
> > > +
> > > +	ret = drmm_add_action_or_reset(&ptdev->base, panthor_device_reset_cleanup, NULL);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = panthor_clk_init(ptdev);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = panthor_devfreq_init(ptdev);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ptdev->iomem = devm_platform_get_and_ioremap_resource(to_platform_device(ptdev->base.dev),
> > > +							      0, &res);
> > > +	if (IS_ERR(ptdev->iomem))
> > > +		return PTR_ERR(ptdev->iomem);
> > > +
> > > +	ptdev->phys_addr = res->start;
> > > +
> > > +	ret = devm_pm_runtime_enable(ptdev->base.dev);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = pm_runtime_resume_and_get(ptdev->base.dev);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = panthor_gpu_init(ptdev);
> > > +	if (ret)
> > > +		goto err_rpm_put;
> > > +
> > > +	ret = panthor_mmu_init(ptdev);
> > > +	if (ret)
> > > +		goto err_unplug_gpu;
> > > +
> > > +	ret = panthor_fw_init(ptdev);
> > > +	if (ret)
> > > +		goto err_unplug_mmu;
> > > +
> > > +	ret = panthor_sched_init(ptdev);
> > > +	if (ret)
> > > +		goto err_unplug_fw;
> > > +
> > > +	/* ~3 frames */
> > > +	pm_runtime_set_autosuspend_delay(ptdev->base.dev, 50);
> > > +
> > > +	ret = drm_dev_register(&ptdev->base, 0);
> > > +	if (ret)
> > > +		goto err_unplug_sched;  
> > 
> > For sake of replicating the panthor_device_unplus() calls, should we do
> > here:
> > 
> > 	if (ret) {
> > 		pm_runtime_dont_use_autosuspend(ptdev->base.dev);
> 
> But pm_runtime_use_autosuspend() is called after that, why do we need
> to call pm_runtime_dont_use_autosuspend() here?

This is in the case where ret != 0, so we're going to skip over
pm_runtime_use_autosuspend(). We've just called
pm_runtime_set_autosuspend_delay() which by my reading also enables
runtime PM when it calls update_autosuspend(), so this is needed.

Best regards,
Liviu

> 
> > 		goto err_unplug_sched;
> > 	}
> > 
> > 
> > > +
> > > +	pm_runtime_use_autosuspend(ptdev->base.dev);
> > > +	pm_runtime_put_autosuspend(ptdev->base.dev);
> > > +	return 0;
> > > +
> > > +err_unplug_sched:
> > > +	panthor_sched_unplug(ptdev);
> > > +
> > > +err_unplug_fw:
> > > +	panthor_fw_unplug(ptdev);
> > > +
> > > +err_unplug_mmu:
> > > +	panthor_mmu_unplug(ptdev);
> > > +
> > > +err_unplug_gpu:
> > > +	panthor_gpu_unplug(ptdev);
> > > +
> > > +err_rpm_put:
> > > +	pm_runtime_put_sync_suspend(ptdev->base.dev);
> > > +	return ret;
> > > +}

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

  reply	other threads:[~2024-02-08 15:55 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 16:30 [PATCH v4 00/14] drm: Add a driver for CSF-based Mali GPUs Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 01/14] drm/panthor: Add uAPI Boris Brezillon
2024-02-08 14:29   ` Liviu Dudau
2024-01-22 16:30 ` [PATCH v4 02/14] drm/panthor: Add GPU register definitions Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 03/14] drm/panthor: Add the device logical block Boris Brezillon
2024-02-08 14:30   ` Liviu Dudau
2024-02-08 15:14     ` Boris Brezillon
2024-02-08 15:55       ` Liviu Dudau [this message]
2024-02-08 16:00         ` Boris Brezillon
2024-02-08 16:18           ` Liviu Dudau
2024-02-08 16:54             ` Boris Brezillon
2024-02-08 15:19     ` Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 04/14] drm/panthor: Add the GPU " Boris Brezillon
2024-02-08 16:09   ` Steven Price
2024-01-22 16:30 ` [PATCH v4 05/14] drm/panthor: Add GEM " Boris Brezillon
2024-02-09 15:58   ` Steven Price
2024-02-12 12:31   ` Liviu Dudau
2024-01-22 16:30 ` [PATCH v4 06/14] drm/panthor: Add the devfreq " Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 07/14] drm/panthor: Add the MMU/VM " Boris Brezillon
2024-02-09 16:51   ` Steven Price
2024-02-10  8:02     ` Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 08/14] drm/panthor: Add the FW " Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 09/14] drm/panthor: Add the heap " Boris Brezillon
2024-02-12 11:40   ` Steven Price
2024-02-14 17:33     ` Boris Brezillon
2024-02-15  9:34       ` Steven Price
2024-01-22 16:30 ` [PATCH v4 10/14] drm/panthor: Add the scheduler " Boris Brezillon
2024-02-14 16:48   ` Steven Price
2024-01-22 16:30 ` [PATCH v4 11/14] drm/panthor: Add the driver frontend block Boris Brezillon
2024-01-23 16:29   ` Heiko Stübner
2024-01-23 17:06     ` Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 12/14] drm/panthor: Allow driver compilation Boris Brezillon
2024-01-22 16:30 ` [PATCH v4 13/14] dt-bindings: gpu: mali-valhall-csf: Add support for Arm Mali CSF GPUs Boris Brezillon
2024-01-30 19:54   ` Rob Herring
2024-01-22 16:30 ` [PATCH v4 14/14] drm/panthor: Add an entry to MAINTAINERS Boris Brezillon
2024-01-23 16:18 ` [PATCH v4 00/14] drm: Add a driver for CSF-based Mali GPUs Heiko Stübner
2024-01-29  7:58 ` Boris Brezillon
2024-01-29  9:20 ` Andy Yan
2024-01-29 10:41   ` [PATCH " Boris Brezillon
2024-02-04  1:14     ` Andy Yan
2024-02-04 10:07       ` Boris Brezillon
2024-02-04 10:36         ` Andy Yan
2024-02-05  9:03       ` Boris Brezillon
2024-02-05  9:41         ` Andy Yan
2024-02-05  9:54         ` Danilo Krummrich
2024-02-05 10:31           ` Boris Brezillon
2024-02-06 10:35         ` Andy Yan
2024-02-06 11:11           ` Boris Brezillon
2024-02-08 16:02 ` Liviu Dudau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZcT5ePyWlie4YyAG@e110455-lin.cambridge.arm.com \
    --to=liviu.dudau@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=chris.diamand@foss.arm.com \
    --cc=daniel@ffwll.ch \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=drinkcat@chromium.org \
    --cc=faith.ekstrand@collabora.com \
    --cc=grant.likely@linaro.org \
    --cc=hanetzer@startmail.com \
    --cc=heiko@sntech.de \
    --cc=ishitatsuyuki@gmail.com \
    --cc=kernel@collabora.com \
    --cc=ketil.johnsen@arm.com \
    --cc=neil.armstrong@linaro.org \
    --cc=peron.clem@gmail.com \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox