All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Shashank Sharma <shashank.sharma@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Mukul Joshi <mukul.joshi@amd.com>,
	Felix Kuehling <felix.kuehling@amd.com>,
	Shashank Sharma <contactshashanksharma@gmail.com>,
	Christian Koenig <christian.koenig@amd.com>
Subject: Re: [PATCH 07/16] drm/amdgpu: add helper to create doorbell pages
Date: Thu, 30 Mar 2023 13:29:06 +0200	[thread overview]
Message-ID: <220faa77-f51d-0551-e390-437e2accbced@gmail.com> (raw)
In-Reply-To: <20230329154753.1261-8-shashank.sharma@amd.com>

Am 29.03.23 um 17:47 schrieb Shashank Sharma:
> From: Shashank Sharma <contactshashanksharma@gmail.com>
>
> This patch adds helper functions to create and free doorbell
> pages for kernel objects.
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h  | 41 ++++++++++++++++
>   .../gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c  | 49 +++++++++++++++++++
>   2 files changed, 90 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> index f9c3b77bf65d..6581b78fe438 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
> @@ -27,6 +27,24 @@
>   /*
>    * GPU doorbell structures, functions & helpers
>    */
> +
> +/* Structure to hold doorbell pages from PCI doorbell BAR */
> +struct amdgpu_doorbell_obj {
> +	struct amdgpu_bo *bo;
> +	uint64_t gpu_addr;

Do we need to map the doorbells into the GART for something?

On the other hand we probably don't have the check to not do it in 
amdgpu_bo_create_reserved yet.

> +	uint32_t *cpu_addr;
> +	uint32_t size;
> +
> +	/* First index in this object */
> +	uint32_t start;
> +
> +	/* Last index in this object */
> +	uint32_t end;
> +
> +	/* bitmap for dynamic doorbell allocation from this object */
> +	unsigned long *doorbell_bitmap;
> +};
> +

Do we really need a separate structure for all this? As far as I can see 
this is just part of the doorbell handling.

>   struct amdgpu_doorbell {
>   	/* doorbell mmio */
>   	resource_size_t		base;
> @@ -328,6 +346,29 @@ int amdgpu_device_doorbell_init(struct amdgpu_device *adev);
>    */
>   void amdgpu_device_doorbell_fini(struct amdgpu_device *adev);
>   
> +/**
> + * amdgpu_doorbell_free_page - Free a doorbell page
> + *
> + * @adev: amdgpu_device pointer
> + *
> + * @db_age: previously allocated doobell page details
> + *
> + */
> +void amdgpu_doorbell_free_page(struct amdgpu_device *adev,
> +				struct amdgpu_doorbell_obj *db_obj);
> +
> +/**
> + * amdgpu_doorbell_alloc_page - create a page from doorbell pool
> + *
> + * @adev: amdgpu_device pointer
> + *
> + * @db_age: doobell page structure to fill details with
> + *
> + * returns 0 on success, else error number
> + */
> +int amdgpu_doorbell_alloc_page(struct amdgpu_device *adev,
> +				struct amdgpu_doorbell_obj *db_obj);
> +
>   #define RDOORBELL32(index) amdgpu_mm_rdoorbell(adev, (index))
>   #define WDOORBELL32(index, v) amdgpu_mm_wdoorbell(adev, (index), (v))
>   #define RDOORBELL64(index) amdgpu_mm_rdoorbell64(adev, (index))
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> index 1aea92363fd3..8be15b82b545 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> @@ -111,6 +111,55 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
>   	}
>   }
>   
> +/**
> + * amdgpu_doorbell_free_page - Free a doorbell page
> + *
> + * @adev: amdgpu_device pointer
> + *
> + * @db_age: previously allocated doobell page details
> + *
> + */
> +void amdgpu_doorbell_free_page(struct amdgpu_device *adev,
> +					struct amdgpu_doorbell_obj *db_obj)
> +{
> +	amdgpu_bo_free_kernel(&db_obj->bo,
> +			      &db_obj->gpu_addr,
> +			      (void **)&db_obj->cpu_addr);
> +
> +}
> +
> +/**
> + * amdgpu_doorbell_alloc_page - create a page from doorbell pool
> + *
> + * @adev: amdgpu_device pointer
> + *
> + * @db_age: doobell page structure to fill details with
> + *
> + * returns 0 on success, else error number
> + */
> +int amdgpu_doorbell_alloc_page(struct amdgpu_device *adev,
> +				struct amdgpu_doorbell_obj *db_obj)
> +{
> +	int r;
> +
> +	db_obj->size = ALIGN(db_obj->size, PAGE_SIZE);
> +
> +	r = amdgpu_bo_create_kernel(adev,
> +				    db_obj->size,
> +				    PAGE_SIZE,
> +				    AMDGPU_GEM_DOMAIN_DOORBELL,
> +				    &db_obj->bo,
> +				    &db_obj->gpu_addr,
> +				    (void **)&db_obj->cpu_addr);
> +
> +	if (r) {
> +		DRM_ERROR("Failed to create doorbell BO, err=%d\n", r);
> +		return r;
> +	}
> +
> +	return 0;
> +}
> +
>   /*
>    * GPU doorbell aperture helpers function.
>    */


  reply	other threads:[~2023-03-30 11:29 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 15:47 [PATCH 00/16] AMDGPU Doorbell manager Shashank Sharma
2023-03-29 15:47 ` [PATCH 01/16] drm/amdgpu: rename num_doorbells Shashank Sharma
2023-03-30 11:04   ` Christian König
2023-03-30 13:11   ` Luben Tuikov
2023-03-30 13:13     ` Shashank Sharma
2023-03-30 14:19   ` Alex Deucher
2023-04-04 16:13   ` Luben Tuikov
2023-03-29 15:47 ` [PATCH 02/16] drm/amdgpu: include protection for doobell.h Shashank Sharma
2023-03-30 11:05   ` Christian König
2023-03-30 11:07     ` Shashank Sharma
2023-03-30 14:20   ` Alex Deucher
2023-03-29 15:47 ` [PATCH 03/16] drm/amdgpu: create a new file for doorbell manager Shashank Sharma
2023-03-30 11:09   ` Christian König
2023-03-30 13:29     ` Luben Tuikov
2023-03-30 13:42       ` Shashank Sharma
2023-03-30 14:23   ` Alex Deucher
2023-03-30 14:49     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 04/16] drm/amdgpu: don't modify num_doorbells for mes Shashank Sharma
2023-03-30 11:10   ` Christian König
2023-03-30 14:24   ` Alex Deucher
2023-03-29 15:47 ` [PATCH 05/16] drm/amdgpu: add UAPI for allocating doorbell memory Shashank Sharma
2023-03-30 11:11   ` Christian König
2023-03-29 15:47 ` [PATCH 06/16] drm/amdgpu: accommodate DOMAIN/PL_DOORBELL Shashank Sharma
2023-03-30 11:14   ` Christian König
2023-03-30 13:33     ` Luben Tuikov
2023-03-30 13:43       ` Shashank Sharma
2023-03-30 13:45         ` Luben Tuikov
2023-03-30 13:48           ` Shashank Sharma
2023-03-30 14:12             ` Luben Tuikov
2023-03-30 15:32               ` Shashank Sharma
2023-03-30 19:59   ` Alex Deucher
2023-03-29 15:47 ` [PATCH 07/16] drm/amdgpu: add helper to create doorbell pages Shashank Sharma
2023-03-30 11:29   ` Christian König [this message]
2023-03-30 11:46     ` Shashank Sharma
2023-03-30 13:42   ` Luben Tuikov
2023-03-30 13:44     ` Luben Tuikov
2023-03-30 14:04     ` Shashank Sharma
2023-03-30 14:15       ` Luben Tuikov
2023-03-30 14:34         ` Shashank Sharma
2023-03-30 14:37           ` Luben Tuikov
2023-03-30 14:55           ` Alex Deucher
2023-03-30 15:21             ` Shashank Sharma
2023-03-30 20:35               ` Alex Deucher
2023-03-31  8:26                 ` Shashank Sharma
2023-03-30 14:28   ` Alex Deucher
2023-03-30 14:38     ` Luben Tuikov
2023-03-29 15:47 ` [PATCH 08/16] drm/amdgpu: initialize ttm for doorbells Shashank Sharma
2023-03-30 11:22   ` Christian König
2023-03-30 14:33   ` Alex Deucher
2023-03-30 14:54     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 09/16] drm/amdgpu: create kernel doorbell page Shashank Sharma
2023-03-30 11:30   ` Christian König
2023-03-30 11:48     ` Shashank Sharma
2023-03-30 14:39       ` Alex Deucher
2023-03-30 14:42         ` Christian König
2023-03-30 14:48           ` Shashank Sharma
2023-03-30 14:53             ` Christian König
2023-03-30 15:04             ` Alex Deucher
2023-03-31  8:25               ` Shashank Sharma
2023-03-30 14:24   ` Luben Tuikov
2023-03-30 14:40     ` Shashank Sharma
2023-03-30 14:49       ` Christian König
2023-03-30 14:52         ` Luben Tuikov
2023-03-30 14:53         ` Shashank Sharma
2023-03-30 14:59           ` Luben Tuikov
2023-03-30 15:09             ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 10/16] drm/amdgpu: validate doorbell read/write Shashank Sharma
2023-03-30 14:34   ` Luben Tuikov
2023-03-30 14:37     ` Shashank Sharma
2023-03-30 14:49       ` Luben Tuikov
2023-03-30 15:02         ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 11/16] drm/amdgpu: get absolute offset from doorbell index Shashank Sharma
2023-03-30 17:18   ` Luben Tuikov
2023-03-30 17:25     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 12/16] drm/amdgpu: use doorbell manager for kfd kernel doorbells Shashank Sharma
2023-03-30 20:46   ` Alex Deucher
2023-03-31  8:27     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 13/16] drm/amdgpu: use doorbell manager for kfd process doorbells Shashank Sharma
2023-03-30 20:54   ` Alex Deucher
2023-03-31  8:28     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 14/16] drm/amdgpu: remove ununsed functions and variables Shashank Sharma
2023-03-29 15:47 ` [PATCH 15/16] drm/amdgpu: use doorbell mgr for MES kernel doorbells Shashank Sharma
2023-03-30 20:58   ` Alex Deucher
2023-03-31  8:29     ` Shashank Sharma
2023-03-29 15:47 ` [PATCH 16/16] drm/amdgpu: user doorbell mgr for MES process doorbells Shashank Sharma
2023-03-30 13:49 ` [PATCH 00/16] AMDGPU Doorbell manager Luben Tuikov
2023-03-30 13:56   ` Sharma, Shashank

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=220faa77-f51d-0551-e390-437e2accbced@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=contactshashanksharma@gmail.com \
    --cc=felix.kuehling@amd.com \
    --cc=mukul.joshi@amd.com \
    --cc=shashank.sharma@amd.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.