RE: [PATCH v2 1/2] drm/amdgpu: separate ras irq from vcn instance irq for UVD_POISON
[AMD Official Use Only - General] Thank you for your suggestion, I will split these two patches in the next version. Regards, Horatio -Original Message- From: Zhou1, Tao Sent: Monday, May 15, 2023 2:38 PM To: Zhang, Horatio ; amd-gfx@lists.freedesktop.org Cc: Zhang, Hawking ; Xu, Feifei ; Liu, Leo ; Jiang, Sonny ; Limonciello, Mario ; Liu, HaoPing (Alan) ; Zhou, Bob ; Zhang, Horatio ; Zhang, Hawking Subject: RE: [PATCH v2 1/2] drm/amdgpu: separate ras irq from vcn instance irq for UVD_POISON [AMD Official Use Only - General] The code is fine with me, but it's better to split the patch into three parts, one is for common vcn code, one is for vcn 2.6 and the third one is for vcn 4.0. Regards, Tao > -Original Message- > From: Horatio Zhang > Sent: Monday, May 15, 2023 10:28 AM > To: amd-gfx@lists.freedesktop.org > Cc: Zhang, Hawking ; Zhou1, Tao > ; Xu, Feifei ; Liu, Leo > ; Jiang, Sonny ; Limonciello, > Mario ; Liu, HaoPing (Alan) > ; Zhou, Bob ; Zhang, Horatio > ; Zhang, Hawking > Subject: [PATCH v2 1/2] drm/amdgpu: separate ras irq from vcn instance > irq for UVD_POISON > > Separate RAS poison consumption handling from the instance irq, and > register dedicated ras_poison_irq src and funcs for UVD_POISON. Fix > the amdgpu_irq_put call trace in vcn_v4_0_hw_fini. > > [ 44.563572] RIP: 0010:amdgpu_irq_put+0xa4/0xc0 [amdgpu] > [ 44.563629] RSP: 0018:b36740edfc90 EFLAGS: 00010246 > [ 44.563630] RAX: RBX: 0001 RCX: > > [ 44.563630] RDX: RSI: RDI: > > [ 44.563631] RBP: b36740edfcb0 R08: R09: > > [ 44.563631] R10: R11: R12: > 954c568e2ea8 > [ 44.563631] R13: R14: 954c568c R15: > 954c568e2ea8 > [ 44.563632] FS: () GS:954f584c() > knlGS: > [ 44.563632] CS: 0010 DS: ES: CR0: 80050033 > [ 44.563633] CR2: 7f028741ba70 CR3: 00026ca1 CR4: > 00750ee0 > [ 44.563633] PKRU: 5554 > [ 44.563633] Call Trace: > [ 44.563634] > [ 44.563634] vcn_v4_0_hw_fini+0x62/0x160 [amdgpu] > [ 44.563700] vcn_v4_0_suspend+0x13/0x30 [amdgpu] > [ 44.563755] amdgpu_device_ip_suspend_phase2+0x240/0x470 [amdgpu] > [ 44.563806] amdgpu_device_ip_suspend+0x41/0x80 [amdgpu] > [ 44.563858] amdgpu_device_pre_asic_reset+0xd9/0x4a0 [amdgpu] > [ 44.563909] amdgpu_device_gpu_recover.cold+0x548/0xcf1 [amdgpu] > [ 44.564006] amdgpu_debugfs_reset_work+0x4c/0x80 [amdgpu] > [ 44.564061] process_one_work+0x21f/0x400 > [ 44.564062] worker_thread+0x200/0x3f0 > [ 44.564063] ? process_one_work+0x400/0x400 > [ 44.564064] kthread+0xee/0x120 > [ 44.564065] ? kthread_complete_and_exit+0x20/0x20 > [ 44.564066] ret_from_fork+0x22/0x30 > > Suggested-by: Hawking Zhang > Signed-off-by: Horatio Zhang > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 27 ++- > drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 +++ > drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 24 ++--- > drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 35 - > 4 files changed, 78 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > index e63fcc58e8e0..f53c22db8d25 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > @@ -1181,6 +1181,31 @@ int amdgpu_vcn_process_poison_irq(struct > amdgpu_device *adev, > return 0; > } > > +int amdgpu_vcn_ras_late_init(struct amdgpu_device *adev, struct > +ras_common_if *ras_block) { > + int r, i; > + > + r = amdgpu_ras_block_late_init(adev, ras_block); > + if (r) > + return r; > + > + if (amdgpu_ras_is_supported(adev, ras_block->block)) { > + for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > + if (adev->vcn.harvest_config & (1 << i)) > + continue; > + > + r = amdgpu_irq_get(adev, &adev- > >vcn.inst[i].ras_poison_irq, 0); > + if (r) > + goto late_fini; > + } > + } > + return 0; > + > +late_fini: > + amdgpu_ras_block_late_fini(adev, ras_block); > + return r; > +} > + > int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev) { > int err; > @@ -1202,7 +1227,7 @@ int amdgpu_vcn_ras_sw_init(struct amdgpu_device > *adev) > adev->vcn.ras_if = &ras->ras_block.ras_comm; > > if (!ras->ras_block.ras_late_init) > - ras->ras_block.ras_late_init = amdgpu_ras_block_late_init; > + ras->ras_block.ras_late_init = amdgpu_vcn_ras_late_init; > > return 0; > } > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h > index c730949ece7d..802d4c2edb
[PATCH V2] amd/amdgpu: perform soft reset for sdma fed error
When testing sdma ib ring fails to detect sdma hang for sdma fed error, force to perform soft reset. V2: Add poison mode support check for special code path. Signed-off-by: YiPeng Chai --- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c index 3d9a80511a45..94b1364d743e 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c @@ -53,6 +53,12 @@ MODULE_FIRMWARE("amdgpu/sdma_6_0_3.bin"); #define SDMA0_HYP_DEC_REG_START 0x5880 #define SDMA0_HYP_DEC_REG_END 0x589a #define SDMA1_HYP_DEC_REG_OFFSET 0x20 +#define regRLC_RLCS_FED_STATUS_0 0x4eff +#define regRLC_RLCS_FED_STATUS_0_BASE_IDX1 +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR_MASK0x0040L +#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR_MASK0x0080L +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR__SHIFT 0x6 +#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR__SHIFT 0x7 static void sdma_v6_0_set_ring_funcs(struct amdgpu_device *adev); static void sdma_v6_0_set_buffer_funcs(struct amdgpu_device *adev); @@ -768,6 +774,19 @@ static bool sdma_v6_0_check_soft_reset(void *handle) return true; } + /* Soft reset should be performed for sdma fed error to +* recover sdma engine, so when testing sdma ib ring fails +* to detect sdma hang, force to perform soft reset. +*/ + if (amdgpu_ras_is_poison_mode_supported(adev)) { + uint32_t rlc_status0 = 0; + + rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0); + if (REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA0_FED_ERR) || + REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA1_FED_ERR)) + return true; + } + return false; } -- 2.34.1
RE: [PATCH V2] amd/amdgpu: perform soft reset for sdma fed error
[AMD Official Use Only - General] Reviewed-by: Hawking Zhang Regards, Hawking -Original Message- From: Chai, Thomas Sent: Monday, May 15, 2023 15:17 To: amd-gfx@lists.freedesktop.org Cc: Chai, Thomas ; Zhang, Hawking ; Zhou1, Tao ; Li, Candice ; Yang, Stanley ; Chai, Thomas Subject: [PATCH V2] amd/amdgpu: perform soft reset for sdma fed error When testing sdma ib ring fails to detect sdma hang for sdma fed error, force to perform soft reset. V2: Add poison mode support check for special code path. Signed-off-by: YiPeng Chai --- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c index 3d9a80511a45..94b1364d743e 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c @@ -53,6 +53,12 @@ MODULE_FIRMWARE("amdgpu/sdma_6_0_3.bin"); #define SDMA0_HYP_DEC_REG_START 0x5880 #define SDMA0_HYP_DEC_REG_END 0x589a #define SDMA1_HYP_DEC_REG_OFFSET 0x20 +#define regRLC_RLCS_FED_STATUS_0 0x4eff +#define regRLC_RLCS_FED_STATUS_0_BASE_IDX1 +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR_MASK0x0040L +#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR_MASK0x0080L +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR__SHIFT 0x6 #define +RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR__SHIFT 0x7 static void sdma_v6_0_set_ring_funcs(struct amdgpu_device *adev); static void sdma_v6_0_set_buffer_funcs(struct amdgpu_device *adev); @@ -768,6 +774,19 @@ static bool sdma_v6_0_check_soft_reset(void *handle) return true; } + /* Soft reset should be performed for sdma fed error to +* recover sdma engine, so when testing sdma ib ring fails +* to detect sdma hang, force to perform soft reset. +*/ + if (amdgpu_ras_is_poison_mode_supported(adev)) { + uint32_t rlc_status0 = 0; + + rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0); + if (REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA0_FED_ERR) || + REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA1_FED_ERR)) + return true; + } + return false; } -- 2.34.1
[PATCH] drm/amdgpu: remove unnecessary (void*) conversions
No need cast (void*) to (struct amdgpu_device *). Signed-off-by: Su Hui --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index f60753f97ac5..c837e0bf2cfc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -1470,7 +1470,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; struct drm_device *dev = adev_to_drm(adev); int r = 0, i; @@ -1581,7 +1581,7 @@ static int amdgpu_debugfs_benchmark(void *data, u64 val) static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; struct drm_device *dev = adev_to_drm(adev); struct drm_file *file; int r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index f52d0ba91a77..f0615a43b3cc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -835,7 +835,7 @@ static const struct dma_fence_ops amdgpu_job_fence_ops = { #if defined(CONFIG_DEBUG_FS) static int amdgpu_debugfs_fence_info_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; int i; for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 863cb668e000..28f79cf8c3fb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -948,7 +948,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, #if defined(CONFIG_DEBUG_FS) static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; struct drm_device *dev = adev_to_drm(adev); struct drm_file *file; int r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index 4ff348e10e4d..49a4238a120e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -436,7 +436,7 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) static int amdgpu_debugfs_sa_info_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; seq_printf(m, "- DELAYED - \n"); amdgpu_sa_bo_dump_debug_info(&adev->ib_pools[AMDGPU_IB_POOL_DELAYED], diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 0efb38539d70..9f9274249b57 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -1441,7 +1441,7 @@ void amdgpu_disable_vblank_kms(struct drm_crtc *crtc) static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; struct drm_amdgpu_info_firmware fw_info; struct drm_amdgpu_query_fw query_fw; struct atom_context *ctx = adev->mode_info.atom_context; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 2cd081cbf706..21f340ed4cca 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2164,7 +2164,7 @@ int amdgpu_ttm_evict_resources(struct amdgpu_device *adev, int mem_type) static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused) { - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; + struct amdgpu_device *adev = m->private; return ttm_pool_debugfs(&adev->mman.bdev.pool, m); } -- 2.30.2
Re: [PATCH] drm/amdgpu: remove unnecessary (void*) conversions
On Mon, May 15, 2023 at 09:34:28AM +0800, Su Hui wrote: > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > index f60753f97ac5..c837e0bf2cfc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > @@ -1470,7 +1470,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) > > static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > struct drm_device *dev = adev_to_drm(adev); > int r = 0, i; > This declaration block was originally written in reverse Christmas tree order: long long long variable name; medium length name; short name; So you probably want to change the order now that the lengths have changed. Same in the other places as well. regards, dan carpenter
[PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
No invocation of get_user_pages() use the vmas parameter, so remove it. The GUP API is confusing and caveated. Recent changes have done much to improve that, however there is more we can do. Exporting vmas is a prime target as the caller has to be extremely careful to preclude their use after the mmap_lock has expired or otherwise be left with dangling pointers. Removing the vmas parameter focuses the GUP functions upon their primary purpose - pinning (and outputting) pages as well as performing the actions implied by the input flags. This is part of a patch series aiming to remove the vmas parameter altogether. Suggested-by: Matthew Wilcox (Oracle) Acked-by: Greg Kroah-Hartman Acked-by: David Hildenbrand Reviewed-by: Jason Gunthorpe Acked-by: Christian König (for radeon parts) Acked-by: Jarkko Sakkinen Signed-off-by: Lorenzo Stoakes --- arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/misc/sgi-gru/grufault.c | 2 +- include/linux/mm.h | 3 +-- mm/gup.c| 9 +++-- mm/gup_test.c | 5 ++--- virt/kvm/kvm_main.c | 2 +- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index 21ca0a831b70..5d390df21440 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -214,7 +214,7 @@ static int __sgx_encl_add_page(struct sgx_encl *encl, if (!(vma->vm_flags & VM_MAYEXEC)) return -EACCES; - ret = get_user_pages(src, 1, 0, &src_page, NULL); + ret = get_user_pages(src, 1, 0, &src_page); if (ret < 1) return -EFAULT; diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 2220cdf6a3f6..3a9db030f98f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -359,7 +359,7 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_device *bdev, struct ttm_tt *ttm struct page **pages = ttm->pages + pinned; r = get_user_pages(userptr, num_pages, write ? FOLL_WRITE : 0, - pages, NULL); + pages); if (r < 0) goto release_pages; diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c index b836936e9747..378cf02a2aa1 100644 --- a/drivers/misc/sgi-gru/grufault.c +++ b/drivers/misc/sgi-gru/grufault.c @@ -185,7 +185,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma, #else *pageshift = PAGE_SHIFT; #endif - if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0) + if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page) <= 0) return -EFAULT; *paddr = page_to_phys(page); put_page(page); diff --git a/include/linux/mm.h b/include/linux/mm.h index db3f66ed2f32..2c1a92bf5626 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2382,8 +2382,7 @@ long pin_user_pages_remote(struct mm_struct *mm, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas, int *locked); long get_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas); + unsigned int gup_flags, struct page **pages); long pin_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas); diff --git a/mm/gup.c b/mm/gup.c index 90d9b65ff35c..b8189396f435 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2294,8 +2294,6 @@ long get_user_pages_remote(struct mm_struct *mm, * @pages: array that receives pointers to the pages pinned. * Should be at least nr_pages long. Or NULL, if caller * only intends to ensure the pages are faulted in. - * @vmas: array of pointers to vmas corresponding to each page. - * Or NULL if the caller does not require them. * * This is the same as get_user_pages_remote(), just with a less-flexible * calling convention where we assume that the mm being operated on belongs to @@ -2303,16 +2301,15 @@ long get_user_pages_remote(struct mm_struct *mm, * obviously don't pass FOLL_REMOTE in here. */ long get_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas) + unsigned int gup_flags, struct page **pages) { int locked = 1; - if (!is_valid_gup_args(pages, vmas, NULL, &gup_flags, FOLL_TOUCH)) + if (!is_valid_gup_args(pages, NULL, NULL, &gup_flags, FOLL_TOUCH)) return -EINVAL; return __g
[PATCH v2 03/12] drm/exynos: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Exynos does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_IO_HELPERS option Signed-off-by: Thomas Zimmermann Cc: Inki Dae Cc: Seung-Woo Kim Cc: Kyungmin Park Cc: Krzysztof Kozlowski Cc: Alim Akhtar --- drivers/gpu/drm/exynos/Kconfig| 1 + drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 10 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index 0cb92d651ff1..7ca7e1dab52c 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig @@ -7,6 +7,7 @@ config DRM_EXYNOS select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP select DRM_KMS_HELPER select VIDEOMODE_HELPERS + select FB_IO_HELPERS if DRM_FBDEV_EMULATION select SND_SOC_HDMI_CODEC if SND_SOC help Choose this option if you have a Samsung SoC Exynos chipset. diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile index 2fd2f3ee4fcf..233a66036584 100644 --- a/drivers/gpu/drm/exynos/Makefile +++ b/drivers/gpu/drm/exynos/Makefile @@ -6,7 +6,6 @@ exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o -exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD)+= exynos_drm_fimd.o exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON) += exynos7_drm_decon.o @@ -23,5 +22,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)+= exynos_drm_rotator.o exynosdrm-$(CONFIG_DRM_EXYNOS_SCALER) += exynos_drm_scaler.o exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o exynosdrm-$(CONFIG_DRM_EXYNOS_MIC) += exynos_drm_mic.o +exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION)+= exynos_drm_fbdev.o obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index ea4b3d248aac..bdd1d087 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -8,6 +8,8 @@ * Seung-Woo Kim */ +#include + #include #include #include @@ -49,11 +51,9 @@ static const struct fb_ops exynos_drm_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, .fb_mmap= exynos_drm_fb_mmap, - .fb_read= drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect= drm_fb_helper_cfb_fillrect, - .fb_copyarea= drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_fillrect= cfb_fillrect, + .fb_copyarea= cfb_copyarea, + .fb_imageblit = cfb_imageblit, .fb_destroy = exynos_drm_fb_destroy, }; -- 2.40.1
[PATCH v2 01/12] fbdev: Add Kconfig options to select different fb_ops helpers
Many fbdev drivers use the same set of fb_ops helpers. Add Kconfig options to select them at once. This will help with making DRM's fbdev emulation code more modular, but can also be used to simplify fbdev's driver configs. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/Kconfig | 21 + 1 file changed, 21 insertions(+) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 485e8c35d5c6..d5ca66f10d1c 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -158,6 +158,27 @@ config FB_DEFERRED_IO bool depends on FB +config FB_IO_HELPERS + bool + depends on FB + select FB_CFB_COPYAREA + select FB_CFB_FILLRECT + select FB_CFB_IMAGEBLIT + +config FB_SYS_HELPERS + bool + depends on FB + select FB_SYS_COPYAREA + select FB_SYS_FILLRECT + select FB_SYS_FOPS + select FB_SYS_IMAGEBLIT + +config FB_SYS_HELPERS_DEFERRED + bool + depends on FB + select FB_DEFERRED_IO + select FB_SYS_HELPER + config FB_HECUBA tristate depends on FB -- 2.40.1
[PATCH v2 02/12] drm/armada: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Armada does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_IO_HELPERS option Signed-off-by: Thomas Zimmermann Cc: Russell King --- drivers/gpu/drm/armada/Kconfig| 1 + drivers/gpu/drm/armada/armada_fbdev.c | 9 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig index f5c66d89ba99..5afade25e217 100644 --- a/drivers/gpu/drm/armada/Kconfig +++ b/drivers/gpu/drm/armada/Kconfig @@ -3,6 +3,7 @@ config DRM_ARMADA tristate "DRM support for Marvell Armada SoCs" depends on DRM && HAVE_CLK && ARM && MMU select DRM_KMS_HELPER + select FB_IO_HELPERS if DRM_FBDEV_EMULATION help Support the "LCD" controllers found on the Marvell Armada 510 devices. There are two controllers on the device, each controller diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index 0a5fd1aa86eb..6c3bbaf53569 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info) static const struct fb_ops armada_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, - .fb_read= drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect= drm_fb_helper_cfb_fillrect, - .fb_copyarea= drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_fillrect= cfb_fillrect, + .fb_copyarea= cfb_copyarea, + .fb_imageblit = cfb_imageblit, .fb_destroy = armada_fbdev_fb_destroy, }; -- 2.40.1
[PATCH v2 04/12] drm/gma500: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Gma500 does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_IO_HELPERS option Signed-off-by: Thomas Zimmermann Cc: Patrik Jakobsson --- drivers/gpu/drm/gma500/Kconfig | 1 + drivers/gpu/drm/gma500/fbdev.c | 9 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig index 2efc0eb41c64..cd3d92725ed4 100644 --- a/drivers/gpu/drm/gma500/Kconfig +++ b/drivers/gpu/drm/gma500/Kconfig @@ -3,6 +3,7 @@ config DRM_GMA500 tristate "Intel GMA500/600/3600/3650 KMS Framebuffer" depends on DRM && PCI && X86 && MMU select DRM_KMS_HELPER + select FB_IO_HELPERS if DRM_FBDEV_EMULATION select I2C select I2C_ALGOBIT # GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915 diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c index 62287407e717..60005c3d01d0 100644 --- a/drivers/gpu/drm/gma500/fbdev.c +++ b/drivers/gpu/drm/gma500/fbdev.c @@ -5,6 +5,7 @@ * **/ +#include #include #include @@ -136,11 +137,9 @@ static const struct fb_ops psb_fbdev_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, .fb_setcolreg = psb_fbdev_fb_setcolreg, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, .fb_mmap = psb_fbdev_fb_mmap, .fb_destroy = psb_fbdev_fb_destroy, }; -- 2.40.1
[PATCH v2 05/12] drm/radeon: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Radeon does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_IO_HELPERS option Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" --- drivers/gpu/drm/radeon/Kconfig| 1 + drivers/gpu/drm/radeon/radeon_fbdev.c | 9 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/radeon/Kconfig b/drivers/gpu/drm/radeon/Kconfig index e19d77d58810..fe498c8af1bb 100644 --- a/drivers/gpu/drm/radeon/Kconfig +++ b/drivers/gpu/drm/radeon/Kconfig @@ -11,6 +11,7 @@ config DRM_RADEON select DRM_SUBALLOC_HELPER select DRM_TTM select DRM_TTM_HELPER + select FB_IO_HELPERS if DRM_FBDEV_EMULATION select SND_HDA_COMPONENT if SND_HDA_CORE select POWER_SUPPLY select HWMON diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c b/drivers/gpu/drm/radeon/radeon_fbdev.c index fe76e29910ef..dcabe527f9c0 100644 --- a/drivers/gpu/drm/radeon/radeon_fbdev.c +++ b/drivers/gpu/drm/radeon/radeon_fbdev.c @@ -24,6 +24,7 @@ * David Airlie */ +#include #include #include #include @@ -193,11 +194,9 @@ static const struct fb_ops radeon_fbdev_fb_ops = { DRM_FB_HELPER_DEFAULT_OPS, .fb_open = radeon_fbdev_fb_open, .fb_release = radeon_fbdev_fb_release, - .fb_read = drm_fb_helper_cfb_read, - .fb_write = drm_fb_helper_cfb_write, - .fb_fillrect = drm_fb_helper_cfb_fillrect, - .fb_copyarea = drm_fb_helper_cfb_copyarea, - .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, .fb_destroy = radeon_fbdev_fb_destroy, }; -- 2.40.1
[PATCH v2 08/12] drm/omapdrm: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Omapdrm does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_SYS_HELPERS option Signed-off-by: Thomas Zimmermann Cc: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/Kconfig | 1 + drivers/gpu/drm/omapdrm/omap_fbdev.c | 12 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig index 76ded1568bd0..b4ac76c9f31b 100644 --- a/drivers/gpu/drm/omapdrm/Kconfig +++ b/drivers/gpu/drm/omapdrm/Kconfig @@ -4,6 +4,7 @@ config DRM_OMAP depends on DRM && OF depends on ARCH_OMAP2PLUS select DRM_KMS_HELPER + select FB_SYS_HELPERS if DRM_FBDEV_EMULATION select VIDEOMODE_HELPERS select HDMI default n diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index b950e93b3846..55a65b81ccdc 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -4,6 +4,8 @@ * Author: Rob Clark */ +#include + #include #include #include @@ -103,11 +105,11 @@ static const struct fb_ops omap_fb_ops = { .fb_pan_display = omap_fbdev_pan_display, .fb_ioctl = drm_fb_helper_ioctl, - .fb_read = drm_fb_helper_sys_read, - .fb_write = drm_fb_helper_sys_write, - .fb_fillrect = drm_fb_helper_sys_fillrect, - .fb_copyarea = drm_fb_helper_sys_copyarea, - .fb_imageblit = drm_fb_helper_sys_imageblit, + .fb_read = fb_sys_read, + .fb_write = fb_sys_write, + .fb_fillrect = sys_fillrect, + .fb_copyarea = sys_copyarea, + .fb_imageblit = sys_imageblit, .fb_destroy = omap_fbdev_fb_destroy, }; -- 2.40.1
[PATCH v2 06/12] drm/fbdev-dma: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Fbdev-dma does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_SYS_HELPERS option Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/drm_fbdev_dma.c | 12 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index ba3fb04bb691..77fb10ddd8a2 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -223,6 +223,7 @@ config DRM_TTM_HELPER config DRM_GEM_DMA_HELPER tristate depends on DRM + select FB_SYS_HELPERS if DRM_FBDEV_EMULATION help Choose this if you need the GEM DMA helper functions diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c index 728deffcc0d9..09a36dc38c43 100644 --- a/drivers/gpu/drm/drm_fbdev_dma.c +++ b/drivers/gpu/drm/drm_fbdev_dma.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT +#include + #include #include #include @@ -64,12 +66,12 @@ static const struct fb_ops drm_fbdev_dma_fb_ops = { .owner = THIS_MODULE, .fb_open = drm_fbdev_dma_fb_open, .fb_release = drm_fbdev_dma_fb_release, - .fb_read = drm_fb_helper_sys_read, - .fb_write = drm_fb_helper_sys_write, + .fb_read = fb_sys_read, + .fb_write = fb_sys_write, DRM_FB_HELPER_DEFAULT_OPS, - .fb_fillrect = drm_fb_helper_sys_fillrect, - .fb_copyarea = drm_fb_helper_sys_copyarea, - .fb_imageblit = drm_fb_helper_sys_imageblit, + .fb_fillrect = sys_fillrect, + .fb_copyarea = sys_copyarea, + .fb_imageblit = sys_imageblit, .fb_destroy = drm_fbdev_dma_fb_destroy, .fb_mmap = drm_fbdev_dma_fb_mmap, }; -- 2.40.1
[PATCH v2 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers
Implement dedicated fbdev helpers for framebuffer I/O instead of using DRM's helpers. Fbdev-generic was the only caller of the DRM helpers, so remove them from the helper module. v2: * use FB_SYS_HELPERS_DEFERRED option Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/Kconfig | 6 +- drivers/gpu/drm/drm_fb_helper.c | 107 drivers/gpu/drm/drm_fbdev_generic.c | 47 ++-- include/drm/drm_fb_helper.h | 41 --- 4 files changed, 43 insertions(+), 158 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 77fb10ddd8a2..92a782827b7b 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -95,6 +95,7 @@ config DRM_KUNIT_TEST config DRM_KMS_HELPER tristate depends on DRM + select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION help CRTC helpers for KMS drivers. @@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_DEFERRED_IO - select FB_SYS_FOPS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT select FRAMEBUFFER_CONSOLE if !EXPERT select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE default y diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 8724e08c518b..ba0a808f14ee 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); -/** - * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory - * @info: fb_info struct pointer - * @buf: userspace buffer to read from framebuffer memory - * @count: number of bytes to read from framebuffer memory - * @ppos: read offset within framebuffer memory - * - * Returns: - * The number of bytes read on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf, - size_t count, loff_t *ppos) -{ - return fb_sys_read(info, buf, count, ppos); -} -EXPORT_SYMBOL(drm_fb_helper_sys_read); - -/** - * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for system memory - * @info: fb_info struct pointer - * @buf: userspace buffer to write to framebuffer memory - * @count: number of bytes to write to framebuffer memory - * @ppos: write offset within framebuffer memory - * - * Returns: - * The number of bytes written on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct drm_fb_helper *helper = info->par; - loff_t pos = *ppos; - ssize_t ret; - struct drm_rect damage_area; - - ret = fb_sys_write(info, buf, count, ppos); - if (ret <= 0) - return ret; - - if (helper->funcs->fb_dirty) { - drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, -drm_rect_width(&damage_area), -drm_rect_height(&damage_area)); - } - - return ret; -} -EXPORT_SYMBOL(drm_fb_helper_sys_write); - -/** - * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect - * @info: fbdev registered by the helper - * @rect: info about rectangle to fill - * - * A wrapper around sys_fillrect implemented by fbdev core - */ -void drm_fb_helper_sys_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{ - struct drm_fb_helper *helper = info->par; - - sys_fillrect(info, rect); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); -} -EXPORT_SYMBOL(drm_fb_helper_sys_fillrect); - -/** - * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea - * @info: fbdev registered by the helper - * @area: info about area to copy - * - * A wrapper around sys_copyarea implemented by fbdev core - */ -void drm_fb_helper_sys_copyarea(struct fb_info *info, - const struct fb_copyarea *area) -{ - struct drm_fb_helper *helper = info->par; - - sys_copyarea(info, area); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); -} -EXPORT_SYMBOL(drm_fb_helper_sys_copyarea); - -/** - * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit - * @info: fbdev registered by the helper - * @image: info about image to blit - * - * A wrapper around sys_imageblit implemented by fbdev core - */ -void drm_fb_helper_sys_imageblit(struct fb_info *info, -
[PATCH v2 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O
DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_() and fb_sys_() helpers. The DRM functions don't provide any additional functionality for most DRM drivers. So remove them and call the fbdev I/O helpers directly. The DRM fbdev I/O wrappers were originally added because does not protect its content with CONFIG_FB. DRM fbdev emulation did not build if the config option had been disabled. This has been fixed. For fbdev-generic and i915, the wrappers added support for damage handling. But this is better handled within the two callers, as each is special in its damage handling. Patch 1 adds several internal Kconfig otpions that DRM drivers (and possibly other fbdev code) will use to select the correct set of I/O helpers. Patches 2 to 9 replace the DRM wrappers in a number of fbdev emulations. Patch 10 exports two helpers for damage handling. Patches 11 and 12 update fbdev-generic and i915 with the help of the exported functions. The patches also remove DRM's fbdev I/O helpers, which are now unused. DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for system memory. Each fbdev emulation now selects the correct helpers for itself. Depending on the selected DRM drivers, kernel builds will now only contain the necessary fbdev I/O helpers and might be slightly smaller in size. v2: * simplify Kconfig handling (Sam) Thomas Zimmermann (12): fbdev: Add Kconfig options to select different fb_ops helpers drm/armada: Use regular fbdev I/O helpers drm/exynos: Use regular fbdev I/O helpers drm/gma500: Use regular fbdev I/O helpers drm/radeon: Use regular fbdev I/O helpers drm/fbdev-dma: Use regular fbdev I/O helpers drm/msm: Use regular fbdev I/O helpers drm/omapdrm: Use regular fbdev I/O helpers drm/tegra: Use regular fbdev I/O helpers drm/fb-helper: Export helpers for marking damage areas drm/fbdev-generic: Implement dedicated fbdev I/O helpers drm/i915: Implement dedicated fbdev I/O helpers drivers/gpu/drm/Kconfig| 10 +- drivers/gpu/drm/armada/Kconfig | 1 + drivers/gpu/drm/armada/armada_fbdev.c | 9 +- drivers/gpu/drm/drm_fb_helper.c| 233 ++--- drivers/gpu/drm/drm_fbdev_dma.c| 12 +- drivers/gpu/drm/drm_fbdev_generic.c| 47 - drivers/gpu/drm/exynos/Kconfig | 1 + drivers/gpu/drm/exynos/Makefile| 2 +- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 10 +- drivers/gpu/drm/gma500/Kconfig | 1 + drivers/gpu/drm/gma500/fbdev.c | 9 +- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/display/intel_fbdev.c | 51 - drivers/gpu/drm/msm/Kconfig| 1 + drivers/gpu/drm/msm/msm_fbdev.c| 12 +- drivers/gpu/drm/omapdrm/Kconfig| 1 + drivers/gpu/drm/omapdrm/omap_fbdev.c | 12 +- drivers/gpu/drm/radeon/Kconfig | 1 + drivers/gpu/drm/radeon/radeon_fbdev.c | 9 +- drivers/gpu/drm/tegra/Kconfig | 1 + drivers/gpu/drm/tegra/fbdev.c | 11 +- drivers/video/fbdev/Kconfig| 21 ++ include/drm/drm_fb_helper.h| 84 +--- 23 files changed, 184 insertions(+), 356 deletions(-) base-commit: 451e49cfbaa90720149e63f4fa9c7824013c783d -- 2.40.1
[PATCH v2 12/12] drm/i915: Implement dedicated fbdev I/O helpers
Implement dedicated fbdev helpers for framebuffer I/O instead of using DRM's helpers. i915 was the only caller of the DRM helpers, so remove them from the helper module. v2: * use FB_IO_HELPERS options Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: "Ville Syrjälä" --- drivers/gpu/drm/Kconfig| 3 - drivers/gpu/drm/drm_fb_helper.c| 107 - drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/display/intel_fbdev.c | 51 -- include/drm/drm_fb_helper.h| 39 5 files changed, 46 insertions(+), 155 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 92a782827b7b..bb2e48cc6cd6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM_KMS_HELPER depends on FB=y || FB=DRM_KMS_HELPER - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT select FRAMEBUFFER_CONSOLE if !EXPERT select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE default y diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index ba0a808f14ee..5927896ad8f6 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); -/** - * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to read from framebuffer memory - * @count: number of bytes to read from framebuffer memory - * @ppos: read offset within framebuffer memory - * - * Returns: - * The number of bytes read on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, - size_t count, loff_t *ppos) -{ - return fb_io_read(info, buf, count, ppos); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_read); - -/** - * drm_fb_helper_cfb_write - Implements struct &fb_ops.fb_write for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to write to framebuffer memory - * @count: number of bytes to write to framebuffer memory - * @ppos: write offset within framebuffer memory - * - * Returns: - * The number of bytes written on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct drm_fb_helper *helper = info->par; - loff_t pos = *ppos; - ssize_t ret; - struct drm_rect damage_area; - - ret = fb_io_write(info, buf, count, ppos); - if (ret <= 0) - return ret; - - if (helper->funcs->fb_dirty) { - drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, -drm_rect_width(&damage_area), -drm_rect_height(&damage_area)); - } - - return ret; -} -EXPORT_SYMBOL(drm_fb_helper_cfb_write); - -/** - * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect - * @info: fbdev registered by the helper - * @rect: info about rectangle to fill - * - * A wrapper around cfb_fillrect implemented by fbdev core - */ -void drm_fb_helper_cfb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{ - struct drm_fb_helper *helper = info->par; - - cfb_fillrect(info, rect); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); - -/** - * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea - * @info: fbdev registered by the helper - * @area: info about area to copy - * - * A wrapper around cfb_copyarea implemented by fbdev core - */ -void drm_fb_helper_cfb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) -{ - struct drm_fb_helper *helper = info->par; - - cfb_copyarea(info, area); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea); - -/** - * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit - * @info: fbdev registered by the helper - * @image: info about image to blit - * - * A wrapper around cfb_imageblit implemented by fbdev core - */ -void drm_fb_helper_cfb_imageblit(struct fb_info *info, -const struct fb_image *image) -{ - struct drm_fb_helper *help
[PATCH v2 07/12] drm/msm: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Msm does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_SYS_HELPERS option Signed-off-by: Thomas Zimmermann Reviewed-by: Dmitry Baryshkov Cc: Rob Clark Cc: Abhinav Kumar Cc: Dmitry Baryshkov Cc: Sean Paul --- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/msm_fbdev.c | 12 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index 85f5ab1d552c..a78662bd6273 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -21,6 +21,7 @@ config DRM_MSM select DRM_BRIDGE select DRM_PANEL_BRIDGE select DRM_SCHED + select FB_SYS_HELPERS if DRM_FBDEV_EMULATION select SHMEM select TMPFS select QCOM_SCM diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 2ebc86381e1c..fc0353a4160e 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -4,6 +4,8 @@ * Author: Rob Clark */ +#include + #include #include #include @@ -57,11 +59,11 @@ static const struct fb_ops msm_fb_ops = { /* Note: to properly handle manual update displays, we wrap the * basic fbdev ops which write to the framebuffer */ - .fb_read = drm_fb_helper_sys_read, - .fb_write = drm_fb_helper_sys_write, - .fb_fillrect = drm_fb_helper_sys_fillrect, - .fb_copyarea = drm_fb_helper_sys_copyarea, - .fb_imageblit = drm_fb_helper_sys_imageblit, + .fb_read = fb_sys_read, + .fb_write = fb_sys_write, + .fb_fillrect = sys_fillrect, + .fb_copyarea = sys_copyarea, + .fb_imageblit = sys_imageblit, .fb_mmap = msm_fbdev_mmap, .fb_destroy = msm_fbdev_fb_destroy, }; -- 2.40.1
[PATCH v2 10/12] drm/fb-helper: Export helpers for marking damage areas
Export drm_fb_helper_damage() and drm_fb_helper_damage_range(), which handle damage areas for fbdev emulation. This is a temporary export that allows to move the DRM I/O helpers for fbdev into drivers. Only fbdev-generic and i915 need them. Both will be updated to implement damage handling by themselves and the exported functions will be removed. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fb_helper.c | 19 +-- include/drm/drm_fb_helper.h | 4 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index f0e9549b6bd7..8724e08c518b 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -625,13 +625,15 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u spin_unlock_irqrestore(&helper->damage_lock, flags); } -static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, -u32 width, u32 height) +/* Don't use in new code. */ +void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, + u32 width, u32 height) { drm_fb_helper_add_damage_clip(helper, x, y, width, height); schedule_work(&helper->damage_work); } +EXPORT_SYMBOL(drm_fb_helper_damage); /* * Convert memory region into area of scanlines and pixels per @@ -670,6 +672,19 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off, drm_rect_init(clip, x1, y1, x2 - x1, y2 - y1); } +/* Don't use in new code. */ +void drm_fb_helper_damage_range(struct drm_fb_helper *fb_helper, off_t off, size_t len) +{ + struct fb_info *info = fb_helper->info; + struct drm_rect damage_area; + + drm_fb_helper_memory_range_to_clip(info, off, len, &damage_area); + drm_fb_helper_damage(fb_helper, damage_area.x1, damage_area.y1, +drm_rect_width(&damage_area), +drm_rect_height(&damage_area)); +} +EXPORT_SYMBOL(drm_fb_helper_damage_range); + /** * drm_fb_helper_deferred_io() - fbdev deferred_io callback function * @info: fb_info struct pointer diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 72032c354a30..80c402f4e379 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -253,6 +253,10 @@ void drm_fb_helper_fill_info(struct fb_info *info, struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes); +void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, + u32 width, u32 height); +void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t len); + void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist); ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf, -- 2.40.1
[PATCH v2 09/12] drm/tegra: Use regular fbdev I/O helpers
Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers. Tegra does not use damage handling, so DRM's fbdev helpers are mere wrappers around the fbdev code. By using fbdev helpers directly within each DRM fbdev emulation, we can eventually remove DRM's wrapper functions entirely. v2: * use FB_SYS_HELPERS option Signed-off-by: Thomas Zimmermann Cc: Thierry Reding Cc: Mikko Perttunen Cc: Jonathan Hunter --- drivers/gpu/drm/tegra/Kconfig | 1 + drivers/gpu/drm/tegra/fbdev.c | 11 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig index 56453ca277c2..498313778175 100644 --- a/drivers/gpu/drm/tegra/Kconfig +++ b/drivers/gpu/drm/tegra/Kconfig @@ -12,6 +12,7 @@ config DRM_TEGRA select DRM_KMS_HELPER select DRM_MIPI_DSI select DRM_PANEL + select FB_SYS_HELPERS if DRM_FBDEV_EMULATION select TEGRA_HOST1X select INTERCONNECT select IOMMU_IOVA diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c index dca9eccae466..144d851e566f 100644 --- a/drivers/gpu/drm/tegra/fbdev.c +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -59,11 +60,11 @@ static void tegra_fbdev_fb_destroy(struct fb_info *info) static const struct fb_ops tegra_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, - .fb_read = drm_fb_helper_sys_read, - .fb_write = drm_fb_helper_sys_write, - .fb_fillrect = drm_fb_helper_sys_fillrect, - .fb_copyarea = drm_fb_helper_sys_copyarea, - .fb_imageblit = drm_fb_helper_sys_imageblit, + .fb_read = fb_sys_read, + .fb_write = fb_sys_write, + .fb_fillrect = sys_fillrect, + .fb_copyarea = sys_copyarea, + .fb_imageblit = sys_imageblit, .fb_mmap = tegra_fb_mmap, .fb_destroy = tegra_fbdev_fb_destroy, }; -- 2.40.1
RE: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM
[AMD Official Use Only - General] The MQD data in VRAM would be lost after S3, for the MQD bo is pinned down as kernel bo and can't be evicted to system memory. AFAIK, driver should not to do allocate/free memory during S3, as there are issues observed to do memory allocation during S3. Regards, Jack -Original Message- From: Alex Deucher Sent: Friday, May 12, 2023 9:13 PM To: Xiao, Jack Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM On Fri, May 12, 2023 at 4:16 AM Jack Xiao wrote: > > Make the preemption optimization effect only for SRIOV, for it caused > failure to resume from S3. Can you elaborate? We ultimately want MQDs in VRAM for performance reasons even for bare metal. Alex > > Signed-off-by: Jack Xiao > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++- > drivers/gpu/drm/amd/amdgpu/mes_v10_1.c | 7 +-- > drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 7 +-- > 3 files changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > index a22d88a4178a..1b795b7bbf38 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > @@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev, > u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > /* Only enable on gfx10 and 11 for now to avoid changing behavior on > older chips */ > - if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0)) > + if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) && > + amdgpu_sriov_vf(adev)) > domain |= AMDGPU_GEM_DOMAIN_VRAM; > > /* create MQD for KIQ */ > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > index 4560476c7c31..5c3d3f6c7ebd 100644 > --- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > @@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct > amdgpu_device *adev, { > int r, mqd_size = sizeof(struct v10_compute_mqd); > struct amdgpu_ring *ring; > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > if (pipe == AMDGPU_MES_KIQ_PIPE) > ring = &adev->gfx.kiq[0].ring; @@ -900,9 +901,11 @@ > static int mes_v10_1_mqd_sw_init(struct amdgpu_device *adev, > if (ring->mqd_obj) > return 0; > > + if (amdgpu_sriov_vf(adev)) > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > + > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > - AMDGPU_GEM_DOMAIN_VRAM | > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > + domain, &ring->mqd_obj, > &ring->mqd_gpu_addr, &ring->mqd_ptr); > if (r) { > dev_warn(adev->dev, "failed to create ring mqd bo > (%d)", r); diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > index 3adb450eec07..79a4d2bfd94a 100644 > --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > @@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct > amdgpu_device *adev, { > int r, mqd_size = sizeof(struct v11_compute_mqd); > struct amdgpu_ring *ring; > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > if (pipe == AMDGPU_MES_KIQ_PIPE) > ring = &adev->gfx.kiq[0].ring; @@ -998,9 +999,11 @@ > static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev, > if (ring->mqd_obj) > return 0; > > + if (amdgpu_sriov_vf(adev)) > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > + > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > - AMDGPU_GEM_DOMAIN_VRAM | > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > + domain, &ring->mqd_obj, > &ring->mqd_gpu_addr, &ring->mqd_ptr); > if (r) { > dev_warn(adev->dev, "failed to create ring mqd bo > (%d)", r); > -- > 2.37.3 >
Re: [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
Looks good: Reviewed-by: Christoph Hellwig
Re: [PATCH AUTOSEL 6.1 4/9] drm/amd/display: Do not set drr on pipe commit
On 5/11/23 21:39, Sasha Levin wrote: > From: Wesley Chalmers > > [ Upstream commit 474f01015ffdb74e01c2eb3584a2822c64e7b2be ] > > [WHY] > Writing to DRR registers such as OTG_V_TOTAL_MIN on the same frame as a > pipe commit can cause underflow. > > [HOW] > Move DMUB p-state delegate into optimze_bandwidth; enabling FAMS sets > optimized_required. > > This change expects that Freesync requests are blocked when > optimized_required is true. This change caused a regression, see https://patchwork.freedesktop.org/patch/532240/?series=116487&rev=1#comment_972234 / 9deeb132-a317-7419-e9da-cbc0a379c...@daenzer.net . -- Earthling Michel Dänzer| https://redhat.com Libre software enthusiast | Mesa and Xwayland developer
Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM
On Mon, May 15, 2023 at 6:40 AM Xiao, Jack wrote: > > [AMD Official Use Only - General] > > The MQD data in VRAM would be lost after S3, for the MQD bo is pinned down > as kernel bo and can't be evicted to system memory. > AFAIK, driver should not to do allocate/free memory during S3, as there are > issues observed to do memory allocation during S3. We restore the contents of the MQD in gfx_v*_0_gfx_init_queue() and gfx_v*_0_kcq_init_queue(). Alex > > Regards, > Jack > > -Original Message- > From: Alex Deucher > Sent: Friday, May 12, 2023 9:13 PM > To: Xiao, Jack > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM > > On Fri, May 12, 2023 at 4:16 AM Jack Xiao wrote: > > > > Make the preemption optimization effect only for SRIOV, for it caused > > failure to resume from S3. > > Can you elaborate? We ultimately want MQDs in VRAM for performance reasons > even for bare metal. > > Alex > > > > > Signed-off-by: Jack Xiao > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++- > > drivers/gpu/drm/amd/amdgpu/mes_v10_1.c | 7 +-- > > drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 7 +-- > > 3 files changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > index a22d88a4178a..1b795b7bbf38 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > @@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev, > > u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > /* Only enable on gfx10 and 11 for now to avoid changing behavior > > on older chips */ > > - if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0)) > > + if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) && > > + amdgpu_sriov_vf(adev)) > > domain |= AMDGPU_GEM_DOMAIN_VRAM; > > > > /* create MQD for KIQ */ > > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > index 4560476c7c31..5c3d3f6c7ebd 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > @@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct > > amdgpu_device *adev, { > > int r, mqd_size = sizeof(struct v10_compute_mqd); > > struct amdgpu_ring *ring; > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > if (pipe == AMDGPU_MES_KIQ_PIPE) > > ring = &adev->gfx.kiq[0].ring; @@ -900,9 +901,11 @@ > > static int mes_v10_1_mqd_sw_init(struct amdgpu_device *adev, > > if (ring->mqd_obj) > > return 0; > > > > + if (amdgpu_sriov_vf(adev)) > > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > > + > > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > > - AMDGPU_GEM_DOMAIN_VRAM | > > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > > + domain, &ring->mqd_obj, > > &ring->mqd_gpu_addr, &ring->mqd_ptr); > > if (r) { > > dev_warn(adev->dev, "failed to create ring mqd bo > > (%d)", r); diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > index 3adb450eec07..79a4d2bfd94a 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > @@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct > > amdgpu_device *adev, { > > int r, mqd_size = sizeof(struct v11_compute_mqd); > > struct amdgpu_ring *ring; > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > if (pipe == AMDGPU_MES_KIQ_PIPE) > > ring = &adev->gfx.kiq[0].ring; @@ -998,9 +999,11 @@ > > static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev, > > if (ring->mqd_obj) > > return 0; > > > > + if (amdgpu_sriov_vf(adev)) > > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > > + > > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > > - AMDGPU_GEM_DOMAIN_VRAM | > > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > > + domain, &ring->mqd_obj, > > &ring->mqd_gpu_addr, &ring->mqd_ptr); > > if (r) { > > dev_warn(adev->dev, "failed to create ring mqd bo > > (%d)", r); > > -- > > 2.37.3 > >
RE: [PATCH 00/10] DC Patches for 15 May 2023
[Public] Hi all, This week this patchset was tested on the following systems: Lenovo ThinkPad T14s Gen2, with AMD Ryzen 5 5650U Lenovo ThinkBook T13s Gen4 with AMD Ryzen 5 6600U Reference AMD RX6800 These systems were tested on the following display types: eDP, (1080p 60hz [5650U]) (1920x1200 60hz [6600U]) (2560x1600 120hz[6600U]) VGA and DVI (1680x1050 60HZ [DP to VGA/DVI, USB-C to DVI/VGA]) DP/HDMI/USB-C (1440p 170hz, 4k 60hz, 4k 144hz [Includes USB-C to DP/HDMI adapters]) MST tested with Startech MST14DP123DP and 2x 4k 60Hz displays DSC tested with Cable Matters 101075 (DP to 3x DP), and 201375 (USB-C to 3x DP) with 3x 4k60 displays HP Hook G2 with 1 and 2 4k60 Displays USB 4 testing with Kensington SD5700T and 1x 4k 60Hz display PCON tested with Club3D CAC-1085 and 1x 4k 144Hz display (at 4k 120HZ, as that is the max the adapter supports) The testing is a mix of automated and manual tests. Manual testing includes (but is not limited to): Changing display configurations and settings Benchmark testing Feature testing (Freesync, etc.) Automated testing includes (but is not limited to): Script testing (scripts to automate some of the manual checks) IGT testing The patchset consists of the amd-staging-drm-next branch (Head commit - 53967b9f28f9 drm/amd/display: Promote DAL to 3.2.235) with new patches added on top of it. This branch is used for both Ubuntu and Chrome OS testing (ChromeOS on a bi-weekly basis). Tested on Ubuntu 22.04.2 Tested-by: Daniel Wheeler Thank you, Dan Wheeler Sr. Technologist | AMD SW Display -- 1 Commerce Valley Dr E, Thornhill, ON L3T 7X6 amd.com -Original Message- From: Aurabindo Pillai Sent: May 10, 2023 4:49 PM To: amd-gfx@lists.freedesktop.org Cc: Wentland, Harry ; Li, Sun peng (Leo) ; Lakha, Bhawanpreet ; Siqueira, Rodrigo ; Pillai, Aurabindo ; Zhuo, Qingqing (Lillian) ; Li, Roman ; Lin, Wayne ; Wang, Chao-kai (Stylon) ; Chiu, Solomon ; Kotarac, Pavle ; Gutierrez, Agustin ; Wheeler, Daniel Subject: [PATCH 00/10] DC Patches for 15 May 2023 This DC patchset brings improvements in multiple areas. In summary, we highlight: * DC v3.2.236 * Fixes related to DCN clock sequencing * Changes to FPO acceptance heuristics for various modelines * Dmesg log readability, visual debug improments and various bug fixes. Cc: Daniel Wheeler --- Alvin Lee (3): drm/amd/display: Only skip update for DCFCLK, UCLK, FCLK on overclock drm/amd/display: Update vactive margin and max vblank for fpo + vactive drm/amd/display: Make unbounded req update separate from dlg/ttu Aric Cyr (1): drm/amd/display: 3.2.236 Daniel Miess (2): drm/amd/display: Fix possible underflow for displays with large vblank drm/amd/display: Remove v_startup workaround for dcn3+ Leo (Hanghong) Ma (1): drm/amd/display: Add visual confirm color support for MCLK switch Mustapha Ghaddar (1): drm/amd/display: enable dpia validate Rodrigo Siqueira (2): drm/amd/display: Convert connector signal id to string drm/amd/display: Remove unnecessary variable .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 24 + drivers/gpu/drm/amd/display/dc/core/dc.c | 51 --- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 50 -- drivers/gpu/drm/amd/display/dc/dc.h | 12 - .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 22 +++- .../amd/display/dc/dcn10/dcn10_hw_sequencer.h | 1 - .../drm/amd/display/dc/dcn20/dcn20_hwseq.c| 37 -- .../drm/amd/display/dc/dcn20/dcn20_hwseq.h| 5 -- .../gpu/drm/amd/display/dc/dcn20/dcn20_init.c | 2 +- .../drm/amd/display/dc/dcn201/dcn201_hwseq.c | 4 +- .../drm/amd/display/dc/dcn201/dcn201_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn21/dcn21_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn30/dcn30_init.c | 2 +- .../drm/amd/display/dc/dcn301/dcn301_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 2 +- .../drm/amd/display/dc/dcn314/dcn314_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn32/dcn32_init.c | 2 +- .../drm/amd/display/dc/dcn32/dcn32_resource.c | 2 + .../drm/amd/display/dc/dcn32/dcn32_resource.h | 1 - .../display/dc/dcn32/dcn32_resource_helpers.c | 2 +- .../amd/display/dc/dcn321/dcn321_resource.c | 2 + .../drm/amd/display/dc/dml/dcn20/dcn20_fpu.c | 24 +++-- .../amd/display/dc/dml/dcn314/dcn314_fpu.c| 19 +++ .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 10 +++- .../gpu/drm/amd/display/dc/inc/core_types.h | 3 ++ .../gpu/drm/amd/display/dc/inc/hw_sequencer.h | 9 +++- .../drm/amd/display/dc/link/link_factory.c| 6 +-- .../drm/amd/display/dc/link/link_validation.c | 3 ++ .../drm/amd/display/include/signal_types.h| 28 ++ 29 files changed, 224 insertions(+), 107 deletions(-) -- 2.40.0
Re: [PATCH] drm/amdgpu: remove unnecessary (void*) conversions
On Mon, May 15, 2023 at 3:17 AM Dan Carpenter wrote: > > On Mon, May 15, 2023 at 09:34:28AM +0800, Su Hui wrote: > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > index f60753f97ac5..c837e0bf2cfc 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > @@ -1470,7 +1470,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device > > *adev) > > > > static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) > > { > > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > > + struct amdgpu_device *adev = m->private; > > struct drm_device *dev = adev_to_drm(adev); > > int r = 0, i; > > > > This declaration block was originally written in reverse Christmas tree > order: > > long long long variable name; > medium length name; > short name; > > So you probably want to change the order now that the lengths have > changed. Same in the other places as well. I don't think it's possible due to the variable dependencies unless you separate the declarations and assignments which doesn't seem like a net win to me. Alex > > regards, > dan carpenter >
[PATCH v4 0/9] drm: fdinfo memory stats
From: Rob Clark Similar motivation to other similar recent attempt[1]. But with an attempt to have some shared code for this. As well as documentation. It is probably a bit UMA-centric, I guess devices with VRAM might want some placement stats as well. But this seems like a reasonable start. Basic gputop support: https://patchwork.freedesktop.org/series/116236/ And already nvtop support: https://github.com/Syllo/nvtop/pull/204 I've combined the separate series to add comm/cmdline override onto the end of this, simply out of convenience (they would otherwise conflict in a bunch of places). v2: Extend things to allow for multiple regions other than just system "memory", make drm_show_memory_stats() a helper so that, drivers can use it or not based on their needs (but in either case, re- use drm_print_memory_stats() v3: Docs fixes v4: use u64 for drm_memory_stats, small docs update and collected Tvrtko's a-b [1] https://patchwork.freedesktop.org/series/112397/ Rob Clark (9): drm/docs: Fix usage stats typos drm: Add common fdinfo helper drm/msm: Switch to fdinfo helper drm/amdgpu: Switch to fdinfo helper drm: Add fdinfo memory stats drm/msm: Add memory stats to fdinfo drm/doc: Relax fdinfo string constraints drm/fdinfo: Add comm/cmdline override fields drm/msm: Wire up comm/cmdline override for fdinfo Documentation/gpu/drm-usage-stats.rst | 101 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- drivers/gpu/drm/drm_file.c | 147 + drivers/gpu/drm/msm/adreno/adreno_gpu.c| 24 +++- drivers/gpu/drm/msm/msm_drv.c | 15 ++- drivers/gpu/drm/msm/msm_gem.c | 15 +++ drivers/gpu/drm/msm/msm_gpu.c | 2 - drivers/gpu/drm/msm/msm_gpu.h | 10 ++ include/drm/drm_drv.h | 7 + include/drm/drm_file.h | 51 +++ include/drm/drm_gem.h | 32 + 13 files changed, 378 insertions(+), 47 deletions(-) -- 2.40.1
[PATCH v4 4/9] drm/amdgpu: Switch to fdinfo helper
From: Rob Clark Signed-off-by: Rob Clark Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index f5ffca24def4..6c0e0c614b94 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2745,21 +2745,21 @@ static const struct file_operations amdgpu_driver_kms_fops = { .flush = amdgpu_flush, .release = drm_release, .unlocked_ioctl = amdgpu_drm_ioctl, .mmap = drm_gem_mmap, .poll = drm_poll, .read = drm_read, #ifdef CONFIG_COMPAT .compat_ioctl = amdgpu_kms_compat_ioctl, #endif #ifdef CONFIG_PROC_FS - .show_fdinfo = amdgpu_show_fdinfo + .show_fdinfo = drm_show_fdinfo, #endif }; int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv) { struct drm_file *file; if (!filp) return -EINVAL; @@ -2800,20 +2800,21 @@ static const struct drm_driver amdgpu_kms_driver = { DRIVER_SYNCOBJ_TIMELINE, .open = amdgpu_driver_open_kms, .postclose = amdgpu_driver_postclose_kms, .lastclose = amdgpu_driver_lastclose_kms, .ioctls = amdgpu_ioctls_kms, .num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms), .dumb_create = amdgpu_mode_dumb_create, .dumb_map_offset = amdgpu_mode_dumb_mmap, .fops = &amdgpu_driver_kms_fops, .release = &amdgpu_driver_release_kms, + .show_fdinfo = amdgpu_show_fdinfo, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = amdgpu_gem_prime_import, .gem_prime_mmap = drm_gem_prime_mmap, .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, .major = KMS_DRIVER_MAJOR, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 99a7855ab1bc..c2fdd5e448d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -46,23 +46,22 @@ static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = { [AMDGPU_HW_IP_COMPUTE] = "compute", [AMDGPU_HW_IP_DMA] = "dma", [AMDGPU_HW_IP_UVD] = "dec", [AMDGPU_HW_IP_VCE] = "enc", [AMDGPU_HW_IP_UVD_ENC] = "enc_1", [AMDGPU_HW_IP_VCN_DEC] = "dec", [AMDGPU_HW_IP_VCN_ENC] = "enc", [AMDGPU_HW_IP_VCN_JPEG] = "jpeg", }; -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct amdgpu_device *adev = drm_to_adev(file->minor->dev); struct amdgpu_fpriv *fpriv = file->driver_priv; struct amdgpu_vm *vm = &fpriv->vm; uint64_t vram_mem = 0, gtt_mem = 0, cpu_mem = 0; ktime_t usage[AMDGPU_HW_IP_NUM]; uint32_t bus, dev, fn, domain; unsigned int hw_ip; int ret; @@ -79,25 +78,22 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) amdgpu_bo_unreserve(vm->root.bo); amdgpu_ctx_mgr_usage(&fpriv->ctx_mgr, usage); /* * ** * For text output format description please see drm-usage-stats.rst! * ** */ - seq_printf(m, "pasid:\t%u\n", fpriv->vm.pasid); - seq_printf(m, "drm-driver:\t%s\n", file->minor->dev->driver->name); - seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn); - seq_printf(m, "drm-client-id:\t%Lu\n", vm->immediate.fence_context); - seq_printf(m, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); - seq_printf(m, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); - seq_printf(m, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); + drm_printf(p, "pasid:\t%u\n", fpriv->vm.pasid); + drm_printf(p, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); + drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); + drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); for (hw_ip = 0; hw_ip < AMDGPU_HW_IP_NUM; ++hw_ip) { if (!usage[hw_ip]) continue; - seq_printf(m, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], + drm_printf(p, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], ktime_to_ns(usage[hw_ip])); } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h i
Re: No GTT->VRAM unswapping with amdgpu?
On Thu, May 11, 2023 at 9:38 PM Linus Lüssing wrote: > > Hi, > > Initially noticed this in some games, which seem to be a bit lazy > with their VRAM allocations + freeing, that performance would drop > dramatically / become unusable once the VRAM is full and GTT gets > used. For instance in No Man's Sky after jumping a solar system > or on DCS World on several maps and in multiplayer. I'm using an > ATI/AMD Radeon RX 6650 XT, 8GB VRAM with an eGPU enclosure > (Razer Core X Chroma, Thunderbolt 3), connected via a 40Gbit/s > USB4 port. Which usually has great performance, until I hit the > VRAM limit. > > I scripted some further tests and benchmarking around > memmtest_vulkan(*) and these were the results: > > https://github.com/T-X/linux-amdgpu-radeon-vram-swapping-test/ > > I would have expected roughly the same speeds in all tests. > However tests 5) and 6) yielded significantly lower performance. > > Which leads me to the conclusion that anything that gets allocated > on GTT stays there and is never unswapped from GTT / system memory > back to VRAM? It will get swapped back to VRAM if it makes sense for performance. The driver throttles swapping if there is too much contention to avoid the overhead of swapping large amounts of memory back and forth between vram and gtt for every command submission. Alex > > I also read that there was some rework with a new TTM allocator > in 2020. But dynamic (un)swapping via TTM seems currently unused? > Is this expected? > > Regards, Linus > > (*): https://github.com/GpuZelenograd/memtest_vulkan
Re: No GTT->VRAM unswapping with amdgpu?
On Mon, May 15, 2023 at 10:42 AM Alex Deucher wrote: > > On Thu, May 11, 2023 at 9:38 PM Linus Lüssing > wrote: > > > > Hi, > > > > Initially noticed this in some games, which seem to be a bit lazy > > with their VRAM allocations + freeing, that performance would drop > > dramatically / become unusable once the VRAM is full and GTT gets > > used. For instance in No Man's Sky after jumping a solar system > > or on DCS World on several maps and in multiplayer. I'm using an > > ATI/AMD Radeon RX 6650 XT, 8GB VRAM with an eGPU enclosure > > (Razer Core X Chroma, Thunderbolt 3), connected via a 40Gbit/s > > USB4 port. Which usually has great performance, until I hit the > > VRAM limit. > > > > I scripted some further tests and benchmarking around > > memmtest_vulkan(*) and these were the results: > > > > https://github.com/T-X/linux-amdgpu-radeon-vram-swapping-test/ > > > > I would have expected roughly the same speeds in all tests. > > However tests 5) and 6) yielded significantly lower performance. > > > > Which leads me to the conclusion that anything that gets allocated > > on GTT stays there and is never unswapped from GTT / system memory > > back to VRAM? > > It will get swapped back to VRAM if it makes sense for performance. > The driver throttles swapping if there is too much contention to avoid > the overhead of swapping large amounts of memory back and forth > between vram and gtt for every command submission. RADV also dynamically prefers GTT if you are using an eGPU and memory is contended: https://cgit.freedesktop.org/mesa/mesa/commit/?id=95d06343c693aa12b4cda5cda31d81fae138b0ec Alex > > Alex > > > > > I also read that there was some rework with a new TTM allocator > > in 2020. But dynamic (un)swapping via TTM seems currently unused? > > Is this expected? > > > > Regards, Linus > > > > (*): https://github.com/GpuZelenograd/memtest_vulkan
Re: [PATCH] drm/amdgpu: remove unnecessary (void*) conversions
On Mon, May 15, 2023 at 10:11:39AM -0400, Alex Deucher wrote: > On Mon, May 15, 2023 at 3:17 AM Dan Carpenter > wrote: > > > > On Mon, May 15, 2023 at 09:34:28AM +0800, Su Hui wrote: > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > > index f60753f97ac5..c837e0bf2cfc 100644 > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > > @@ -1470,7 +1470,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device > > > *adev) > > > > > > static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) > > > { > > > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > > > + struct amdgpu_device *adev = m->private; > > > struct drm_device *dev = adev_to_drm(adev); > > > int r = 0, i; > > > > > > > This declaration block was originally written in reverse Christmas tree > > order: > > > > long long long variable name; > > medium length name; > > short name; > > > > So you probably want to change the order now that the lengths have > > changed. Same in the other places as well. > > I don't think it's possible due to the variable dependencies unless > you separate the declarations and assignments which doesn't seem like > a net win to me. Gar. I'm dumb. Sorry for the noise. regards, dan carpenter
Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM
[AMD Official Use Only - General] Yes, it should work. If that, the routine would behave like *reset*. That means driver would behave like to create a new queue instead of restoring a saved queue. I can have a try with this solution. Regards, Jack From: Alex Deucher Sent: Monday, 15 May 2023 21:08 To: Xiao, Jack Cc: amd-gfx@lists.freedesktop.org ; Deucher, Alexander Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM On Mon, May 15, 2023 at 6:40 AM Xiao, Jack wrote: > > [AMD Official Use Only - General] > > The MQD data in VRAM would be lost after S3, for the MQD bo is pinned down > as kernel bo and can't be evicted to system memory. > AFAIK, driver should not to do allocate/free memory during S3, as there are > issues observed to do memory allocation during S3. We restore the contents of the MQD in gfx_v*_0_gfx_init_queue() and gfx_v*_0_kcq_init_queue(). Alex > > Regards, > Jack > > -Original Message- > From: Alex Deucher > Sent: Friday, May 12, 2023 9:13 PM > To: Xiao, Jack > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM > > On Fri, May 12, 2023 at 4:16 AM Jack Xiao wrote: > > > > Make the preemption optimization effect only for SRIOV, for it caused > > failure to resume from S3. > > Can you elaborate? We ultimately want MQDs in VRAM for performance reasons > even for bare metal. > > Alex > > > > > Signed-off-by: Jack Xiao > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++- > > drivers/gpu/drm/amd/amdgpu/mes_v10_1.c | 7 +-- > > drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 7 +-- > > 3 files changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > index a22d88a4178a..1b795b7bbf38 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > @@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev, > > u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > /* Only enable on gfx10 and 11 for now to avoid changing behavior > > on older chips */ > > - if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0)) > > + if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) && > > + amdgpu_sriov_vf(adev)) > > domain |= AMDGPU_GEM_DOMAIN_VRAM; > > > > /* create MQD for KIQ */ > > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > index 4560476c7c31..5c3d3f6c7ebd 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > @@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct > > amdgpu_device *adev, { > > int r, mqd_size = sizeof(struct v10_compute_mqd); > > struct amdgpu_ring *ring; > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > if (pipe == AMDGPU_MES_KIQ_PIPE) > > ring = &adev->gfx.kiq[0].ring; @@ -900,9 +901,11 @@ > > static int mes_v10_1_mqd_sw_init(struct amdgpu_device *adev, > > if (ring->mqd_obj) > > return 0; > > > > + if (amdgpu_sriov_vf(adev)) > > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > > + > > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > > - AMDGPU_GEM_DOMAIN_VRAM | > > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > > + domain, &ring->mqd_obj, > > &ring->mqd_gpu_addr, &ring->mqd_ptr); > > if (r) { > > dev_warn(adev->dev, "failed to create ring mqd bo > > (%d)", r); diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > index 3adb450eec07..79a4d2bfd94a 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > @@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct > > amdgpu_device *adev, { > > int r, mqd_size = sizeof(struct v11_compute_mqd); > > struct amdgpu_ring *ring; > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > if (pipe == AMDGPU_MES_KIQ_PIPE) > > ring = &adev->gfx.kiq[0].ring; @@ -998,9 +999,11 @@ > > static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev, > > if (ring->mqd_obj) > > return 0; > > > > + if (amdgpu_sriov_vf(adev)) > > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > > + > > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > > - AMDGPU_GEM_DOMAIN_VRAM | > > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > > + domain, &ring->mqd_obj, > > &ring->mqd_gpu_addr, &ring->mqd_ptr); > > if (r) { > > d
Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM
On Mon, May 15, 2023 at 11:02 AM Xiao, Jack wrote: > > [AMD Official Use Only - General] > > > Yes, it should work. If that, the routine would behave like *reset*. That > means driver would behave like to create a new queue instead of restoring a > saved queue. I can have a try with this solution. > I think it should work as is. At least suspend/resume worked when I tested it. The logic in gfx_v11_0_gfx_init_queue() is: if (!amdgpu_in_reset(adev) && !adev->in_suspend) { ... // Save the original image after init at driver load time memcpy(adev->gfx.me.mqd_backup[mqd_idx], mqd, sizeof(*mqd)); } else { // restore the saved image at resume or reset time memcpy(mqd, adev->gfx.me.mqd_backup[mqd_idx], sizeof(*mqd)); ... } Alex > Regards, > Jack > > From: Alex Deucher > Sent: Monday, 15 May 2023 21:08 > To: Xiao, Jack > Cc: amd-gfx@lists.freedesktop.org ; Deucher, > Alexander > Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM > > On Mon, May 15, 2023 at 6:40 AM Xiao, Jack wrote: > > > > [AMD Official Use Only - General] > > > > The MQD data in VRAM would be lost after S3, for the MQD bo is pinned down > > as kernel bo and can't be evicted to system memory. > > AFAIK, driver should not to do allocate/free memory during S3, as there are > > issues observed to do memory allocation during S3. > > We restore the contents of the MQD in gfx_v*_0_gfx_init_queue() and > gfx_v*_0_kcq_init_queue(). > > Alex > > > > > Regards, > > Jack > > > > -Original Message- > > From: Alex Deucher > > Sent: Friday, May 12, 2023 9:13 PM > > To: Xiao, Jack > > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > > > Subject: Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM > > > > On Fri, May 12, 2023 at 4:16 AM Jack Xiao wrote: > > > > > > Make the preemption optimization effect only for SRIOV, for it caused > > > failure to resume from S3. > > > > Can you elaborate? We ultimately want MQDs in VRAM for performance reasons > > even for bare metal. > > > > Alex > > > > > > > > Signed-off-by: Jack Xiao > > > --- > > > drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++- > > > drivers/gpu/drm/amd/amdgpu/mes_v10_1.c | 7 +-- > > > drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 7 +-- > > > 3 files changed, 12 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > > index a22d88a4178a..1b795b7bbf38 100644 > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c > > > @@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev, > > > u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > > > /* Only enable on gfx10 and 11 for now to avoid changing behavior > > > on older chips */ > > > - if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0)) > > > + if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) && > > > + amdgpu_sriov_vf(adev)) > > > domain |= AMDGPU_GEM_DOMAIN_VRAM; > > > > > > /* create MQD for KIQ */ > > > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > > b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > > index 4560476c7c31..5c3d3f6c7ebd 100644 > > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c > > > @@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct > > > amdgpu_device *adev, { > > > int r, mqd_size = sizeof(struct v10_compute_mqd); > > > struct amdgpu_ring *ring; > > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > > > if (pipe == AMDGPU_MES_KIQ_PIPE) > > > ring = &adev->gfx.kiq[0].ring; @@ -900,9 +901,11 @@ > > > static int mes_v10_1_mqd_sw_init(struct amdgpu_device *adev, > > > if (ring->mqd_obj) > > > return 0; > > > > > > + if (amdgpu_sriov_vf(adev)) > > > + domain |= AMDGPU_GEM_DOMAIN_VRAM; > > > + > > > r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, > > > - AMDGPU_GEM_DOMAIN_VRAM | > > > - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, > > > + domain, &ring->mqd_obj, > > > &ring->mqd_gpu_addr, &ring->mqd_ptr); > > > if (r) { > > > dev_warn(adev->dev, "failed to create ring mqd bo > > > (%d)", r); diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > > b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > > index 3adb450eec07..79a4d2bfd94a 100644 > > > --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > > > @@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct > > > amdgpu_device *adev, { > > > int r, mqd_size = sizeof(struct v11_compute_mqd); > > > struct amdgpu_ring *ring; > > > + u32 domain = AMDGPU_GEM_DOMAIN_GTT; > > > > >
Re: [PATCH v2 03/12] drm/exynos: Use regular fbdev I/O helpers
Hi Thomas, On Mon, May 15, 2023 at 11:40:24AM +0200, Thomas Zimmermann wrote: > Use the regular fbdev helpers for framebuffer I/O instead of DRM's > helpers. Exynos does not use damage handling, so DRM's fbdev helpers > are mere wrappers around the fbdev code. > > By using fbdev helpers directly within each DRM fbdev emulation, > we can eventually remove DRM's wrapper functions entirely. > > v2: > * use FB_IO_HELPERS option > > Signed-off-by: Thomas Zimmermann > Cc: Inki Dae > Cc: Seung-Woo Kim > Cc: Kyungmin Park > Cc: Krzysztof Kozlowski > Cc: Alim Akhtar > --- > drivers/gpu/drm/exynos/Kconfig| 1 + > drivers/gpu/drm/exynos/Makefile | 2 +- > drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 10 +- > 3 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig > index 0cb92d651ff1..7ca7e1dab52c 100644 > --- a/drivers/gpu/drm/exynos/Kconfig > +++ b/drivers/gpu/drm/exynos/Kconfig > @@ -7,6 +7,7 @@ config DRM_EXYNOS > select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP > select DRM_KMS_HELPER > select VIDEOMODE_HELPERS > + select FB_IO_HELPERS if DRM_FBDEV_EMULATION > select SND_SOC_HDMI_CODEC if SND_SOC > help > Choose this option if you have a Samsung SoC Exynos chipset. > diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile > index 2fd2f3ee4fcf..233a66036584 100644 > --- a/drivers/gpu/drm/exynos/Makefile > +++ b/drivers/gpu/drm/exynos/Makefile > @@ -6,7 +6,6 @@ > exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ > exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o > > -exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o > exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o > exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o > exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON)+= exynos7_drm_decon.o > @@ -23,5 +22,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += > exynos_drm_rotator.o > exynosdrm-$(CONFIG_DRM_EXYNOS_SCALER)+= exynos_drm_scaler.o > exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o > exynosdrm-$(CONFIG_DRM_EXYNOS_MIC) += exynos_drm_mic.o > +exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o What does this change do? Maybe something that was left by accident? Sam > > obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o > diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c > b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c > index ea4b3d248aac..bdd1d087 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c > @@ -8,6 +8,8 @@ > * Seung-Woo Kim > */ > > +#include > + > #include > #include > #include > @@ -49,11 +51,9 @@ static const struct fb_ops exynos_drm_fb_ops = { > .owner = THIS_MODULE, > DRM_FB_HELPER_DEFAULT_OPS, > .fb_mmap= exynos_drm_fb_mmap, > - .fb_read= drm_fb_helper_cfb_read, > - .fb_write = drm_fb_helper_cfb_write, > - .fb_fillrect= drm_fb_helper_cfb_fillrect, > - .fb_copyarea= drm_fb_helper_cfb_copyarea, > - .fb_imageblit = drm_fb_helper_cfb_imageblit, > + .fb_fillrect= cfb_fillrect, > + .fb_copyarea= cfb_copyarea, > + .fb_imageblit = cfb_imageblit, > .fb_destroy = exynos_drm_fb_destroy, > }; > > -- > 2.40.1
Re: [PATCH v2 02/12] drm/armada: Use regular fbdev I/O helpers
Hi Thomas, On Mon, May 15, 2023 at 11:40:23AM +0200, Thomas Zimmermann wrote: > Use the regular fbdev helpers for framebuffer I/O instead of DRM's > helpers. Armada does not use damage handling, so DRM's fbdev helpers > are mere wrappers around the fbdev code. > > By using fbdev helpers directly within each DRM fbdev emulation, > we can eventually remove DRM's wrapper functions entirely. > > v2: > * use FB_IO_HELPERS option > > Signed-off-by: Thomas Zimmermann > Cc: Russell King > --- > drivers/gpu/drm/armada/Kconfig| 1 + > drivers/gpu/drm/armada/armada_fbdev.c | 9 - > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig > index f5c66d89ba99..5afade25e217 100644 > --- a/drivers/gpu/drm/armada/Kconfig > +++ b/drivers/gpu/drm/armada/Kconfig > @@ -3,6 +3,7 @@ config DRM_ARMADA > tristate "DRM support for Marvell Armada SoCs" > depends on DRM && HAVE_CLK && ARM && MMU > select DRM_KMS_HELPER > + select FB_IO_HELPERS if DRM_FBDEV_EMULATION > help > Support the "LCD" controllers found on the Marvell Armada 510 > devices. There are two controllers on the device, each controller > diff --git a/drivers/gpu/drm/armada/armada_fbdev.c > b/drivers/gpu/drm/armada/armada_fbdev.c > index 0a5fd1aa86eb..6c3bbaf53569 100644 > --- a/drivers/gpu/drm/armada/armada_fbdev.c > +++ b/drivers/gpu/drm/armada/armada_fbdev.c > @@ -5,6 +5,7 @@ > */ > > #include > +#include > #include > #include > > @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info) > static const struct fb_ops armada_fb_ops = { > .owner = THIS_MODULE, > DRM_FB_HELPER_DEFAULT_OPS, > - .fb_read= drm_fb_helper_cfb_read, > - .fb_write = drm_fb_helper_cfb_write, I had expected to see .fb_read = fb_io_read, But maybe this only used when using damage handling? Likewise for drm_fb_helper_cfb_write. ?? > - .fb_fillrect= drm_fb_helper_cfb_fillrect, > - .fb_copyarea= drm_fb_helper_cfb_copyarea, > - .fb_imageblit = drm_fb_helper_cfb_imageblit, > + .fb_fillrect= cfb_fillrect, > + .fb_copyarea= cfb_copyarea, > + .fb_imageblit = cfb_imageblit, This part is as expected. Sam > .fb_destroy = armada_fbdev_fb_destroy, > }; > > -- > 2.40.1
Re: [PATCH v2 02/12] drm/armada: Use regular fbdev I/O helpers
On Mon, May 15, 2023 at 07:55:44PM +0200, Sam Ravnborg wrote: > Hi Thomas, > > On Mon, May 15, 2023 at 11:40:23AM +0200, Thomas Zimmermann wrote: > > Use the regular fbdev helpers for framebuffer I/O instead of DRM's > > helpers. Armada does not use damage handling, so DRM's fbdev helpers > > are mere wrappers around the fbdev code. > > > > By using fbdev helpers directly within each DRM fbdev emulation, > > we can eventually remove DRM's wrapper functions entirely. > > > > v2: > > * use FB_IO_HELPERS option > > > > Signed-off-by: Thomas Zimmermann > > Cc: Russell King > > --- > > drivers/gpu/drm/armada/Kconfig| 1 + > > drivers/gpu/drm/armada/armada_fbdev.c | 9 - > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig > > index f5c66d89ba99..5afade25e217 100644 > > --- a/drivers/gpu/drm/armada/Kconfig > > +++ b/drivers/gpu/drm/armada/Kconfig > > @@ -3,6 +3,7 @@ config DRM_ARMADA > > tristate "DRM support for Marvell Armada SoCs" > > depends on DRM && HAVE_CLK && ARM && MMU > > select DRM_KMS_HELPER > > + select FB_IO_HELPERS if DRM_FBDEV_EMULATION > > help > > Support the "LCD" controllers found on the Marvell Armada 510 > > devices. There are two controllers on the device, each controller > > diff --git a/drivers/gpu/drm/armada/armada_fbdev.c > > b/drivers/gpu/drm/armada/armada_fbdev.c > > index 0a5fd1aa86eb..6c3bbaf53569 100644 > > --- a/drivers/gpu/drm/armada/armada_fbdev.c > > +++ b/drivers/gpu/drm/armada/armada_fbdev.c > > @@ -5,6 +5,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > > > @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info) > > static const struct fb_ops armada_fb_ops = { > > .owner = THIS_MODULE, > > DRM_FB_HELPER_DEFAULT_OPS, > > - .fb_read= drm_fb_helper_cfb_read, > > - .fb_write = drm_fb_helper_cfb_write, > I had expected to see > .fb_read = fb_io_read, > > But maybe this only used when using damage handling? > > Likewise for drm_fb_helper_cfb_write. > > ?? > > > - .fb_fillrect= drm_fb_helper_cfb_fillrect, > > - .fb_copyarea= drm_fb_helper_cfb_copyarea, > > - .fb_imageblit = drm_fb_helper_cfb_imageblit, > > + .fb_fillrect= cfb_fillrect, > > + .fb_copyarea= cfb_copyarea, > > + .fb_imageblit = cfb_imageblit, > > This part is as expected. Well, to me it looks like this has gone through an entire circular set of revisions: commit e8b70e4dd7b5dad7c2379de6e0851587bf86bfd6 Author: Archit Taneja Date: Wed Jul 22 14:58:04 2015 +0530 drm/armada: Use new drm_fb_helper functions - .fb_fillrect= cfb_fillrect, - .fb_copyarea= cfb_copyarea, - .fb_imageblit = cfb_imageblit, + .fb_fillrect= drm_fb_helper_cfb_fillrect, + .fb_copyarea= drm_fb_helper_cfb_copyarea, + .fb_imageblit = drm_fb_helper_cfb_imageblit, commit 983780918c759fdbbf0bf033e701bbff75d2af23 Author: Thomas Zimmermann Date: Thu Nov 3 16:14:40 2022 +0100 drm/fb-helper: Perform all fbdev I/O with the same implementation + .fb_read= drm_fb_helper_cfb_read, + .fb_write = drm_fb_helper_cfb_write, and now effectively those two changes are being reverted, so we'd now be back to the pre-July 2015 state of affairs. As I believe the fbdev layer has been stable, this change merely reverts the driver back to what it once was. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
On Sun, May 14, 2023, Lorenzo Stoakes wrote: > No invocation of get_user_pages() use the vmas parameter, so remove it. > > The GUP API is confusing and caveated. Recent changes have done much to > improve that, however there is more we can do. Exporting vmas is a prime > target as the caller has to be extremely careful to preclude their use > after the mmap_lock has expired or otherwise be left with dangling > pointers. > > Removing the vmas parameter focuses the GUP functions upon their primary > purpose - pinning (and outputting) pages as well as performing the actions > implied by the input flags. > > This is part of a patch series aiming to remove the vmas parameter > altogether. > > Suggested-by: Matthew Wilcox (Oracle) > Acked-by: Greg Kroah-Hartman > Acked-by: David Hildenbrand > Reviewed-by: Jason Gunthorpe > Acked-by: Christian K�nig (for radeon parts) > Acked-by: Jarkko Sakkinen > Signed-off-by: Lorenzo Stoakes > --- > arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- > drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- > drivers/misc/sgi-gru/grufault.c | 2 +- > include/linux/mm.h | 3 +-- > mm/gup.c| 9 +++-- > mm/gup_test.c | 5 ++--- > virt/kvm/kvm_main.c | 2 +- > 7 files changed, 10 insertions(+), 15 deletions(-) Acked-by: Sean Christopherson (KVM) > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index cb5c13eee193..eaa5bb8dbadc 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2477,7 +2477,7 @@ static inline int check_user_page_hwpoison(unsigned > long addr) > { > int rc, flags = FOLL_HWPOISON | FOLL_WRITE; > > - rc = get_user_pages(addr, 1, flags, NULL, NULL); > + rc = get_user_pages(addr, 1, flags, NULL); > return rc == -EHWPOISON; Unrelated to this patch, I think there's a pre-existing bug here. If gup() returns a valid page, KVM will leak the refcount and unintentionally pin the page. That's highly unlikely as check_user_page_hwpoison() is called iff get_user_pages_unlocked() fails (called by hva_to_pfn_slow()), but it's theoretically possible that userspace could change the VMAs between hva_to_pfn_slow() and check_user_page_hwpoison() since KVM doesn't hold any relevant locks at this point. E.g. if there's no VMA during hva_to_pfn_{fast,slow}(), npages==-EFAULT and KVM will invoke check_user_page_hwpoison(). If userspace installs a valid mapping after hva_to_pfn_slow() but before KVM acquires mmap_lock, then gup() will find a valid page. I _think_ the fix is to simply delete this code. The bug was introduced by commit fafc3dbaac64 ("KVM: Replace is_hwpoison_address with __get_user_pages"). At that time, KVM didn't check for "npages == -EHWPOISON" from the first call to get_user_pages_unlocked(). Later on, commit 0857b9e95c1a ("KVM: Enable async page fault processing") reworked the caller to be: mmap_read_lock(current->mm); if (npages == -EHWPOISON || (!async && check_user_page_hwpoison(addr))) { pfn = KVM_PFN_ERR_HWPOISON; goto exit; } where async really means NOWAIT, so that the hwpoison use of gup() didn't sleep. KVM: Enable async page fault processing If asynchronous hva_to_pfn() is requested call GUP with FOLL_NOWAIT to avoid sleeping on IO. Check for hwpoison is done at the same time, otherwise check_user_page_hwpoison() will call GUP again and will put vcpu to sleep. There are other potential problems too, e.g. the hwpoison call doesn't honor the recently introduced @interruptible flag. I don't see any reason to keep check_user_page_hwpoison(), KVM can simply rely on the "npages == -EHWPOISON" check. get_user_pages_unlocked() is guaranteed to be called with roughly equivalent flags, and the flags that aren't equivalent are arguably bugs in check_user_page_hwpoison(), e.g. assuming FOLL_WRITE is wrong. TL;DR: Go ahead with this change, I'll submit a separate patch to delete the buggy KVM code.
[PATCH] drm/amdkfd: Fix null ptr access
From: Hawking Zhang Avoid access null xcp_mgr pointer. Signed-off-by: Hawking Zhang Reviewed-by: Lijo Lazar Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index bf32e547182c..2cfef3f9456f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -644,12 +644,14 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, * If the VMID range changes for GFX9.4.3, then this code MUST be * revisited. */ - partition_mode = amdgpu_xcp_query_partition_mode(kfd->adev->xcp_mgr, AMDGPU_XCP_FL_LOCKED); - if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 3) && - partition_mode == AMDGPU_CPX_PARTITION_MODE && - kfd->num_nodes != 1) { - vmid_num_kfd /= 2; - first_vmid_kfd = last_vmid_kfd + 1 - vmid_num_kfd*2; + if (kfd->adev->xcp_mgr) { + partition_mode = amdgpu_xcp_query_partition_mode(kfd->adev->xcp_mgr, + AMDGPU_XCP_FL_LOCKED); + if (partition_mode == AMDGPU_CPX_PARTITION_MODE && + kfd->num_nodes != 1) { + vmid_num_kfd /= 2; + first_vmid_kfd = last_vmid_kfd + 1 - vmid_num_kfd*2; + } } /* Verify module parameters regarding mapped process number*/ -- 2.40.1
[PATCH] drm/amdgpu: Do not access members of xcp w/o check (v2)
From: Hawking Zhang Not all the asic needs xcp. ensure check xcp availabity before accessing its member. v2: add missing change in kfd_topology.c Signed-off-by: Hawking Zhang Reviewed-by: Le Ma Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 8 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_device.c| 2 +- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 85df73f2c85e..739eb7c0d133 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -429,17 +429,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev, void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, struct kfd_local_mem_info *mem_info, - uint8_t xcp_id) + struct amdgpu_xcp *xcp) { memset(mem_info, 0, sizeof(*mem_info)); - if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) { + if (xcp) { if (adev->gmc.real_vram_size == adev->gmc.visible_vram_size) mem_info->local_mem_size_public = - KFD_XCP_MEMORY_SIZE(adev, xcp_id); + KFD_XCP_MEMORY_SIZE(adev, xcp->id); else mem_info->local_mem_size_private = - KFD_XCP_MEMORY_SIZE(adev, xcp_id); + KFD_XCP_MEMORY_SIZE(adev, xcp->id); } else { mem_info->local_mem_size_public = adev->gmc.visible_vram_size; mem_info->local_mem_size_private = adev->gmc.real_vram_size - diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index 48d12dbff968..be43d71ba7ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -233,7 +233,7 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev, enum kgd_engine_type type); void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, struct kfd_local_mem_info *mem_info, - uint8_t xcp_id); + struct amdgpu_xcp *xcp); uint64_t amdgpu_amdkfd_get_gpu_clock_counter(struct amdgpu_device *adev); uint32_t amdgpu_amdkfd_get_max_engine_clock_in_mhz(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index 2cfef3f9456f..986543a000bf 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -784,7 +784,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, atomic_set(&node->sram_ecc_flag, 0); amdgpu_amdkfd_get_local_mem_info(kfd->adev, - &node->local_mem_info, node->xcp->id); + &node->local_mem_info, node->xcp); /* Initialize the KFD node */ if (kfd_init_node(node)) { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index e0bacf017a40..8302d8967158 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c @@ -1235,7 +1235,7 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev) * all the banks will report the same mem_clk_max information */ amdgpu_amdkfd_get_local_mem_info(dev->gpu->adev, &local_mem_info, -dev->gpu->xcp->id); +dev->gpu->xcp); list_for_each_entry(mem, &dev->mem_props, list) mem->mem_clk_max = local_mem_info.mem_clk_max; -- 2.40.1
RE: [PATCH] drm/amdgpu: Fix the EPERM error when get user pages
[AMD Official Use Only - General] > -Original Message- > From: amd-gfx On Behalf Of Ma > Jun > Sent: Monday, May 15, 2023 2:14 AM > To: amd-gfx@lists.freedesktop.org > Cc: Sierra Guiza, Alejandro (Alex) ; Ma, Jun > ; Kuehling, Felix ; Koenig, > Christian > Subject: [PATCH] drm/amdgpu: Fix the EPERM error when get user pages > > Check and pass the readonly flags when set amdgpu_ttm_tt flags > > for readonly ptr pages. Otherwise, there is EPERM error returned > > during the KFDExceptionTest.PermissionFaultUserPointer test on > > ploaris10. > > Signed-off-by: Ma Jun > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > index d426333e865a..85d1087439c0 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > @@ -1036,10 +1036,17 @@ static int init_user_pages(struct kgd_mem > *mem, uint64_t user_addr, > struct ttm_operation_ctx ctx = { true, false }; > struct hmm_range *range; > int ret = 0; > + uint32_t tt_flags = 0; > > mutex_lock(&process_info->lock); > > - ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, 0); > + if(!(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE)) Space between the if and (. E.g., if ( Alex > + tt_flags |= AMDGPU_GEM_USERPTR_READONLY; > + else > + tt_flags = 0; > + > + > + ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, tt_flags); > if (ret) { > pr_err("%s: Failed to set userptr: %d\n", __func__, ret); > goto out; > -- > 2.34.1
Re: [PATCH] drm/amdgpu: remove unnecessary (void*) conversions
Applied. Thanks! Alex On Mon, May 15, 2023 at 3:18 AM Su Hui wrote: > > No need cast (void*) to (struct amdgpu_device *). > > Signed-off-by: Su Hui > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- > 6 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > index f60753f97ac5..c837e0bf2cfc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > @@ -1470,7 +1470,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) > > static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > struct drm_device *dev = adev_to_drm(adev); > int r = 0, i; > > @@ -1581,7 +1581,7 @@ static int amdgpu_debugfs_benchmark(void *data, u64 val) > > static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > struct drm_device *dev = adev_to_drm(adev); > struct drm_file *file; > int r; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c > index f52d0ba91a77..f0615a43b3cc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c > @@ -835,7 +835,7 @@ static const struct dma_fence_ops amdgpu_job_fence_ops = { > #if defined(CONFIG_DEBUG_FS) > static int amdgpu_debugfs_fence_info_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > int i; > > for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > index 863cb668e000..28f79cf8c3fb 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > @@ -948,7 +948,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, > #if defined(CONFIG_DEBUG_FS) > static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > struct drm_device *dev = adev_to_drm(adev); > struct drm_file *file; > int r; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c > index 4ff348e10e4d..49a4238a120e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c > @@ -436,7 +436,7 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) > > static int amdgpu_debugfs_sa_info_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > > seq_printf(m, "- DELAYED - > \n"); > amdgpu_sa_bo_dump_debug_info(&adev->ib_pools[AMDGPU_IB_POOL_DELAYED], > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > index 0efb38539d70..9f9274249b57 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > @@ -1441,7 +1441,7 @@ void amdgpu_disable_vblank_kms(struct drm_crtc *crtc) > > static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void > *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > struct drm_amdgpu_info_firmware fw_info; > struct drm_amdgpu_query_fw query_fw; > struct atom_context *ctx = adev->mode_info.atom_context; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 2cd081cbf706..21f340ed4cca 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -2164,7 +2164,7 @@ int amdgpu_ttm_evict_resources(struct amdgpu_device > *adev, int mem_type) > > static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused) > { > - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; > + struct amdgpu_device *adev = m->private; > > return ttm_pool_debugfs(&adev->mman.bdev.pool, m); > } > -- > 2.30.2 >
Re: [PATCH] drm/amdgpu: Validate VM ioctl flags.
Applied. Thanks! Alex On Sat, May 13, 2023 at 8:54 AM Bas Nieuwenhuizen wrote: > > None have been defined yet, so reject anybody setting any. Mesa sets > it to 0 anyway. > > Signed-off-by: Bas Nieuwenhuizen > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > index 158176b2f47e..62922a795312 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > @@ -2442,6 +2442,10 @@ int amdgpu_vm_ioctl(struct drm_device *dev, void > *data, struct drm_file *filp) > struct amdgpu_fpriv *fpriv = filp->driver_priv; > int r; > > + /* No valid flags defined yet */ > + if (args->in.flags) > + return -EINVAL; > + > switch (args->in.op) { > case AMDGPU_VM_OP_RESERVE_VMID: > /* We only have requirement to reserve vmid from gfxhub */ > -- > 2.40.1 >
Re: [PATCH] drm:amd:amdgpu: Fix missing buffer object unlock in failure path
On 5/3/23 16:15, Sukrut Bellary wrote: > smatch warning - > 1) drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3615 gfx_v9_0_kiq_resume() > warn: inconsistent returns 'ring->mqd_obj->tbo.base.resv'. > > 2) drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:6901 gfx_v10_0_kiq_resume() > warn: inconsistent returns 'ring->mqd_obj->tbo.base.resv'. > > Signed-off-by: Sukrut Bellary > --- > drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 4 +++- > drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 +++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c > b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c > index 8bd07ff59671..66d5c5d68454 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c > @@ -6891,8 +6891,10 @@ static int gfx_v10_0_kiq_resume(struct amdgpu_device > *adev) > return r; > > r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr); > - if (unlikely(r != 0)) > + if (unlikely(r != 0)) { > + amdgpu_bo_unreserve(ring->mqd_obj); > return r; > + } > > gfx_v10_0_kiq_init_queue(ring); > amdgpu_bo_kunmap(ring->mqd_obj); > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > index bce6919d666a..d5715d8a4128 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > @@ -3617,8 +3617,10 @@ static int gfx_v9_0_kiq_resume(struct amdgpu_device > *adev) > return r; > > r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr); > - if (unlikely(r != 0)) > + if (unlikely(r != 0)) { > + amdgpu_bo_unreserve(ring->mqd_obj); > return r; > + } > > gfx_v9_0_kiq_init_queue(ring); > amdgpu_bo_kunmap(ring->mqd_obj); Follow-up. Could you please review this patch? -- Regards, Sukrut
[PATCH] drm/amd/pm: add delay to avoid unintened shutdown due to hotspot temperature spark
There will be a double check for the hotspot temperature on delay expired. This can avoid unintended shutdown due to hotspot temperature spark. Signed-off-by: Evan Quan -- v1->v2: - add the proper millidegree Celsius to degree Celsius transform --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 34 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 ++ .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 9 ++--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c| 9 ++--- 6 files changed, 55 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 39192eba3ff8..4cd873659365 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -243,6 +243,7 @@ extern int amdgpu_num_kcq; #define AMDGPU_VCNFW_LOG_SIZE (32 * 1024) extern int amdgpu_vcnfw_log; extern int amdgpu_sg_display; +extern uint amdgpu_ctf_delay; #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD(256*1024*1024) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 749eeb9a2976..6c699fefdf92 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -198,6 +198,7 @@ int amdgpu_smartshift_bias; int amdgpu_use_xgmi_p2p = 1; int amdgpu_vcnfw_log; int amdgpu_sg_display = -1; /* auto */ +uint amdgpu_ctf_delay = 50; /* in ms */ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -973,6 +974,19 @@ MODULE_PARM_DESC(smu_pptable_id, "specify pptable id to be used (-1 = auto(default) value, 0 = use pptable from vbios, > 0 = soft pptable id)"); module_param_named(smu_pptable_id, amdgpu_smu_pptable_id, int, 0444); +/** + * DOC: ctf_delay (uint) + * On SW CTF triggerred, to protect the chip from over-heated and possible damage, we usually + * trigger a system shutdown. However, considering there may be a hotspot temperature spark + * momentarily hitting the SW CTF setting point, a delay is added to avoid unintended shutdown. + * On the delay expired, the shutdown will be performed if the hotspot temp is still + * bigger than the SW CTF setting. Otherwise, nothing will be done. + * The default setting for the delay is 50ms. + */ +MODULE_PARM_DESC(ctf_delay, + "the delay(default 50ms) enforced before real action taken on ctf triggerred"); +module_param_named(ctf_delay, amdgpu_ctf_delay, uint, 0444); + /* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */ diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 3c860939031e..71153b335ad9 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -24,6 +24,7 @@ #include #include +#include #include "amdgpu.h" #include "amdgpu_smu.h" @@ -1070,6 +1071,34 @@ static void smu_interrupt_work_fn(struct work_struct *work) smu->ppt_funcs->interrupt_work(smu); } +static void smu_swctf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = + container_of(work, struct smu_context, swctf_delayed_work.work); + struct smu_temperature_range *range = + &smu->thermal_range; + struct amdgpu_device *adev = smu->adev; + uint32_t hotspot_tmp, size; + + /* +* If the hotspot temperature is confirmed as below SW CTF setting point +* after the delay enforced, nothing will be done. +* Otherwise, a graceful shutdown will be performed to prevent further damage. +*/ + if (smu->ppt_funcs->read_sensor && + !smu->ppt_funcs->read_sensor(smu, +AMDGPU_PP_SENSOR_HOTSPOT_TEMP, +&hotspot_tmp, +&size) && + range->software_shutdown_temp && + hotspot_tmp / 1000 < range->software_shutdown_temp) + return; + + dev_emerg(adev->dev, "ERROR: GPU over temperature range(SW CTF) detected!\n"); + dev_emerg(adev->dev, "ERROR: System is going to shutdown due to GPU SW CTF!\n"); + orderly_poweroff(true); +} + static int smu_sw_init(void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; @@ -1358,6 +1387,9 @@ static int smu_smc_hw_setup(struct smu_context *smu) return ret; } + INIT_DELAYED_WORK(&smu->swctf_delayed_work, + smu_swctf_delayed_work_handler); + ret = smu_enable_thermal_alert(smu); if (ret) { dev_err(adev->dev, "Failed to enable thermal alert!\n"); @@ -1592,6 +1624,8 @@ static int smu_smc_hw_cleanup(struct smu_co
[PATCH v3 2/6] drm/amdgpu: add RAS POISON interrupt funcs for vcn_v2_6
Add ras_poison_irq and functions. Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 24 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c index 7044bd7c9f62..52f1a90b0bb6 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c @@ -143,7 +143,7 @@ static int vcn_v2_5_sw_init(void *handle) /* VCN POISON TRAP */ r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_vcns[j], - VCN_2_6__SRCID_UVD_POISON, &adev->vcn.inst[j].irq); + VCN_2_6__SRCID_UVD_POISON, &adev->vcn.inst[j].ras_poison_irq); if (r) return r; } @@ -354,6 +354,9 @@ static int vcn_v2_5_hw_fini(void *handle) (adev->vcn.cur_state != AMD_PG_STATE_GATE && RREG32_SOC15(VCN, i, mmUVD_STATUS))) vcn_v2_5_set_powergating_state(adev, AMD_PG_STATE_GATE); + + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__VCN)) + amdgpu_irq_put(adev, &adev->vcn.inst[i].ras_poison_irq, 0); } return 0; @@ -1807,6 +1810,14 @@ static int vcn_v2_5_set_interrupt_state(struct amdgpu_device *adev, return 0; } +static int vcn_v2_6_set_ras_interrupt_state(struct amdgpu_device *adev, + struct amdgpu_irq_src *source, + unsigned int type, + enum amdgpu_interrupt_state state) +{ + return 0; +} + static int vcn_v2_5_process_interrupt(struct amdgpu_device *adev, struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry) @@ -1837,9 +1848,6 @@ static int vcn_v2_5_process_interrupt(struct amdgpu_device *adev, case VCN_2_0__SRCID__UVD_ENC_LOW_LATENCY: amdgpu_fence_process(&adev->vcn.inst[ip_instance].ring_enc[1]); break; - case VCN_2_6__SRCID_UVD_POISON: - amdgpu_vcn_process_poison_irq(adev, source, entry); - break; default: DRM_ERROR("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data[0]); @@ -1854,6 +1862,11 @@ static const struct amdgpu_irq_src_funcs vcn_v2_5_irq_funcs = { .process = vcn_v2_5_process_interrupt, }; +static const struct amdgpu_irq_src_funcs vcn_v2_6_ras_irq_funcs = { + .set = vcn_v2_6_set_ras_interrupt_state, + .process = amdgpu_vcn_process_poison_irq, +}; + static void vcn_v2_5_set_irq_funcs(struct amdgpu_device *adev) { int i; @@ -1863,6 +1876,9 @@ static void vcn_v2_5_set_irq_funcs(struct amdgpu_device *adev) continue; adev->vcn.inst[i].irq.num_types = adev->vcn.num_enc_rings + 1; adev->vcn.inst[i].irq.funcs = &vcn_v2_5_irq_funcs; + + adev->vcn.inst[i].ras_poison_irq.num_types = adev->vcn.num_enc_rings + 1; + adev->vcn.inst[i].ras_poison_irq.funcs = &vcn_v2_6_ras_irq_funcs; } } -- 2.34.1
[PATCH v3 1/6] drm/amdgpu: separate ras irq from vcn instance irq for UVD_POISON
Separate vcn RAS poison consumption handling from the instance irq, and register dedicated ras_poison_irq src and funcs for UVD_POISON. v2: - Separate ras irq from vcn instance irq - Improve the subject and code comments v3: - Split the patch into three parts - Improve the code comments Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 27 - drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index 06ec2dc55857..38f6ba281853 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c @@ -1189,6 +1189,31 @@ int amdgpu_vcn_process_poison_irq(struct amdgpu_device *adev, return 0; } +int amdgpu_vcn_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block) +{ + int r, i; + + r = amdgpu_ras_block_late_init(adev, ras_block); + if (r) + return r; + + if (amdgpu_ras_is_supported(adev, ras_block->block)) { + for (i = 0; i < adev->vcn.num_vcn_inst; i++) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + + r = amdgpu_irq_get(adev, &adev->vcn.inst[i].ras_poison_irq, 0); + if (r) + goto late_fini; + } + } + return 0; + +late_fini: + amdgpu_ras_block_late_fini(adev, ras_block); + return r; +} + int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev) { int err; @@ -1210,7 +1235,7 @@ int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev) adev->vcn.ras_if = &ras->ras_block.ras_comm; if (!ras->ras_block.ras_late_init) - ras->ras_block.ras_late_init = amdgpu_ras_block_late_init; + ras->ras_block.ras_late_init = amdgpu_vcn_ras_late_init; return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h index 1eb9ccd1d83d..92d5534df5f4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h @@ -239,6 +239,7 @@ struct amdgpu_vcn_inst { struct amdgpu_ring ring_enc[AMDGPU_VCN_MAX_ENC_RINGS]; atomic_tsched_score; struct amdgpu_irq_src irq; + struct amdgpu_irq_src ras_poison_irq; struct amdgpu_vcn_reg external; struct amdgpu_bo*dpg_sram_bo; struct dpg_pause_state pause_state; @@ -409,6 +410,8 @@ void amdgpu_debugfs_vcn_fwlog_init(struct amdgpu_device *adev, int amdgpu_vcn_process_poison_irq(struct amdgpu_device *adev, struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry); +int amdgpu_vcn_ras_late_init(struct amdgpu_device *adev, + struct ras_common_if *ras_block); int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev); #endif -- 2.34.1
[PATCH v3 3/6] drm/amdgpu: add RAS POISON interrupt funcs for vcn_v4_0
Add ras_poison_irq and functions. And fix the amdgpu_irq_put call trace in vcn_v4_0_hw_fini. [ 44.563572] RIP: 0010:amdgpu_irq_put+0xa4/0xc0 [amdgpu] [ 44.563629] RSP: 0018:b36740edfc90 EFLAGS: 00010246 [ 44.563630] RAX: RBX: 0001 RCX: [ 44.563630] RDX: RSI: RDI: [ 44.563631] RBP: b36740edfcb0 R08: R09: [ 44.563631] R10: R11: R12: 954c568e2ea8 [ 44.563631] R13: R14: 954c568c R15: 954c568e2ea8 [ 44.563632] FS: () GS:954f584c() knlGS: [ 44.563632] CS: 0010 DS: ES: CR0: 80050033 [ 44.563633] CR2: 7f028741ba70 CR3: 00026ca1 CR4: 00750ee0 [ 44.563633] PKRU: 5554 [ 44.563633] Call Trace: [ 44.563634] [ 44.563634] vcn_v4_0_hw_fini+0x62/0x160 [amdgpu] [ 44.563700] vcn_v4_0_suspend+0x13/0x30 [amdgpu] [ 44.563755] amdgpu_device_ip_suspend_phase2+0x240/0x470 [amdgpu] [ 44.563806] amdgpu_device_ip_suspend+0x41/0x80 [amdgpu] [ 44.563858] amdgpu_device_pre_asic_reset+0xd9/0x4a0 [amdgpu] [ 44.563909] amdgpu_device_gpu_recover.cold+0x548/0xcf1 [amdgpu] [ 44.564006] amdgpu_debugfs_reset_work+0x4c/0x80 [amdgpu] [ 44.564061] process_one_work+0x21f/0x400 [ 44.564062] worker_thread+0x200/0x3f0 [ 44.564063] ? process_one_work+0x400/0x400 [ 44.564064] kthread+0xee/0x120 [ 44.564065] ? kthread_complete_and_exit+0x20/0x20 [ 44.564066] ret_from_fork+0x22/0x30 Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 35 ++- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c index 81446e6996df..b607122ab26b 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c @@ -139,7 +139,7 @@ static int vcn_v4_0_sw_init(void *handle) /* VCN POISON TRAP */ r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_vcns[i], - VCN_4_0__SRCID_UVD_POISON, &adev->vcn.inst[i].irq); + VCN_4_0__SRCID_UVD_POISON, &adev->vcn.inst[i].ras_poison_irq); if (r) return r; @@ -305,8 +305,8 @@ static int vcn_v4_0_hw_fini(void *handle) vcn_v4_0_set_powergating_state(adev, AMD_PG_STATE_GATE); } } - - amdgpu_irq_put(adev, &adev->vcn.inst[i].irq, 0); + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__VCN)) + amdgpu_irq_put(adev, &adev->vcn.inst[i].ras_poison_irq, 0); } return 0; @@ -1975,6 +1975,24 @@ static int vcn_v4_0_set_interrupt_state(struct amdgpu_device *adev, struct amdgp return 0; } +/** + * vcn_v4_0_set_ras_interrupt_state - set VCN block RAS interrupt state + * + * @adev: amdgpu_device pointer + * @source: interrupt sources + * @type: interrupt types + * @state: interrupt states + * + * Set VCN block RAS interrupt state + */ +static int vcn_v4_0_set_ras_interrupt_state(struct amdgpu_device *adev, + struct amdgpu_irq_src *source, + unsigned int type, + enum amdgpu_interrupt_state state) +{ + return 0; +} + /** * vcn_v4_0_process_interrupt - process VCN block interrupt * @@ -2007,9 +2025,6 @@ static int vcn_v4_0_process_interrupt(struct amdgpu_device *adev, struct amdgpu_ case VCN_4_0__SRCID__UVD_ENC_GENERAL_PURPOSE: amdgpu_fence_process(&adev->vcn.inst[ip_instance].ring_enc[0]); break; - case VCN_4_0__SRCID_UVD_POISON: - amdgpu_vcn_process_poison_irq(adev, source, entry); - break; default: DRM_ERROR("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data[0]); @@ -2024,6 +2039,11 @@ static const struct amdgpu_irq_src_funcs vcn_v4_0_irq_funcs = { .process = vcn_v4_0_process_interrupt, }; +static const struct amdgpu_irq_src_funcs vcn_v4_0_ras_irq_funcs = { + .set = vcn_v4_0_set_ras_interrupt_state, + .process = amdgpu_vcn_process_poison_irq, +}; + /** * vcn_v4_0_set_irq_funcs - set VCN block interrupt irq functions * @@ -2041,6 +2061,9 @@ static void vcn_v4_0_set_irq_funcs(struct amdgpu_device *adev) adev->vcn.inst[i].irq.num_types = adev->vcn.num_enc_rings + 1; adev->vcn.inst[i].irq.funcs = &vcn_v4_0_irq_funcs; + + adev->vcn.inst[i].ras_poison_irq.num_types = adev->vcn.num_enc_rings + 1; + adev->vcn.inst[i].ras_poison_irq.funcs = &vcn_v4_0_ras_irq_funcs; } } -- 2.34.1
[PATCH v3 4/6] drm/amdgpu: separate ras irq from jpeg instance irq for UVD_POISON
Separate jpegbRAS poison consumption handling from the instance irq, and register dedicated ras_poison_irq src and funcs for UVD_POISON. v2: - Separate ras irq from jpeg instance irq - Improve the subject and code comments v3: - Split the patch into three parts - Improve the code comments Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 27 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c index 8c479669c459..3add4b4f0667 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c @@ -245,6 +245,31 @@ int amdgpu_jpeg_process_poison_irq(struct amdgpu_device *adev, return 0; } +int amdgpu_jpeg_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block) +{ + int r, i; + + r = amdgpu_ras_block_late_init(adev, ras_block); + if (r) + return r; + + if (amdgpu_ras_is_supported(adev, ras_block->block)) { + for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) { + if (adev->jpeg.harvest_config & (1 << i)) + continue; + + r = amdgpu_irq_get(adev, &adev->jpeg.inst[i].ras_poison_irq, 0); + if (r) + goto late_fini; + } + } + return 0; + +late_fini: + amdgpu_ras_block_late_fini(adev, ras_block); + return r; +} + int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev) { int err; @@ -266,7 +291,7 @@ int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev) adev->jpeg.ras_if = &ras->ras_block.ras_comm; if (!ras->ras_block.ras_late_init) - ras->ras_block.ras_late_init = amdgpu_ras_block_late_init; + ras->ras_block.ras_late_init = amdgpu_jpeg_ras_late_init; return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h index 90516f623f56..ffe47e9f5bf2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h @@ -39,6 +39,7 @@ struct amdgpu_jpeg_reg{ struct amdgpu_jpeg_inst { struct amdgpu_ring ring_dec[AMDGPU_MAX_JPEG_RINGS]; struct amdgpu_irq_src irq; + struct amdgpu_irq_src ras_poison_irq; struct amdgpu_jpeg_reg external; uint8_t aid_id; }; @@ -78,6 +79,8 @@ int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout); int amdgpu_jpeg_process_poison_irq(struct amdgpu_device *adev, struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry); +int amdgpu_jpeg_ras_late_init(struct amdgpu_device *adev, + struct ras_common_if *ras_block); int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev); #endif /*__AMDGPU_JPEG_H__*/ -- 2.34.1
[PATCH v3 5/6] drm/amdgpu: add RAS POISON interrupt funcs for jpeg_v2_6
Add ras_poison_irq and functions. Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 27 -- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c index b79edb12b90e..3c83f0578113 100644 --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c @@ -102,13 +102,13 @@ static int jpeg_v2_5_sw_init(void *handle) /* JPEG DJPEG POISON EVENT */ r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_jpeg[i], - VCN_2_6__SRCID_DJPEG0_POISON, &adev->jpeg.inst[i].irq); + VCN_2_6__SRCID_DJPEG0_POISON, &adev->jpeg.inst[i].ras_poison_irq); if (r) return r; /* JPEG EJPEG POISON EVENT */ r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_jpeg[i], - VCN_2_6__SRCID_EJPEG0_POISON, &adev->jpeg.inst[i].irq); + VCN_2_6__SRCID_EJPEG0_POISON, &adev->jpeg.inst[i].ras_poison_irq); if (r) return r; } @@ -221,6 +221,9 @@ static int jpeg_v2_5_hw_fini(void *handle) if (adev->jpeg.cur_state != AMD_PG_STATE_GATE && RREG32_SOC15(JPEG, i, mmUVD_JRBC_STATUS)) jpeg_v2_5_set_powergating_state(adev, AMD_PG_STATE_GATE); + + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__JPEG)) + amdgpu_irq_put(adev, &adev->jpeg.inst[i].ras_poison_irq, 0); } return 0; @@ -569,6 +572,14 @@ static int jpeg_v2_5_set_interrupt_state(struct amdgpu_device *adev, return 0; } +static int jpeg_v2_6_set_ras_interrupt_state(struct amdgpu_device *adev, + struct amdgpu_irq_src *source, + unsigned int type, + enum amdgpu_interrupt_state state) +{ + return 0; +} + static int jpeg_v2_5_process_interrupt(struct amdgpu_device *adev, struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry) @@ -593,10 +604,6 @@ static int jpeg_v2_5_process_interrupt(struct amdgpu_device *adev, case VCN_2_0__SRCID__JPEG_DECODE: amdgpu_fence_process(adev->jpeg.inst[ip_instance].ring_dec); break; - case VCN_2_6__SRCID_DJPEG0_POISON: - case VCN_2_6__SRCID_EJPEG0_POISON: - amdgpu_jpeg_process_poison_irq(adev, source, entry); - break; default: DRM_ERROR("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data[0]); @@ -725,6 +732,11 @@ static const struct amdgpu_irq_src_funcs jpeg_v2_5_irq_funcs = { .process = jpeg_v2_5_process_interrupt, }; +static const struct amdgpu_irq_src_funcs jpeg_v2_6_ras_irq_funcs = { + .set = jpeg_v2_6_set_ras_interrupt_state, + .process = amdgpu_jpeg_process_poison_irq, +}; + static void jpeg_v2_5_set_irq_funcs(struct amdgpu_device *adev) { int i; @@ -735,6 +747,9 @@ static void jpeg_v2_5_set_irq_funcs(struct amdgpu_device *adev) adev->jpeg.inst[i].irq.num_types = 1; adev->jpeg.inst[i].irq.funcs = &jpeg_v2_5_irq_funcs; + + adev->jpeg.inst[i].ras_poison_irq.num_types = 1; + adev->jpeg.inst[i].ras_poison_irq.funcs = &jpeg_v2_6_ras_irq_funcs; } } -- 2.34.1
[PATCH v3 6/6] drm/amdgpu: add RAS POISON interrupt funcs for jpeg_v4_0
Add ras_poison_irq and functions. And fix the amdgpu_irq_put call trace in jpeg_v4_0_hw_fini. [ 50.497562] RIP: 0010:amdgpu_irq_put+0xa4/0xc0 [amdgpu] [ 50.497619] RSP: 0018:aa2400fcfcb0 EFLAGS: 00010246 [ 50.497620] RAX: RBX: 0001 RCX: [ 50.497621] RDX: RSI: RDI: [ 50.497621] RBP: aa2400fcfcd0 R08: R09: [ 50.497622] R10: R11: R12: 99b2105242d8 [ 50.497622] R13: R14: 99b21050 R15: 99b21050 [ 50.497623] FS: () GS:99b51848() knlGS: [ 50.497623] CS: 0010 DS: ES: CR0: 80050033 [ 50.497624] CR2: 7f9d32aa91e8 CR3: 0001ba21 CR4: 00750ee0 [ 50.497624] PKRU: 5554 [ 50.497625] Call Trace: [ 50.497625] [ 50.497627] jpeg_v4_0_hw_fini+0x43/0xc0 [amdgpu] [ 50.497693] jpeg_v4_0_suspend+0x13/0x30 [amdgpu] [ 50.497751] amdgpu_device_ip_suspend_phase2+0x240/0x470 [amdgpu] [ 50.497802] amdgpu_device_ip_suspend+0x41/0x80 [amdgpu] [ 50.497854] amdgpu_device_pre_asic_reset+0xd9/0x4a0 [amdgpu] [ 50.497905] amdgpu_device_gpu_recover.cold+0x548/0xcf1 [amdgpu] [ 50.498005] amdgpu_debugfs_reset_work+0x4c/0x80 [amdgpu] [ 50.498060] process_one_work+0x21f/0x400 [ 50.498063] worker_thread+0x200/0x3f0 [ 50.498064] ? process_one_work+0x400/0x400 [ 50.498065] kthread+0xee/0x120 [ 50.498067] ? kthread_complete_and_exit+0x20/0x20 [ 50.498068] ret_from_fork+0x22/0x30 Suggested-by: Hawking Zhang Signed-off-by: Horatio Zhang --- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 27 +++--- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c index 495facb885f4..8690467b3285 100644 --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c @@ -87,13 +87,13 @@ static int jpeg_v4_0_sw_init(void *handle) /* JPEG DJPEG POISON EVENT */ r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VCN, - VCN_4_0__SRCID_DJPEG0_POISON, &adev->jpeg.inst->irq); + VCN_4_0__SRCID_DJPEG0_POISON, &adev->jpeg.inst->ras_poison_irq); if (r) return r; /* JPEG EJPEG POISON EVENT */ r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VCN, - VCN_4_0__SRCID_EJPEG0_POISON, &adev->jpeg.inst->irq); + VCN_4_0__SRCID_EJPEG0_POISON, &adev->jpeg.inst->ras_poison_irq); if (r) return r; @@ -202,7 +202,8 @@ static int jpeg_v4_0_hw_fini(void *handle) RREG32_SOC15(JPEG, 0, regUVD_JRBC_STATUS)) jpeg_v4_0_set_powergating_state(adev, AMD_PG_STATE_GATE); } - amdgpu_irq_put(adev, &adev->jpeg.inst->irq, 0); + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__JPEG)) + amdgpu_irq_put(adev, &adev->jpeg.inst->ras_poison_irq, 0); return 0; } @@ -670,6 +671,14 @@ static int jpeg_v4_0_set_interrupt_state(struct amdgpu_device *adev, return 0; } +static int jpeg_v4_0_set_ras_interrupt_state(struct amdgpu_device *adev, + struct amdgpu_irq_src *source, + unsigned int type, + enum amdgpu_interrupt_state state) +{ + return 0; +} + static int jpeg_v4_0_process_interrupt(struct amdgpu_device *adev, struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry) @@ -680,10 +689,6 @@ static int jpeg_v4_0_process_interrupt(struct amdgpu_device *adev, case VCN_4_0__SRCID__JPEG_DECODE: amdgpu_fence_process(adev->jpeg.inst->ring_dec); break; - case VCN_4_0__SRCID_DJPEG0_POISON: - case VCN_4_0__SRCID_EJPEG0_POISON: - amdgpu_jpeg_process_poison_irq(adev, source, entry); - break; default: DRM_DEV_ERROR(adev->dev, "Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data[0]); @@ -753,10 +758,18 @@ static const struct amdgpu_irq_src_funcs jpeg_v4_0_irq_funcs = { .process = jpeg_v4_0_process_interrupt, }; +static const struct amdgpu_irq_src_funcs jpeg_v4_0_ras_irq_funcs = { + .set = jpeg_v4_0_set_ras_interrupt_state, + .process = amdgpu_jpeg_process_poison_irq, +}; + static void jpeg_v4_0_set_irq_funcs(struct amdgpu_device *adev) { adev->jpeg.inst->irq.num_types = 1; adev->jpeg.inst->irq.funcs = &jpeg_v4_0_irq_funcs; + + adev->jpeg.inst->ras_poison_irq.num_types = 1; + adev->jpeg.inst->ras_poison_irq.funcs = &jpeg_v4_0_ras_irq_funcs; } const struct amdgpu_ip_block_version jp
RE: [PATCH v3 6/6] drm/amdgpu: add RAS POISON interrupt funcs for jpeg_v4_0
[AMD Official Use Only - General] The series is: Reviewed-by: Tao Zhou > -Original Message- > From: amd-gfx On Behalf Of Horatio > Zhang > Sent: Tuesday, May 16, 2023 1:04 PM > To: amd-gfx@lists.freedesktop.org > Cc: Liu, HaoPing (Alan) ; Zhou, Bob > ; Zhang, Horatio ; Xu, Feifei > ; Zhou1, Tao ; Jiang, Sonny > ; Limonciello, Mario ; > Liu, Leo ; Zhang, Hawking > Subject: [PATCH v3 6/6] drm/amdgpu: add RAS POISON interrupt funcs for > jpeg_v4_0 > > Add ras_poison_irq and functions. And fix the amdgpu_irq_put call trace in > jpeg_v4_0_hw_fini. > > [ 50.497562] RIP: 0010:amdgpu_irq_put+0xa4/0xc0 [amdgpu] > [ 50.497619] RSP: 0018:aa2400fcfcb0 EFLAGS: 00010246 > [ 50.497620] RAX: RBX: 0001 RCX: > > [ 50.497621] RDX: RSI: RDI: > > [ 50.497621] RBP: aa2400fcfcd0 R08: R09: > > [ 50.497622] R10: R11: R12: > 99b2105242d8 > [ 50.497622] R13: R14: 99b21050 R15: > 99b21050 > [ 50.497623] FS: () GS:99b51848() > knlGS: > [ 50.497623] CS: 0010 DS: ES: CR0: 80050033 > [ 50.497624] CR2: 7f9d32aa91e8 CR3: 0001ba21 CR4: > 00750ee0 > [ 50.497624] PKRU: 5554 > [ 50.497625] Call Trace: > [ 50.497625] > [ 50.497627] jpeg_v4_0_hw_fini+0x43/0xc0 [amdgpu] > [ 50.497693] jpeg_v4_0_suspend+0x13/0x30 [amdgpu] > [ 50.497751] amdgpu_device_ip_suspend_phase2+0x240/0x470 [amdgpu] > [ 50.497802] amdgpu_device_ip_suspend+0x41/0x80 [amdgpu] > [ 50.497854] amdgpu_device_pre_asic_reset+0xd9/0x4a0 [amdgpu] > [ 50.497905] amdgpu_device_gpu_recover.cold+0x548/0xcf1 [amdgpu] > [ 50.498005] amdgpu_debugfs_reset_work+0x4c/0x80 [amdgpu] > [ 50.498060] process_one_work+0x21f/0x400 > [ 50.498063] worker_thread+0x200/0x3f0 > [ 50.498064] ? process_one_work+0x400/0x400 > [ 50.498065] kthread+0xee/0x120 > [ 50.498067] ? kthread_complete_and_exit+0x20/0x20 > [ 50.498068] ret_from_fork+0x22/0x30 > > Suggested-by: Hawking Zhang > Signed-off-by: Horatio Zhang > --- > drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 27 +++--- > 1 file changed, 20 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c > b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c > index 495facb885f4..8690467b3285 100644 > --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c > @@ -87,13 +87,13 @@ static int jpeg_v4_0_sw_init(void *handle) > > /* JPEG DJPEG POISON EVENT */ > r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VCN, > - VCN_4_0__SRCID_DJPEG0_POISON, &adev->jpeg.inst- > >irq); > + VCN_4_0__SRCID_DJPEG0_POISON, &adev->jpeg.inst- > >ras_poison_irq); > if (r) > return r; > > /* JPEG EJPEG POISON EVENT */ > r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VCN, > - VCN_4_0__SRCID_EJPEG0_POISON, &adev->jpeg.inst- > >irq); > + VCN_4_0__SRCID_EJPEG0_POISON, &adev->jpeg.inst- > >ras_poison_irq); > if (r) > return r; > > @@ -202,7 +202,8 @@ static int jpeg_v4_0_hw_fini(void *handle) > RREG32_SOC15(JPEG, 0, regUVD_JRBC_STATUS)) > jpeg_v4_0_set_powergating_state(adev, > AMD_PG_STATE_GATE); > } > - amdgpu_irq_put(adev, &adev->jpeg.inst->irq, 0); > + if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__JPEG)) > + amdgpu_irq_put(adev, &adev->jpeg.inst->ras_poison_irq, 0); > > return 0; > } > @@ -670,6 +671,14 @@ static int jpeg_v4_0_set_interrupt_state(struct > amdgpu_device *adev, > return 0; > } > > +static int jpeg_v4_0_set_ras_interrupt_state(struct amdgpu_device *adev, > + struct amdgpu_irq_src *source, > + unsigned int type, > + enum amdgpu_interrupt_state state) { > + return 0; > +} > + > static int jpeg_v4_0_process_interrupt(struct amdgpu_device *adev, > struct amdgpu_irq_src *source, > struct amdgpu_iv_entry *entry) @@ -680,10 > +689,6 @@ static int jpeg_v4_0_process_interrupt(struct amdgpu_device *adev, > case VCN_4_0__SRCID__JPEG_DECODE: > amdgpu_fence_process(adev->jpeg.inst->ring_dec); > break; > - case VCN_4_0__SRCID_DJPEG0_POISON: > - case VCN_4_0__SRCID_EJPEG0_POISON: > - amdgpu_jpeg_process_poison_irq(adev, source, entry); > - break; > default: > DRM_DEV_ERROR(adev->dev, "Unhandled interrupt: %d %d\n", > entry->src_id, entry->src_data[0]); @@ -753,10 > +758,18 @@ static const struct amdgpu_irq_src_funcs jpeg_v
Re: [PATCH] drm/amdgpu: Fix the EPERM error when get user pages
On 5/16/2023 5:03 AM, Deucher, Alexander wrote: > [AMD Official Use Only - General] > >> -Original Message- >> From: amd-gfx On Behalf Of Ma >> Jun >> Sent: Monday, May 15, 2023 2:14 AM >> To: amd-gfx@lists.freedesktop.org >> Cc: Sierra Guiza, Alejandro (Alex) ; Ma, Jun >> ; Kuehling, Felix ; Koenig, >> Christian >> Subject: [PATCH] drm/amdgpu: Fix the EPERM error when get user pages >> >> Check and pass the readonly flags when set amdgpu_ttm_tt flags >> >> for readonly ptr pages. Otherwise, there is EPERM error returned >> >> during the KFDExceptionTest.PermissionFaultUserPointer test on >> >> ploaris10. >> >> Signed-off-by: Ma Jun >> --- >> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 - >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c >> index d426333e865a..85d1087439c0 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c >> @@ -1036,10 +1036,17 @@ static int init_user_pages(struct kgd_mem >> *mem, uint64_t user_addr, >> struct ttm_operation_ctx ctx = { true, false }; >> struct hmm_range *range; >> int ret = 0; >> +uint32_t tt_flags = 0; >> >> mutex_lock(&process_info->lock); >> >> -ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, 0); >> +if(!(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE)) > > Space between the if and (. E.g., if ( Thanks, will fix in next version. Regards, Ma Jun > > Alex > >> +tt_flags |= AMDGPU_GEM_USERPTR_READONLY; >> +else >> +tt_flags = 0; >> + >> + >> +ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, tt_flags); >> if (ret) { >> pr_err("%s: Failed to set userptr: %d\n", __func__, ret); >> goto out; >> -- >> 2.34.1