From: "Welty, Brian" <brian.welty@intel.com>
To: Oak Zeng <oak.zeng@intel.com>, <intel-xe@lists.freedesktop.org>
Cc: <thomas.hellstrom@intel.com>, <matthew.brost@intel.com>,
<himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH 4/8] drm/xe: Introduce a helper to get dpa from pfn
Date: Wed, 20 Mar 2024 14:41:42 -0700 [thread overview]
Message-ID: <4f386d5a-1bcf-4489-b82f-17b2c0673b7a@intel.com> (raw)
In-Reply-To: <20240320034425.1785007-5-oak.zeng@intel.com>
On 3/19/2024 8:44 PM, Oak Zeng wrote:
> Since we now create struct page backing for each vram page,
> each vram page now also has a pfn, just like system memory.
> This allow us to calcuate device physical address from pfn.
>
> v1: move the function to xe_svm.h (Matt)
> s/vram_pfn_to_dpa/xe_mem_region_pfn_to_dpa (Matt)
> add kernel document for the helper (Thomas)
>
> Signed-off-by: Oak Zeng <oak.zeng@intel.com>
> ---
> drivers/gpu/drm/xe/xe_svm.h | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
> index e944971cfc6d..8a34429eb674 100644
> --- a/drivers/gpu/drm/xe/xe_svm.h
> +++ b/drivers/gpu/drm/xe/xe_svm.h
> @@ -6,8 +6,31 @@
> #ifndef __XE_SVM_H
> #define __XE_SVM_H
>
> -struct xe_tile;
> -struct xe_mem_region;
> +#include "xe_device_types.h"
> +#include "xe_device.h"
> +#include "xe_assert.h"
> +
> +/**
> + * xe_mem_region_pfn_to_dpa() - Calculate page's dpa from pfn
> + *
> + * @mr: The memory region that page resides in
> + * @pfn: page frame number of the page
> + *
> + * Returns: the device physical address of the page
> + */
> +static inline u64 xe_mem_region_pfn_to_dpa(struct xe_mem_region *mr, u64 pfn)
> +{
> + u64 dpa;
> + struct xe_tile *tile = xe_mem_region_to_tile(mr);
I believe you are dropping this patch for now, but wanted to comment.
Is above the only usage of xe_mem_region_to_tile() ?
As mentioned in earlier review, it's better to avoid the tight
association with xe_mem_region and tile. Such as for the UMA we talked
before, it's nice to have flexibility for xe_mem_region to be associated
with multiple tiles. But I guess this is all future/pending, so can
leave to solve in future if you prefer.
Not sure you have other usage of xe_mem_region_to_tile(). But here,
looks only used for getting tile->xe pointer.
Can caller of xe_mem_region_pfn_to_dpa() just pass in the xe device pointer?
-Brian
> + struct xe_device *xe = tile_to_xe(tile);
> + u64 offset;
> +
> + xe_assert(xe, (pfn << PAGE_SHIFT) >= mr->hpa_base);
> + offset = (pfn << PAGE_SHIFT) - mr->hpa_base;
> + dpa = mr->dpa_base + offset;
> +
> + return dpa;
> +}
>
> int xe_devm_add(struct xe_tile *tile, struct xe_mem_region *mr);
> void xe_devm_remove(struct xe_tile *tile, struct xe_mem_region *mr);
next prev parent reply other threads:[~2024-03-20 21:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 3:44 [PATCH 0/8] Use hmm_range_fault to populate user page Oak Zeng
2024-03-20 3:37 ` ✓ CI.Patch_applied: success for " Patchwork
2024-03-20 3:37 ` ✗ CI.checkpatch: warning " Patchwork
2024-03-20 3:38 ` ✗ CI.KUnit: failure " Patchwork
2024-03-20 3:44 ` [PATCH 1/8] drm/xe/svm: Remap and provide memmap backing for GPU vram Oak Zeng
2024-03-20 3:44 ` [PATCH 2/8] drm/xe/svm: Introduce DRM_XE_SVM kernel config Oak Zeng
2024-03-20 3:44 ` [PATCH 3/8] drm/xe: Introduce helper to get tile from memory region Oak Zeng
2024-03-20 3:44 ` [PATCH 4/8] drm/xe: Introduce a helper to get dpa from pfn Oak Zeng
2024-03-20 21:41 ` Welty, Brian [this message]
2024-03-20 22:34 ` Zeng, Oak
2024-03-20 3:44 ` [PATCH 5/8] drm/xe/svm: Get xe memory region from page Oak Zeng
2024-03-20 3:44 ` [PATCH 6/8] drm/xe: Introduce helper to populate userptr Oak Zeng
2024-03-20 19:19 ` Welty, Brian
2024-03-20 20:02 ` Zeng, Oak
2024-03-20 3:44 ` [PATCH 7/8] drm/xe: Introduce a helper to free sg table Oak Zeng
2024-03-20 3:44 ` [PATCH 8/8] drm/xe: Use hmm_range_fault to populate user pages Oak Zeng
-- strict thread matches above, loose matches on Subject: below --
2024-03-20 3:24 [PATCH 0/8] Use hmm_range_fault to populate user page Oak Zeng
2024-03-20 3:24 ` [PATCH 4/8] drm/xe: Introduce a helper to get dpa from pfn Oak Zeng
2024-03-19 2:55 [PATCH 0/8] Use hmm_range_fault to populate user page Oak Zeng
2024-03-19 2:55 ` [PATCH 4/8] drm/xe: Introduce a helper to get dpa from pfn Oak Zeng
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=4f386d5a-1bcf-4489-b82f-17b2c0673b7a@intel.com \
--to=brian.welty@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=oak.zeng@intel.com \
--cc=thomas.hellstrom@intel.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