Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: "Zeng, Oak" <oak.zeng@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Hellstrom, Thomas" <thomas.hellstrom@intel.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"Welty, Brian" <brian.welty@intel.com>,
	"Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH 3/5] drm/xe: Helper to get dpa from pfn
Date: Sat, 16 Mar 2024 01:33:39 +0000	[thread overview]
Message-ID: <ZfT2841h44bVO85l@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <SA1PR11MB69912484F35F776FD70B692C92282@SA1PR11MB6991.namprd11.prod.outlook.com>

On Fri, Mar 15, 2024 at 11:29:33AM -0600, Zeng, Oak wrote:
> 
> 
> > -----Original Message-----
> > From: Brost, Matthew <matthew.brost@intel.com>
> > Sent: Thursday, March 14, 2024 1:39 PM
> > To: Zeng, Oak <oak.zeng@intel.com>
> > Cc: intel-xe@lists.freedesktop.org; Hellstrom, Thomas
> > <thomas.hellstrom@intel.com>; airlied@gmail.com; Welty, Brian
> > <brian.welty@intel.com>; Ghimiray, Himal Prasad
> > <himal.prasad.ghimiray@intel.com>
> > Subject: Re: [PATCH 3/5] drm/xe: Helper to get dpa from pfn
> > 
> > On Wed, Mar 13, 2024 at 11:35:51PM -0400, 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.
> > >
> > > Signed-off-by: Oak Zeng <oak.zeng@intel.com>
> > > ---
> > >  drivers/gpu/drm/xe/xe_device_types.h | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_device_types.h
> > b/drivers/gpu/drm/xe/xe_device_types.h
> > > index bbea40b57e84..bf349321f037 100644
> > > --- a/drivers/gpu/drm/xe/xe_device_types.h
> > > +++ b/drivers/gpu/drm/xe/xe_device_types.h
> > > @@ -576,4 +576,12 @@ static inline struct xe_tile *mem_region_to_tile(struct
> > xe_mem_region *mr)
> > >  	return container_of(mr, struct xe_tile, mem.vram);
> > >  }
> > >
> > > +static inline u64 vram_pfn_to_dpa(struct xe_mem_region *mr, u64 pfn)
> > > +{
> > > +	u64 dpa;
> > > +	u64 offset = (pfn << PAGE_SHIFT) - mr->hpa_base;
> > 
> > Can't this be negative?
> > 
> > e.g. if pfn == 0, offset == -mr->hpa_base.
> > 
> > Or is the assumption (pfn << PAGE_SHIFT) is always > mr->hpa_base?
> > 
> > If so can we an assert or something to ensure we using this function correctly.
> 
> Yes we can assert it. The hpa_base is the host physical base address for this memory region, while pfn should point to a page inside this memory region.
> 
> I will add an assertion.
> 
> 
> > 
> > > +	dpa = mr->dpa_base + offset;
> > > +	return dpa;
> > > +}
> > 
> > Same as previous patch, should be *.h not a *_types.h file.
> 
> Yes will fix.
> > 
> > Also as this is xe_mem_region not explictly vram. Maybe:
> > 
> > s/vram_pfn_to_dpa/xe_mem_region_pfn_to_dpa/
> 
> Xe_mem_region can only represent vram, right? I mean it can't represent system memory. Copied the definition below:
> 
> /**
>  * struct xe_mem_region - memory region structure
>  * This is used to describe a memory region in xe
>  * device, such as HBM memory or CXL extension memory.
>  */
> 

Ah yes but still as the first argument is xe_mem_region I think the
function name should reflect that.

Matt

> Oak
> 
> > 
> > Matt
> > 
> > > +
> > >  #endif
> > > --
> > > 2.26.3
> > >

  reply	other threads:[~2024-03-16  1:35 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14  3:35 [PATCH 0/5] Use hmm_range_fault to populate user page Oak Zeng
2024-03-14  3:28 ` ✓ CI.Patch_applied: success for " Patchwork
2024-03-14  3:28 ` ✗ CI.checkpatch: warning " Patchwork
2024-03-14  3:29 ` ✗ CI.KUnit: failure " Patchwork
2024-03-14  3:35 ` [PATCH 1/5] drm/xe/svm: Remap and provide memmap backing for GPU vram Oak Zeng
2024-03-14 17:17   ` Matthew Brost
2024-03-14 18:32     ` Zeng, Oak
2024-03-14 20:49       ` Matthew Brost
2024-03-15 16:00         ` Zeng, Oak
2024-03-15 20:39           ` Matthew Brost
2024-03-15 21:31             ` Zeng, Oak
2024-03-16  1:25               ` Matthew Brost
2024-03-18 10:16                 ` Hellstrom, Thomas
2024-03-18 15:02                   ` Zeng, Oak
2024-03-18 15:46                     ` Hellstrom, Thomas
2024-03-18 14:51                 ` Zeng, Oak
2024-03-15  1:45   ` Welty, Brian
2024-03-15  3:10     ` Zeng, Oak
2024-03-15  3:16       ` Zeng, Oak
2024-03-15 18:05         ` Welty, Brian
2024-03-15 23:11           ` Zeng, Oak
2024-03-14  3:35 ` [PATCH 2/5] drm/xe: Helper to get memory region from tile Oak Zeng
2024-03-14 17:33   ` Matthew Brost
2024-03-14 17:44   ` Matthew Brost
2024-03-15  2:48     ` Zeng, Oak
2024-03-14  3:35 ` [PATCH 3/5] drm/xe: Helper to get dpa from pfn Oak Zeng
2024-03-14 17:39   ` Matthew Brost
2024-03-15 17:29     ` Zeng, Oak
2024-03-16  1:33       ` Matthew Brost [this message]
2024-03-18 19:25         ` Zeng, Oak
2024-03-18 12:09     ` Hellstrom, Thomas
2024-03-18 19:27       ` Zeng, Oak
2024-03-14  3:35 ` [PATCH 4/5] drm/xe: Helper to populate a userptr or hmmptr Oak Zeng
2024-03-14 20:25   ` Matthew Brost
2024-03-16  1:35     ` Zeng, Oak
2024-03-18  0:29       ` Matthew Brost
2024-03-18 11:53   ` Hellstrom, Thomas
2024-03-18 19:50     ` Zeng, Oak
2024-03-19  8:41       ` Hellstrom, Thomas
2024-03-19 16:13         ` Zeng, Oak
2024-03-19 19:52           ` Hellstrom, Thomas
2024-03-19 20:01             ` Zeng, Oak
2024-03-18 13:12   ` Hellstrom, Thomas
2024-03-18 14:49     ` Zeng, Oak
2024-03-18 15:40       ` Hellstrom, Thomas
2024-03-18 16:09         ` Zeng, Oak
2024-03-14  3:35 ` [PATCH 5/5] drm/xe: Use hmm_range_fault to populate user pages Oak Zeng
2024-03-14 20:54   ` Matthew Brost
2024-03-19  2:36     ` Zeng, Oak

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=ZfT2841h44bVO85l@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=airlied@gmail.com \
    --cc=brian.welty@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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