All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Steven Price <steven.price@arm.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	Liviu Dudau <liviu.dudau@arm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/panthor: Don't use virt_to_pfn()
Date: Mon, 18 Mar 2024 15:11:42 +0000	[thread overview]
Message-ID: <5566e7e4-7c35-4939-9676-a739c96b8aa5@arm.com> (raw)
In-Reply-To: <20240318145119.368582-1-steven.price@arm.com>

On 18/03/2024 2:51 pm, Steven Price wrote:
> virt_to_pfn() isn't available on x86 (except to xen) so breaks
> COMPILE_TEST builds. Avoid its use completely by instead storing the
> struct page pointer allocated in panthor_device_init() and using
> page_to_pfn() instead.
> 
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>   drivers/gpu/drm/panthor/panthor_device.c | 10 ++++++----
>   drivers/gpu/drm/panthor/panthor_device.h |  2 +-
>   2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
> index 69deb8e17778..3c30da03fa48 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.c
> +++ b/drivers/gpu/drm/panthor/panthor_device.c
> @@ -154,6 +154,7 @@ int panthor_device_init(struct panthor_device *ptdev)
>   {
>   	struct resource *res;
>   	struct page *p;
> +	u32 *dummy_page_virt;
>   	int ret;
>   
>   	ptdev->coherent = device_get_dma_attr(ptdev->base.dev) == DEV_DMA_COHERENT;
> @@ -172,9 +173,10 @@ int panthor_device_init(struct panthor_device *ptdev)
>   	if (!p)
>   		return -ENOMEM;
>   
> -	ptdev->pm.dummy_latest_flush = page_address(p);
> +	ptdev->pm.dummy_latest_flush = p;
> +	dummy_page_virt = page_address(p);
>   	ret = drmm_add_action_or_reset(&ptdev->base, panthor_device_free_page,
> -				       ptdev->pm.dummy_latest_flush);
> +				       dummy_page_virt);

Nit: I was about to say I'd be inclined to switch the callback to 
__free_page() instead, but then I realise there's no real need to be 
reinventing that in the first place:

	dummy_page_virt = (void *)devm_get_free_pages(ptdev->base.dev,
					GFP_KERNEL | GFP_ZERO, 0);
	if (!dummy_page_virt)
		return -ENOMEM;

	ptdev->pm.dummy_latest_flush = virt_to_page(dummy_page_virt);

Cheers,
Robin.

>   	if (ret)
>   		return ret;
>   
> @@ -184,7 +186,7 @@ int panthor_device_init(struct panthor_device *ptdev)
>   	 * happens while the dummy page is mapped. Zero cannot be used because
>   	 * that means 'always flush'.
>   	 */
> -	*ptdev->pm.dummy_latest_flush = 1;
> +	*dummy_page_virt = 1;
>   
>   	INIT_WORK(&ptdev->reset.work, panthor_device_reset_work);
>   	ptdev->reset.wq = alloc_ordered_workqueue("panthor-reset-wq", 0);
> @@ -353,7 +355,7 @@ static vm_fault_t panthor_mmio_vm_fault(struct vm_fault *vmf)
>   		if (active)
>   			pfn = __phys_to_pfn(ptdev->phys_addr + CSF_GPU_LATEST_FLUSH_ID);
>   		else
> -			pfn = virt_to_pfn(ptdev->pm.dummy_latest_flush);
> +			pfn = page_to_pfn(ptdev->pm.dummy_latest_flush);
>   		break;
>   
>   	default:
> diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
> index 51c9d61b6796..c84c27dcc92c 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.h
> +++ b/drivers/gpu/drm/panthor/panthor_device.h
> @@ -160,7 +160,7 @@ struct panthor_device {
>   		 * Used to replace the real LATEST_FLUSH page when the GPU
>   		 * is suspended.
>   		 */
> -		u32 *dummy_latest_flush;
> +		struct page *dummy_latest_flush;
>   	} pm;
>   };
>   

  parent reply	other threads:[~2024-03-18 15:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 14:51 [PATCH] drm/panthor: Don't use virt_to_pfn() Steven Price
2024-03-18 15:09 ` Boris Brezillon
2024-03-18 15:11 ` Robin Murphy [this message]
2024-03-18 15:25   ` Boris Brezillon
2024-03-25 10:05   ` Boris Brezillon

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=5566e7e4-7c35-4939-9676-a739c96b8aa5@arm.com \
    --to=robin.murphy@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=liviu.dudau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.