Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2024-08-27 Thread Stephen Rothwell
Hi all,

On Mon, 26 Aug 2024 11:10:22 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the amdgpu tree got a conflict in:
> 
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> 
> between commits:
> 
>   537ef0f88897 ("drm/amd/display: use new vblank enable policy for DCN35+")
>   e45b6716de4b ("drm/amd/display: use a more lax vblank enable policy for 
> DCN35+")
>   58a261bfc967 ("drm/amd/display: use a more lax vblank enable policy for 
> older ASICs")
> 
> from the drm-misc tree and commit:
> 
>   7fb363c57522 ("drm/amd/display: Let drm_crtc_vblank_on/off manage 
> interrupts")
> 
> from the amdgpu tree.
> 
> I fixed it up (I think - see below) and can carry the fix as necessary.
> This is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> 
> diff --cc drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 34872eb4fc84,7d999e352df3..
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@@ -8229,66 -8248,12 +8242,35 @@@ static int amdgpu_dm_encoder_init(struc
>   
>   static void manage_dm_interrupts(struct amdgpu_device *adev,
>struct amdgpu_crtc *acrtc,
>  - bool enable)
>  + struct dm_crtc_state *acrtc_state)
>   {
> - /*
> -  * We have no guarantee that the frontend index maps to the same
> -  * backend index - some even map to more than one.
> -  *
> -  * TODO: Use a different interrupt or check DC itself for the mapping.
> -  */
> - int irq_type =
> - amdgpu_display_crtc_idx_to_irq_type(
> - adev,
> - acrtc->crtc_id);
>  -if (enable)
>  -drm_crtc_vblank_on(&acrtc->base);
>  -else
>  +struct drm_vblank_crtc_config config = {0};
>  +struct dc_crtc_timing *timing;
>  +int offdelay;
>  +
>  +if (acrtc_state) {
>  +if (amdgpu_ip_version(adev, DCE_HWIP, 0) <
>  +IP_VERSION(3, 5, 0) ||
>  +acrtc_state->stream->link->psr_settings.psr_version <
>  +DC_PSR_VERSION_UNSUPPORTED) {
>  +timing = &acrtc_state->stream->timing;
>  +
>  +/* at least 2 frames */
>  +offdelay = DIV64_U64_ROUND_UP((u64)20 *
>  +  timing->v_total *
>  +  timing->h_total,
>  +  timing->pix_clk_100hz);
>  +
>  +config.offdelay_ms = offdelay ?: 30;
>  +} else {
>  +config.disable_immediate = true;
>  +}
>  +
>  +drm_crtc_vblank_on_config(&acrtc->base,
>  +  &config);
> - 
> - amdgpu_irq_get(
> - adev,
> - &adev->pageflip_irq,
> - irq_type);
> - #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
> - amdgpu_irq_get(
> - adev,
> - &adev->vline0_irq,
> - irq_type);
> - #endif
>  +} else {
> - #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
> - amdgpu_irq_put(
> - adev,
> - &adev->vline0_irq,
> - irq_type);
> - #endif
> - amdgpu_irq_put(
> - adev,
> - &adev->pageflip_irq,
> - irq_type);
>   drm_crtc_vblank_off(&acrtc->base);
>  +}
>   }
>   
>   static void dm_update_pflip_irq_state(struct amdgpu_device *adev,

This is now a conflict between the drm-misc tree and the drm tree.

-- 
Cheers,
Stephen Rothwell


pgpMYJ5ZwMeVK.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2024-08-25 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

between commits:

  537ef0f88897 ("drm/amd/display: use new vblank enable policy for DCN35+")
  e45b6716de4b ("drm/amd/display: use a more lax vblank enable policy for 
DCN35+")
  58a261bfc967 ("drm/amd/display: use a more lax vblank enable policy for older 
ASICs")

from the drm-misc tree and commit:

  7fb363c57522 ("drm/amd/display: Let drm_crtc_vblank_on/off manage interrupts")

from the amdgpu tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 34872eb4fc84,7d999e352df3..
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@@ -8229,66 -8248,12 +8242,35 @@@ static int amdgpu_dm_encoder_init(struc
  
  static void manage_dm_interrupts(struct amdgpu_device *adev,
 struct amdgpu_crtc *acrtc,
 -   bool enable)
 +   struct dm_crtc_state *acrtc_state)
  {
-   /*
-* We have no guarantee that the frontend index maps to the same
-* backend index - some even map to more than one.
-*
-* TODO: Use a different interrupt or check DC itself for the mapping.
-*/
-   int irq_type =
-   amdgpu_display_crtc_idx_to_irq_type(
-   adev,
-   acrtc->crtc_id);
 -  if (enable)
 -  drm_crtc_vblank_on(&acrtc->base);
 -  else
 +  struct drm_vblank_crtc_config config = {0};
 +  struct dc_crtc_timing *timing;
 +  int offdelay;
 +
 +  if (acrtc_state) {
 +  if (amdgpu_ip_version(adev, DCE_HWIP, 0) <
 +  IP_VERSION(3, 5, 0) ||
 +  acrtc_state->stream->link->psr_settings.psr_version <
 +  DC_PSR_VERSION_UNSUPPORTED) {
 +  timing = &acrtc_state->stream->timing;
 +
 +  /* at least 2 frames */
 +  offdelay = DIV64_U64_ROUND_UP((u64)20 *
 +timing->v_total *
 +timing->h_total,
 +timing->pix_clk_100hz);
 +
 +  config.offdelay_ms = offdelay ?: 30;
 +  } else {
 +  config.disable_immediate = true;
 +  }
 +
 +  drm_crtc_vblank_on_config(&acrtc->base,
 +&config);
- 
-   amdgpu_irq_get(
-   adev,
-   &adev->pageflip_irq,
-   irq_type);
- #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
-   amdgpu_irq_get(
-   adev,
-   &adev->vline0_irq,
-   irq_type);
- #endif
 +  } else {
- #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
-   amdgpu_irq_put(
-   adev,
-   &adev->vline0_irq,
-   irq_type);
- #endif
-   amdgpu_irq_put(
-   adev,
-   &adev->pageflip_irq,
-   irq_type);
drm_crtc_vblank_off(&acrtc->base);
 +  }
  }
  
  static void dm_update_pflip_irq_state(struct amdgpu_device *adev,


pgpODmeUYTxRM.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2023-05-14 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  include/drm/display/drm_dp.h

between commit:

  55b24786b748 ("drm/display: Add missing OLED Vesa brightnesses definitions")

from the drm-misc tree and commit:

  4d5f872dbc75 ("drm/amd/display: Adding support for VESA SCR")

from the amdgpu tree.

I fixed it up (the changes in the latter included the changes in the
former (apart from whitespace differences)) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


pgp_tqm_NQDpz.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2023-01-15 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

between commit:

  a6276e92a037 ("drm: Include  where needed")

from the drm-misc tree and commit:

  a98cdd8c4856 ("drm/amd/display: refactor ddc logic from dc_link_ddc to 
link_ddc")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 55a845eb0c6d,7bf21bb52a7d..
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@@ -66,8 -66,6 +66,7 @@@
  
  #include "ivsrcid/ivsrcid_vislands30.h"
  
- #include "i2caux_interface.h"
 +#include 
  #include 
  #include 
  #include 


pgp9gF0uZM9cG.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2022-11-15 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  include/drm/gpu_scheduler.h

between commit:

  2cf9886e2816 ("drm/scheduler: remove drm_sched_dependency_optimized")

from the drm-misc tree and commit:

  06a2d7cc3f04 ("drm/amdgpu: revert "implement tdr advanced mode"")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc include/drm/gpu_scheduler.h
index cec147f7c50b,0168ff469ae0..
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@@ -532,10 -528,9 +532,7 @@@ void drm_sched_wakeup(struct drm_gpu_sc
  void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job 
*bad);
  void drm_sched_start(struct drm_gpu_scheduler *sched, bool full_recovery);
  void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched);
- void drm_sched_resubmit_jobs_ext(struct drm_gpu_scheduler *sched, int max);
  void drm_sched_increase_karma(struct drm_sched_job *bad);
- void drm_sched_reset_karma(struct drm_sched_job *bad);
- void drm_sched_increase_karma_ext(struct drm_sched_job *bad, int type);
 -bool drm_sched_dependency_optimized(struct dma_fence* fence,
 -  struct drm_sched_entity *entity);
  void drm_sched_fault(struct drm_gpu_scheduler *sched);
  void drm_sched_job_kickout(struct drm_sched_job *s_job);
  


pgp1fHMa0EDh1.pgp
Description: OpenPGP digital signature


Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2022-04-29 Thread Christian König

Am 29.04.22 um 03:13 schrieb Stephen Rothwell:

Hi all,

On Wed, 13 Apr 2022 10:10:14 +1000 Stephen Rothwell  
wrote:

On Wed, 6 Apr 2022 10:34:05 +1000 Stephen Rothwell  
wrote:

Today's linux-next merge of the amdgpu tree got a conflict in:

   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

between commit:

   fee2ede15542 ("drm/ttm: rework bulk move handling v5")

from the drm-misc tree and commit:

   184a69ca4d41 ("drm/amdgpu: separate VM PT handling into amdgpu_vm_pt.c")

from the amdgpu tree.

I fixed it up (I used this file from the latter and added the following
patch) and can carry the fix as necessary. This is now fixed as far as
linux-next is concerned, but any non trivial conflicts should be mentioned
to your upstream maintainer when your tree is submitted for merging.
You may also want to consider cooperating with the maintainer of the
conflicting tree to minimise any particularly complex conflicts.

From: Stephen Rothwell 
Date: Wed, 6 Apr 2022 10:28:53 +1000
Subject: [PATCH] fix up for "drm/ttm: rework bulk move handling v5"

Signed-off-by: Stephen Rothwell 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index 958d7ed97882..a29933fa001f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -630,7 +630,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base 
*entry)
  
  	if (!entry->bo)

return;
+
shadow = amdgpu_bo_shadowed(entry->bo);
+   if (shadow) {
+   ttm_bo_set_bulk_move(&shadow->tbo, NULL);
+   amdgpu_bo_unref(&shadow);
+   }
+
+   ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
entry->bo->vm_bo = NULL;
list_del(&entry->vm_status);
amdgpu_bo_unref(&shadow);
@@ -653,8 +660,6 @@ static void amdgpu_vm_pt_free_dfs(struct amdgpu_device 
*adev,
struct amdgpu_vm_pt_cursor cursor;
struct amdgpu_vm_bo_base *entry;
  
-	vm->bulk_moveable = false;

-
for_each_amdgpu_vm_pt_dfs_safe(adev, vm, start, cursor, entry)
amdgpu_vm_pt_free(entry);
  
--

2.35.1

This is now a conflict between the drm tree and the amdgpu tree.

I noticed that commit 184a69ca4d41 was merged into the drm tree but
only the second hunk of this merge fixup was applied.  So is the first
hunk above unnecessary?


Ah! Thanks a lot for noticing this.

And the hunk is absolutely necessary and we already have a bug report 
that it is missing wondering why I can't reproduce this.


Thanks,
Christian.


Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2022-04-28 Thread Stephen Rothwell
Hi all,

On Wed, 13 Apr 2022 10:10:14 +1000 Stephen Rothwell  
wrote:
>
> On Wed, 6 Apr 2022 10:34:05 +1000 Stephen Rothwell  
> wrote:
> >
> > Today's linux-next merge of the amdgpu tree got a conflict in:
> > 
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > 
> > between commit:
> > 
> >   fee2ede15542 ("drm/ttm: rework bulk move handling v5")
> > 
> > from the drm-misc tree and commit:
> > 
> >   184a69ca4d41 ("drm/amdgpu: separate VM PT handling into amdgpu_vm_pt.c")
> > 
> > from the amdgpu tree.
> > 
> > I fixed it up (I used this file from the latter and added the following
> > patch) and can carry the fix as necessary. This is now fixed as far as
> > linux-next is concerned, but any non trivial conflicts should be mentioned
> > to your upstream maintainer when your tree is submitted for merging.
> > You may also want to consider cooperating with the maintainer of the
> > conflicting tree to minimise any particularly complex conflicts.
> > 
> > From: Stephen Rothwell 
> > Date: Wed, 6 Apr 2022 10:28:53 +1000
> > Subject: [PATCH] fix up for "drm/ttm: rework bulk move handling v5"
> > 
> > Signed-off-by: Stephen Rothwell 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> > index 958d7ed97882..a29933fa001f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> > @@ -630,7 +630,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base 
> > *entry)
> >  
> > if (!entry->bo)
> > return;
> > +
> > shadow = amdgpu_bo_shadowed(entry->bo);
> > +   if (shadow) {
> > +   ttm_bo_set_bulk_move(&shadow->tbo, NULL);
> > +   amdgpu_bo_unref(&shadow);
> > +   }
> > +
> > +   ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
> > entry->bo->vm_bo = NULL;
> > list_del(&entry->vm_status);
> > amdgpu_bo_unref(&shadow);
> > @@ -653,8 +660,6 @@ static void amdgpu_vm_pt_free_dfs(struct amdgpu_device 
> > *adev,
> > struct amdgpu_vm_pt_cursor cursor;
> > struct amdgpu_vm_bo_base *entry;
> >  
> > -   vm->bulk_moveable = false;
> > -
> > for_each_amdgpu_vm_pt_dfs_safe(adev, vm, start, cursor, entry)
> > amdgpu_vm_pt_free(entry);
> >  
> > -- 
> > 2.35.1  
> 
> This is now a conflict between the drm tree and the amdgpu tree.

I noticed that commit 184a69ca4d41 was merged into the drm tree but
only the second hunk of this merge fixup was applied.  So is the first
hunk above unnecessary?

-- 
Cheers,
Stephen Rothwell


pgpDSxdniFy4v.pgp
Description: OpenPGP digital signature


Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2022-04-12 Thread Stephen Rothwell
Hi all,

On Wed, 6 Apr 2022 10:34:05 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the amdgpu tree got a conflict in:
> 
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> 
> between commit:
> 
>   fee2ede15542 ("drm/ttm: rework bulk move handling v5")
> 
> from the drm-misc tree and commit:
> 
>   184a69ca4d41 ("drm/amdgpu: separate VM PT handling into amdgpu_vm_pt.c")
> 
> from the amdgpu tree.
> 
> I fixed it up (I used this file from the latter and added the following
> patch) and can carry the fix as necessary. This is now fixed as far as
> linux-next is concerned, but any non trivial conflicts should be mentioned
> to your upstream maintainer when your tree is submitted for merging.
> You may also want to consider cooperating with the maintainer of the
> conflicting tree to minimise any particularly complex conflicts.
> 
> From: Stephen Rothwell 
> Date: Wed, 6 Apr 2022 10:28:53 +1000
> Subject: [PATCH] fix up for "drm/ttm: rework bulk move handling v5"
> 
> Signed-off-by: Stephen Rothwell 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> index 958d7ed97882..a29933fa001f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> @@ -630,7 +630,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base 
> *entry)
>  
>   if (!entry->bo)
>   return;
> +
>   shadow = amdgpu_bo_shadowed(entry->bo);
> + if (shadow) {
> + ttm_bo_set_bulk_move(&shadow->tbo, NULL);
> + amdgpu_bo_unref(&shadow);
> + }
> +
> + ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
>   entry->bo->vm_bo = NULL;
>   list_del(&entry->vm_status);
>   amdgpu_bo_unref(&shadow);
> @@ -653,8 +660,6 @@ static void amdgpu_vm_pt_free_dfs(struct amdgpu_device 
> *adev,
>   struct amdgpu_vm_pt_cursor cursor;
>   struct amdgpu_vm_bo_base *entry;
>  
> - vm->bulk_moveable = false;
> -
>   for_each_amdgpu_vm_pt_dfs_safe(adev, vm, start, cursor, entry)
>   amdgpu_vm_pt_free(entry);
>  
> -- 
> 2.35.1

This is now a conflict between the drm tree and the amdgpu tree.

-- 
Cheers,
Stephen Rothwell


pgpHP8aRm32UG.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2022-04-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

between commit:

  fee2ede15542 ("drm/ttm: rework bulk move handling v5")

from the drm-misc tree and commit:

  184a69ca4d41 ("drm/amdgpu: separate VM PT handling into amdgpu_vm_pt.c")

from the amdgpu tree.

I fixed it up (I used this file from the latter and added the following
patch) and can carry the fix as necessary. This is now fixed as far as
linux-next is concerned, but any non trivial conflicts should be mentioned
to your upstream maintainer when your tree is submitted for merging.
You may also want to consider cooperating with the maintainer of the
conflicting tree to minimise any particularly complex conflicts.

From: Stephen Rothwell 
Date: Wed, 6 Apr 2022 10:28:53 +1000
Subject: [PATCH] fix up for "drm/ttm: rework bulk move handling v5"

Signed-off-by: Stephen Rothwell 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index 958d7ed97882..a29933fa001f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -630,7 +630,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base 
*entry)
 
if (!entry->bo)
return;
+
shadow = amdgpu_bo_shadowed(entry->bo);
+   if (shadow) {
+   ttm_bo_set_bulk_move(&shadow->tbo, NULL);
+   amdgpu_bo_unref(&shadow);
+   }
+
+   ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
entry->bo->vm_bo = NULL;
list_del(&entry->vm_status);
amdgpu_bo_unref(&shadow);
@@ -653,8 +660,6 @@ static void amdgpu_vm_pt_free_dfs(struct amdgpu_device 
*adev,
struct amdgpu_vm_pt_cursor cursor;
struct amdgpu_vm_bo_base *entry;
 
-   vm->bulk_moveable = false;
-
for_each_amdgpu_vm_pt_dfs_safe(adev, vm, start, cursor, entry)
amdgpu_vm_pt_free(entry);
 
-- 
2.35.1

-- 
Cheers,
Stephen Rothwell


pgpJODMhv4P8M.pgp
Description: OpenPGP digital signature


Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-06-03 Thread Stephen Rothwell
Hi all,

On Thu, 3 Jun 2021 12:48:47 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the amdgpu tree got conflicts in:
> 
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> 
> between commit:
> 
>   d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")
> 
> from the drm-misc tree and commits:
> 
>   b453e42a6e8b ("drm/amdgpu: Add new placement for preemptible SG BOs")
>   2a675640bc2d ("drm/amdgpu: move shadow bo validation to VM code")
>   59276f056fb7 ("drm/amdgpu: switch to amdgpu_bo_vm for vm code")
>   19a1d9350be6 ("drm/amdgpu: flush gart changes after all BO recovery")
> 
> from the amdgpu tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 663aa7d2e2ea,86259435803e..
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@@ -459,10 -479,11 +461,11 @@@ static int amdgpu_bo_move(struct ttm_bu
>   {
>   struct amdgpu_device *adev;
>   struct amdgpu_bo *abo;
>  -struct ttm_resource *old_mem = &bo->mem;
>  +struct ttm_resource *old_mem = bo->resource;
>   int r;
>   
> - if (new_mem->mem_type == TTM_PL_TT) {
> + if (new_mem->mem_type == TTM_PL_TT ||
> + new_mem->mem_type == AMDGPU_PL_PREEMPT) {
>   r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
>   if (r)
>   return r;
> @@@ -989,8 -1012,9 +995,9 @@@ int amdgpu_ttm_alloc_gart(struct ttm_bu
>   return r;
>   }
>   
> + amdgpu_gart_invalidate_tlb(adev);
>  -ttm_resource_free(bo, &bo->mem);
>  -bo->mem = tmp;
>  +ttm_resource_free(bo, bo->resource);
>  +ttm_bo_assign_mem(bo, &tmp);
>   }
>   
>   return 0;
> @@@ -1348,7 -1373,16 +1356,16 @@@ static bool amdgpu_ttm_bo_eviction_valu
>   }
>   }
>   
>  -switch (bo->mem.mem_type) {
>  +switch (bo->resource->mem_type) {
> + case AMDGPU_PL_PREEMPT:
> + /* Preemptible BOs don't own system resources managed by the
> +  * driver (pages, VRAM, GART space). They point to resources
> +  * owned by someone else (e.g. pageable memory in user mode
> +  * or a DMABuf). They are used in a preemptible context so we
> +  * can guarantee no deadlocks and good QoS in case of MMU
> +  * notifiers or DMABuf move notifiers from the resource owner.
> +  */
> + return false;
>   case TTM_PL_TT:
>   if (amdgpu_bo_is_amdgpu_bo(bo) &&
>   amdgpu_bo_encrypted(ttm_to_amdgpu_bo(bo)))
> @@@ -1767,8 -1809,13 +1791,9 @@@ void amdgpu_ttm_fini(struct amdgpu_devi
>   amdgpu_bo_free_kernel(&adev->mman.discovery_memory, NULL, NULL);
>   amdgpu_ttm_fw_reserve_vram_fini(adev);
>   
>  -if (adev->mman.aper_base_kaddr)
>  -iounmap(adev->mman.aper_base_kaddr);
>  -adev->mman.aper_base_kaddr = NULL;
>  -
>   amdgpu_vram_mgr_fini(adev);
>   amdgpu_gtt_mgr_fini(adev);
> + amdgpu_preempt_mgr_fini(adev);
>   ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GDS);
>   ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GWS);
>   ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_OA);
> @@@ -1919,7 -2010,12 +1944,12 @@@ int amdgpu_fill_buffer(struct amdgpu_b
>   return -EINVAL;
>   }
>   
>  -if (bo->tbo.mem.mem_type == AMDGPU_PL_PREEMPT) {
> ++if (bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT) {
> + DRM_ERROR("Trying to clear preemptible memory.\n");
> + return -EINVAL;
> + }
> + 
>  -if (bo->tbo.mem.mem_type == TTM_PL_TT) {
>  +if (bo->tbo.resource->mem_type == TTM_PL_TT) {
>   r = amdgpu_ttm_alloc_gart(&bo->tbo);
>   if (r)
>   return r;
> diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index bcfd4a8d0288,1923f035713a..
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@@ -657,11 -657,10 +658,11 @@@ void amdgpu_vm_move_to_lru_tail(struct 
>   if (!bo->parent)
>   continue;
>   
>  -ttm_bo_move_to_lru_tail(&bo->tbo, &bo->tbo.mem,
>  +ttm_bo_move_to_lru_tail(&bo->tbo, bo->tbo.resource,
>   &vm->lru_bulk_move);
> - if (bo->shadow)
> - ttm_bo_move_to_lru_tail(&bo->shadow->tbo,
> + if (shadow)
>  -ttm_bo_move_to_lr

Re: linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-06-02 Thread Stephen Rothwell
Hi all,

On Thu, 3 Jun 2021 12:48:47 +1000 Stephen Rothwell  
wrote:
>
> diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index bcfd4a8d0288,1923f035713a..
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@@ -657,11 -657,10 +658,11 @@@ void amdgpu_vm_move_to_lru_tail(struct 
>   if (!bo->parent)
>   continue;
>   
>  -ttm_bo_move_to_lru_tail(&bo->tbo, &bo->tbo.mem,
>  +ttm_bo_move_to_lru_tail(&bo->tbo, bo->tbo.resource,
>   &vm->lru_bulk_move);
> - if (bo->shadow)
> - ttm_bo_move_to_lru_tail(&bo->shadow->tbo,
> + if (shadow)
>  -ttm_bo_move_to_lru_tail(&shadow->tbo, &shadow->tbo.mem,
> ++ttm_bo_move_to_lru_tail(&shadow->tbo,
>  +bo->shadow->tbo.resource,

that line should have been
shadow->tbo.resource,

I have fixed it up in my resolution.

-- 
Cheers,
Stephen Rothwell


pgpcoJQrBq0Z0.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-06-02 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got conflicts in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

between commit:

  d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

from the drm-misc tree and commits:

  b453e42a6e8b ("drm/amdgpu: Add new placement for preemptible SG BOs")
  2a675640bc2d ("drm/amdgpu: move shadow bo validation to VM code")
  59276f056fb7 ("drm/amdgpu: switch to amdgpu_bo_vm for vm code")
  19a1d9350be6 ("drm/amdgpu: flush gart changes after all BO recovery")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 663aa7d2e2ea,86259435803e..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@@ -459,10 -479,11 +461,11 @@@ static int amdgpu_bo_move(struct ttm_bu
  {
struct amdgpu_device *adev;
struct amdgpu_bo *abo;
 -  struct ttm_resource *old_mem = &bo->mem;
 +  struct ttm_resource *old_mem = bo->resource;
int r;
  
-   if (new_mem->mem_type == TTM_PL_TT) {
+   if (new_mem->mem_type == TTM_PL_TT ||
+   new_mem->mem_type == AMDGPU_PL_PREEMPT) {
r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
if (r)
return r;
@@@ -989,8 -1012,9 +995,9 @@@ int amdgpu_ttm_alloc_gart(struct ttm_bu
return r;
}
  
+   amdgpu_gart_invalidate_tlb(adev);
 -  ttm_resource_free(bo, &bo->mem);
 -  bo->mem = tmp;
 +  ttm_resource_free(bo, bo->resource);
 +  ttm_bo_assign_mem(bo, &tmp);
}
  
return 0;
@@@ -1348,7 -1373,16 +1356,16 @@@ static bool amdgpu_ttm_bo_eviction_valu
}
}
  
 -  switch (bo->mem.mem_type) {
 +  switch (bo->resource->mem_type) {
+   case AMDGPU_PL_PREEMPT:
+   /* Preemptible BOs don't own system resources managed by the
+* driver (pages, VRAM, GART space). They point to resources
+* owned by someone else (e.g. pageable memory in user mode
+* or a DMABuf). They are used in a preemptible context so we
+* can guarantee no deadlocks and good QoS in case of MMU
+* notifiers or DMABuf move notifiers from the resource owner.
+*/
+   return false;
case TTM_PL_TT:
if (amdgpu_bo_is_amdgpu_bo(bo) &&
amdgpu_bo_encrypted(ttm_to_amdgpu_bo(bo)))
@@@ -1767,8 -1809,13 +1791,9 @@@ void amdgpu_ttm_fini(struct amdgpu_devi
amdgpu_bo_free_kernel(&adev->mman.discovery_memory, NULL, NULL);
amdgpu_ttm_fw_reserve_vram_fini(adev);
  
 -  if (adev->mman.aper_base_kaddr)
 -  iounmap(adev->mman.aper_base_kaddr);
 -  adev->mman.aper_base_kaddr = NULL;
 -
amdgpu_vram_mgr_fini(adev);
amdgpu_gtt_mgr_fini(adev);
+   amdgpu_preempt_mgr_fini(adev);
ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GDS);
ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GWS);
ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_OA);
@@@ -1919,7 -2010,12 +1944,12 @@@ int amdgpu_fill_buffer(struct amdgpu_b
return -EINVAL;
}
  
 -  if (bo->tbo.mem.mem_type == AMDGPU_PL_PREEMPT) {
++  if (bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT) {
+   DRM_ERROR("Trying to clear preemptible memory.\n");
+   return -EINVAL;
+   }
+ 
 -  if (bo->tbo.mem.mem_type == TTM_PL_TT) {
 +  if (bo->tbo.resource->mem_type == TTM_PL_TT) {
r = amdgpu_ttm_alloc_gart(&bo->tbo);
if (r)
return r;
diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index bcfd4a8d0288,1923f035713a..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@@ -657,11 -657,10 +658,11 @@@ void amdgpu_vm_move_to_lru_tail(struct 
if (!bo->parent)
continue;
  
 -  ttm_bo_move_to_lru_tail(&bo->tbo, &bo->tbo.mem,
 +  ttm_bo_move_to_lru_tail(&bo->tbo, bo->tbo.resource,
&vm->lru_bulk_move);
-   if (bo->shadow)
-   ttm_bo_move_to_lru_tail(&bo->shadow->tbo,
+   if (shadow)
 -  ttm_bo_move_to_lru_tail(&shadow->tbo, &shadow->tbo.mem,
++  ttm_bo_move_to_lru_tail(&shadow->tbo,
 +  bo->shadow->tbo.res

linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-05-20 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdkfd/kfd_device.c

between commit:

  e9669fb78262 ("drm/amdgpu: Add early fini callback")

from the drm-misc tree and commit:

  814ab9930cfd ("drm/amdkfd: register HMM device private zone")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdkfd/kfd_device.c
index b066aa009b6f,80015e866498..
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@@ -861,6 -891,8 +891,7 @@@ out
  void kgd2kfd_device_exit(struct kfd_dev *kfd)
  {
if (kfd->init_complete) {
 -  kgd2kfd_suspend(kfd, false);
+   svm_migrate_fini((struct amdgpu_device *)kfd->kgd);
device_queue_manager_uninit(kfd->dqm);
kfd_interrupt_exit(kfd);
kfd_topology_remove_device(kfd);


pgpujlOCUjRiT.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-05-20 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

between commit:

  35bba8313b95 ("drm/amdgpu: Convert driver sysfs attributes to static 
attributes")

from the drm-misc tree and commit:

  589939d40116 ("drm/amdgpu: fix coding style and documentation in 
amdgpu_vram_mgr.c")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index a99d196b05df,a52e17ed3df6..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@@ -162,74 -181,6 +181,10 @@@ static struct attribute *amdgpu_vram_mg
NULL
  };
  
 +const struct attribute_group amdgpu_vram_mgr_attr_group = {
 +  .attrs = amdgpu_vram_mgr_attributes
 +};
 +
- static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
- 
- /**
-  * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
-  *
-  * @adev: amdgpu_device pointer
-  *
-  * Allocate and initialize the VRAM manager.
-  */
- int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
- {
-   struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;
-   struct ttm_resource_manager *man = &mgr->manager;
- 
-   ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
- 
-   man->func = &amdgpu_vram_mgr_func;
- 
-   drm_mm_init(&mgr->mm, 0, man->size);
-   spin_lock_init(&mgr->lock);
-   INIT_LIST_HEAD(&mgr->reservations_pending);
-   INIT_LIST_HEAD(&mgr->reserved_pages);
- 
-   ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
-   ttm_resource_manager_set_used(man, true);
-   return 0;
- }
- 
- /**
-  * amdgpu_vram_mgr_fini - free and destroy VRAM manager
-  *
-  * @adev: amdgpu_device pointer
-  *
-  * Destroy and free the VRAM manager, returns -EBUSY if ranges are still
-  * allocated inside it.
-  */
- void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
- {
-   struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;
-   struct ttm_resource_manager *man = &mgr->manager;
-   int ret;
-   struct amdgpu_vram_reservation *rsv, *temp;
- 
-   ttm_resource_manager_set_used(man, false);
- 
-   ret = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
-   if (ret)
-   return;
- 
-   spin_lock(&mgr->lock);
-   list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, node)
-   kfree(rsv);
- 
-   list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, node) {
-   drm_mm_remove_node(&rsv->mm_node);
-   kfree(rsv);
-   }
-   drm_mm_takedown(&mgr->mm);
-   spin_unlock(&mgr->lock);
- 
-   ttm_resource_manager_cleanup(man);
-   ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
- }
- 
  /**
   * amdgpu_vram_mgr_vis_size - Calculate visible node size
   *
@@@ -444,10 -396,10 +400,10 @@@ static int amdgpu_vram_mgr_new(struct t
pages_per_node = HPAGE_PMD_NR;
  #else
/* default to 2MB */
-   pages_per_node = (2UL << (20UL - PAGE_SHIFT));
+   pages_per_node = 2UL << (20UL - PAGE_SHIFT);
  #endif
-   pages_per_node = max((uint32_t)pages_per_node,
-tbo->page_alignment);
+   pages_per_node = max_t(uint32_t, pages_per_node,
 - mem->page_alignment);
++ tbo->page_alignment);
num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node);
}
  
@@@ -465,38 -417,29 +421,29 @@@
mem->start = 0;
pages_left = mem->num_pages;
  
-   spin_lock(&mgr->lock);
-   for (i = 0; pages_left >= pages_per_node; ++i) {
-   unsigned long pages = rounddown_pow_of_two(pages_left);
- 
-   /* Limit maximum size to 2GB due to SG table limitations */
-   pages = min(pages, (2UL << (30 - PAGE_SHIFT)));
- 
-   r = drm_mm_insert_node_in_range(mm, &nodes[i], pages,
-   pages_per_node, 0,
-   place->fpfn, lpfn,
-   mode);
-   if (unlikely(r))
-   break;
- 
-   vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
-   amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
-   pages_left -= pages;
-   }
+   /* Limit maximum size to 2GB due to SG table limitations */
+   pages = min(pages_left, 2UL << (30 - PAGE_SHIFT));
  
-   for (; 

linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-05-20 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

between commit:

  f89f8c6bafd0 ("drm/amdgpu: Guard against write accesses after device removal")

from the drm-misc tree and commit:

  0ccc3ccf5b3a ("drm/amdgpu: re-apply "use the new cursor in the VM code" v2")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 90c34491f85d,57a6ad04118c..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@@ -1594,23 -1618,21 +1620,24 @@@ static int amdgpu_vm_update_ptes(struc
   * Returns:
   * 0 for success, -EINVAL for failure.
   */
- static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
-  struct amdgpu_device *bo_adev,
-  struct amdgpu_vm *vm, bool immediate,
-  bool unlocked, struct dma_resv *resv,
-  uint64_t start, uint64_t last,
-  uint64_t flags, uint64_t offset,
-  struct drm_mm_node *nodes,
-  dma_addr_t *pages_addr,
-  struct dma_fence **fence)
+ int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
+   struct amdgpu_device *bo_adev,
+   struct amdgpu_vm *vm, bool immediate,
+   bool unlocked, struct dma_resv *resv,
+   uint64_t start, uint64_t last,
+   uint64_t flags, uint64_t offset,
+   struct ttm_resource *res,
+   dma_addr_t *pages_addr,
+   struct dma_fence **fence,
+   bool *table_freed)
  {
struct amdgpu_vm_update_params params;
+   struct amdgpu_res_cursor cursor;
enum amdgpu_sync_mode sync_mode;
-   uint64_t pfn;
 -  int r;
 +  int r, idx;
 +
 +  if (!drm_dev_enter(&adev->ddev, &idx))
 +  return -ENODEV;
  
memset(¶ms, 0, sizeof(params));
params.adev = adev;
@@@ -1717,9 -1722,11 +1727,12 @@@
  
r = vm->update_funcs->commit(¶ms, fence);
  
+   if (table_freed)
+   *table_freed = params.table_freed;
+ 
  error_unlock:
amdgpu_vm_eviction_unlock(vm);
 +  drm_dev_exit(idx);
return r;
  }
  


pgpVaLtLGjXFd.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-05-20 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

between commit:

  35bba8313b95 ("drm/amdgpu: Convert driver sysfs attributes to static 
attributes")

from the drm-misc tree and commit:

  a614b336f1c1 ("drm/amdgpu: fix coding style and documentation in 
amdgpu_gtt_mgr.c")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index a4404da8ca6d,8860545344c7..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@@ -75,75 -80,6 +80,16 @@@ static DEVICE_ATTR(mem_info_gtt_total, 
  static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
   amdgpu_mem_info_gtt_used_show, NULL);
  
 +static struct attribute *amdgpu_gtt_mgr_attributes[] = {
 +  &dev_attr_mem_info_gtt_total.attr,
 +  &dev_attr_mem_info_gtt_used.attr,
 +  NULL
 +};
 +
 +const struct attribute_group amdgpu_gtt_mgr_attr_group = {
 +  .attrs = amdgpu_gtt_mgr_attributes
 +};
 +
- static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
- /**
-  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
-  *
-  * @adev: amdgpu_device pointer
-  * @gtt_size: maximum size of GTT
-  *
-  * Allocate and initialize the GTT manager.
-  */
- int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
- {
-   struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
-   struct ttm_resource_manager *man = &mgr->manager;
-   uint64_t start, size;
- 
-   man->use_tt = true;
-   man->func = &amdgpu_gtt_mgr_func;
- 
-   ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
- 
-   start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
-   size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
-   drm_mm_init(&mgr->mm, start, size);
-   spin_lock_init(&mgr->lock);
-   atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
- 
-   ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
-   ttm_resource_manager_set_used(man, true);
-   return 0;
- }
- 
- /**
-  * amdgpu_gtt_mgr_fini - free and destroy GTT manager
-  *
-  * @adev: amdgpu_device pointer
-  *
-  * Destroy and free the GTT manager, returns -EBUSY if ranges are still
-  * allocated inside it.
-  */
- void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
- {
-   struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
-   struct ttm_resource_manager *man = &mgr->manager;
-   int ret;
- 
-   ttm_resource_manager_set_used(man, false);
- 
-   ret = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
-   if (ret)
-   return;
- 
-   spin_lock(&mgr->lock);
-   drm_mm_takedown(&mgr->mm);
-   spin_unlock(&mgr->lock);
- 
-   ttm_resource_manager_cleanup(man);
-   ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
- }
- 
  /**
   * amdgpu_gtt_mgr_has_gart_addr - Check if mem has address space
   *
@@@ -306,3 -249,76 +259,61 @@@ static const struct ttm_resource_manage
.free = amdgpu_gtt_mgr_del,
.debug = amdgpu_gtt_mgr_debug
  };
+ 
+ /**
+  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
+  *
+  * @adev: amdgpu_device pointer
+  * @gtt_size: maximum size of GTT
+  *
+  * Allocate and initialize the GTT manager.
+  */
+ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
+ {
+   struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
+   struct ttm_resource_manager *man = &mgr->manager;
+   uint64_t start, size;
 -  int ret;
+ 
+   man->use_tt = true;
+   man->func = &amdgpu_gtt_mgr_func;
+ 
+   ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
+ 
+   start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
+   size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
+   drm_mm_init(&mgr->mm, start, size);
+   spin_lock_init(&mgr->lock);
+   atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
+ 
 -  ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
 -  if (ret) {
 -  DRM_ERROR("Failed to create device file mem_info_gtt_total\n");
 -  return ret;
 -  }
 -  ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_used);
 -  if (ret) {
 -  DRM_ERROR("Failed to create device file mem_info_gtt_used\n");
 -  return ret;
 -  }
 -
+   ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
+   ttm_resource_manager_set_used(man, true);
+   return 0;
+ }
+ 
+ /**
+  * amdgpu_gtt_mgr_fini - free and destro

linux-next: manual merge of the amdgpu tree with the drm-misc tree

2021-05-11 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

between commit:

  c777dc9e7933 ("drm/ttm: move the page_alignment into the BO v2")

from the drm-misc tree and commit:

  dd03daec0ff1 ("drm/amdgpu: restructure amdgpu_vram_mgr_new")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index f7235438535f,e2cbe19404c0..
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@@ -448,10 -391,10 +391,10 @@@ static int amdgpu_vram_mgr_new(struct t
pages_per_node = HPAGE_PMD_NR;
  #else
/* default to 2MB */
-   pages_per_node = (2UL << (20UL - PAGE_SHIFT));
+   pages_per_node = 2UL << (20UL - PAGE_SHIFT);
  #endif
-   pages_per_node = max((uint32_t)pages_per_node,
-tbo->page_alignment);
+   pages_per_node = max_t(uint32_t, pages_per_node,
 - mem->page_alignment);
++ tbo->page_alignment);
num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node);
}
  
@@@ -469,38 -412,29 +412,29 @@@
mem->start = 0;
pages_left = mem->num_pages;
  
-   spin_lock(&mgr->lock);
-   for (i = 0; pages_left >= pages_per_node; ++i) {
-   unsigned long pages = rounddown_pow_of_two(pages_left);
+   /* Limit maximum size to 2GB due to SG table limitations */
+   pages = min(pages_left, 2UL << (30 - PAGE_SHIFT));
  
-   /* Limit maximum size to 2GB due to SG table limitations */
-   pages = min(pages, (2UL << (30 - PAGE_SHIFT)));
- 
-   r = drm_mm_insert_node_in_range(mm, &nodes[i], pages,
-   pages_per_node, 0,
-   place->fpfn, lpfn,
-   mode);
-   if (unlikely(r))
-   break;
- 
-   vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
-   amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
-   pages_left -= pages;
-   }
- 
-   for (; pages_left; ++i) {
-   unsigned long pages = min(pages_left, pages_per_node);
+   i = 0;
+   spin_lock(&mgr->lock);
+   while (pages_left) {
 -  uint32_t alignment = mem->page_alignment;
 +  uint32_t alignment = tbo->page_alignment;
  
-   if (pages == pages_per_node)
+   if (pages >= pages_per_node)
alignment = pages_per_node;
  
-   r = drm_mm_insert_node_in_range(mm, &nodes[i],
-   pages, alignment, 0,
-   place->fpfn, lpfn,
-   mode);
-   if (unlikely(r))
+   r = drm_mm_insert_node_in_range(mm, &nodes[i], pages, alignment,
+   0, place->fpfn, lpfn, mode);
+   if (unlikely(r)) {
+   if (pages > pages_per_node) {
+   if (is_power_of_2(pages))
+   pages = pages / 2;
+   else
+   pages = rounddown_pow_of_two(pages);
+   continue;
+   }
goto error;
+   }
  
vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
amdgpu_vram_mgr_virt_start(mem, &nodes[i]);


pgpxc9ZLjozxw.pgp
Description: OpenPGP digital signature