Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH 2/2] drm/xe: Use drm_device managed mutex/mm init helpers in GGTT
Date: Thu, 6 Jun 2024 20:33:22 +0200	[thread overview]
Message-ID: <476b5068-16de-4cf8-8f2d-47ee0e9986db@intel.com> (raw)
In-Reply-To: <ZmHxBSZBi2vwQr1L@intel.com>



On 06.06.2024 19:25, Rodrigo Vivi wrote:
> On Fri, May 24, 2024 at 03:35:18PM +0200, Michal Wajdeczko wrote:
>> There is not need for private release action as there are existing
>> drmm_mm_init() and drmm_mutex_init() helpers that can be used.
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_ggtt.c | 23 +++++++++++------------
>>  1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
>> index 17e5066763db..7c91fe212dcb 100644
>> --- a/drivers/gpu/drm/xe/xe_ggtt.c
>> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
>> @@ -96,14 +96,6 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
>>  	}
>>  }
>>  
>> -static void ggtt_fini_early(struct drm_device *drm, void *arg)
>> -{
>> -	struct xe_ggtt *ggtt = arg;
>> -
>> -	mutex_destroy(&ggtt->lock);
>> -	drm_mm_takedown(&ggtt->mm);
>> -}
>> -
>>  static void ggtt_fini(struct drm_device *drm, void *arg)
>>  {
>>  	struct xe_ggtt *ggtt = arg;
>> @@ -141,6 +133,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>>  	struct xe_device *xe = tile_to_xe(ggtt->tile);
>>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>>  	unsigned int gsm_size;
>> +	int err;
>>  
>>  	if (IS_SRIOV_VF(xe))
>>  		gsm_size = SZ_8M; /* GGTT is expected to be 4GiB */
>> @@ -189,12 +182,18 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>>  	else
>>  		ggtt->pt_ops = &xelp_pt_ops;
>>  
>> -	drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
>> -		    ggtt->size - xe_wopcm_size(xe));
>> -	mutex_init(&ggtt->lock);
>> +	err = drmm_mm_init(&xe->drm, &ggtt->mm, xe_wopcm_size(xe),
>> +			   ggtt->size - xe_wopcm_size(xe));
>> +	if (err)
>> +		return err;
>> +
>> +	err = drmm_mutex_init(&xe->drm, &ggtt->lock);
>> +	if (err)
>> +		return err;
> 
> My first impression here is that we would have a bug here if drmm_mm_init
> works, but drmm_mutex_init fails, but we are likely safe because the
> probe will also entirely fail if this mutex init fails.
> 
>> +
>>  	primelockdep(ggtt);
>>  
>> -	return drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);
> 
> But my question here is, why drmm and not devm for this ggtt case that
> only makes sense if the hardware/device is up and not about the module
> or no reason to keep it alive after the probe failure or device removal.
> 
> I know that the question is orthogonal to your patch. But if we decide to
> change the course later and move this towards devm, then we need to
> get back to the exit function and perhaps regular mutex.

but note that drm_mm alone does not interact with the hw, it's what we
eventually build on top of it (like here ggtt manager) may touch the hw

> 
> I mean, really nothing against this patch itself, specially if we are
> confident that drmm is the way to go with this ggtt. So, I'm not blocking
> here:
> 
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> 
>> +	return 0;
>>  }
>>  
>>  static void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
>> -- 
>> 2.43.0
>>

  reply	other threads:[~2024-06-06 18:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24 13:35 [PATCH 0/2] Add DRM-managed drm_mm_init() Michal Wajdeczko
2024-05-24 13:35 ` [PATCH 1/2] drm: " Michal Wajdeczko
2024-06-06 17:27   ` Rodrigo Vivi
2024-05-24 13:35 ` [PATCH 2/2] drm/xe: Use drm_device managed mutex/mm init helpers in GGTT Michal Wajdeczko
2024-06-06 17:25   ` Rodrigo Vivi
2024-06-06 18:33     ` Michal Wajdeczko [this message]
2024-05-24 13:41 ` ✓ CI.Patch_applied: success for Add DRM-managed drm_mm_init() Patchwork
2024-05-24 13:42 ` ✓ CI.checkpatch: " Patchwork
2024-05-24 13:43 ` ✓ CI.KUnit: " Patchwork
2024-05-24 13:54 ` ✓ CI.Build: " Patchwork
2024-05-24 13:57 ` ✓ CI.Hooks: " Patchwork
2024-05-24 13:58 ` ✗ CI.checksparse: warning " Patchwork
2024-05-24 14:28 ` ✗ CI.BAT: failure " Patchwork
2024-05-24 17:25   ` Michal Wajdeczko
2024-05-27 11:27 ` ✗ CI.FULL: " Patchwork

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=476b5068-16de-4cf8-8f2d-47ee0e9986db@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.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