Am 24.07.19 um 16:10 schrieb Andrey Grodzovsky: > Move the logic to clear AMDGPU_GEM_CREATE_CPU_GTT_USWC in > amdgpu_bo_do_create into standalone helper so it can be reused > in other functions. > > Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@xxxxxxx> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 63 +++++++++++++++++------------- > drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 + > 2 files changed, 38 insertions(+), 27 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > index 989b7b5..64c45bc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > @@ -413,6 +413,41 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, > return false; > } > > +void amdgpu_bo_validate_uswc(u64 *bo_flags) Better return bool here instead of modifying the flag. Christian. > +{ > + u64 flags = *bo_flags; > + > +#ifdef CONFIG_X86_32 > + /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit > + * See https://bugs.freedesktop.org/show_bug.cgi?id=84627 > + */ > + flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > +#elif defined(CONFIG_X86) && !defined(CONFIG_X86_PAT) > + /* Don't try to enable write-combining when it can't work, or things > + * may be slow > + * See https://bugs.freedesktop.org/show_bug.cgi?id=88758 > + */ > + > +#ifndef CONFIG_COMPILE_TEST > +#warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance \ > + thanks to write-combining > +#endif > + > + if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) > + DRM_INFO_ONCE("Please enable CONFIG_MTRR and CONFIG_X86_PAT for " > + "better performance thanks to write-combining\n"); > + flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > +#else > + /* For architectures that don't support WC memory, > + * mask out the WC flag from the BO > + */ > + if (!drm_arch_can_wc_memory()) > + flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > +#endif > + > + *bo_flags = flags; > +} > + > static int amdgpu_bo_do_create(struct amdgpu_device *adev, > struct amdgpu_bo_param *bp, > struct amdgpu_bo **bo_ptr) > @@ -466,33 +501,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, > > bo->flags = bp->flags; > > -#ifdef CONFIG_X86_32 > - /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit > - * See https://bugs.freedesktop.org/show_bug.cgi?id=84627 > - */ > - bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > -#elif defined(CONFIG_X86) && !defined(CONFIG_X86_PAT) > - /* Don't try to enable write-combining when it can't work, or things > - * may be slow > - * See https://bugs.freedesktop.org/show_bug.cgi?id=88758 > - */ > - > -#ifndef CONFIG_COMPILE_TEST > -#warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance \ > - thanks to write-combining > -#endif > - > - if (bo->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) > - DRM_INFO_ONCE("Please enable CONFIG_MTRR and CONFIG_X86_PAT for " > - "better performance thanks to write-combining\n"); > - bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > -#else > - /* For architectures that don't support WC memory, > - * mask out the WC flag from the BO > - */ > - if (!drm_arch_can_wc_memory()) > - bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; > -#endif > + amdgpu_bo_validate_uswc(&bo->flags); > > bo->tbo.bdev = &adev->mman.bdev; > if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA | > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > index d60593c..07832e8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h > @@ -308,5 +308,7 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager, > struct seq_file *m); > #endif > > +void amdgpu_bo_validate_uswc(u64 *bo_flags); > + > > #endif _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx