Re: [PATCH 1/2] drm/amdgpu: release the VM shadow in the error path as well
The series is Reviewed-by: Chunming Zhou On 2018年02月03日 04:17, Christian König wrote: Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 61cf93867b8e..b43098f02a40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -411,6 +411,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, r = amdgpu_vm_clear_bo(adev, vm, pt, level, ats); if (r) { + amdgpu_bo_unref(&pt->shadow); amdgpu_bo_unref(&pt); return r; } @@ -418,6 +419,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, if (vm->use_cpu_for_update) { r = amdgpu_bo_kmap(pt, NULL); if (r) { + amdgpu_bo_unref(&pt->shadow); amdgpu_bo_unref(&pt); return r; } ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 5/5] drm/amdgpu: replace iova debugfs file with iomem
Patch1 & 2 & 4, Reviewed-by: Roger He Patch 5: Acked-by: Roger He -Original Message- From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of Christian K?nig Sent: Saturday, February 03, 2018 3:10 AM To: amd-gfx@lists.freedesktop.org; dri-de...@lists.freedesktop.org Subject: [PATCH 5/5] drm/amdgpu: replace iova debugfs file with iomem This allows access to pages allocated through the driver with optional IOMMU mapping. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 57 - 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 648c449aaa79..795ceaeb82d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1929,38 +1929,51 @@ static const struct file_operations amdgpu_ttm_gtt_fops = { #endif -static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf, - size_t size, loff_t *pos) +static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, +size_t size, loff_t *pos) { struct amdgpu_device *adev = file_inode(f)->i_private; - int r; - uint64_t phys; struct iommu_domain *dom; + ssize_t result = 0; + int r; - // always return 8 bytes - if (size != 8) - return -EINVAL; + dom = iommu_get_domain_for_dev(adev->dev); - // only accept page addresses - if (*pos & 0xFFF) - return -EINVAL; + while (size) { + phys_addr_t addr = *pos & PAGE_MASK; + loff_t off = *pos & ~PAGE_MASK; + size_t bytes = PAGE_SIZE - off; + unsigned long pfn; + struct page *p; + void *ptr; - dom = iommu_get_domain_for_dev(adev->dev); - if (dom) - phys = iommu_iova_to_phys(dom, *pos); - else - phys = *pos; + addr = dom ? iommu_iova_to_phys(dom, addr) : addr; - r = copy_to_user(buf, &phys, 8); - if (r) - return -EFAULT; + pfn = addr >> PAGE_SHIFT; + if (!pfn_valid(pfn)) + return -EPERM; + + p = pfn_to_page(pfn); + if (p->mapping != adev->mman.bdev.dev_mapping) + return -EPERM; + + ptr = kmap(p); + r = copy_to_user(buf, ptr, bytes); + kunmap(p); + if (r) + return -EFAULT; - return 8; + size -= bytes; + *pos += bytes; + result += bytes; + } + + return result; } -static const struct file_operations amdgpu_ttm_iova_fops = { +static const struct file_operations amdgpu_ttm_iomem_fops = { .owner = THIS_MODULE, - .read = amdgpu_iova_to_phys_read, + .read = amdgpu_iomem_read, .llseek = default_llseek }; @@ -1973,7 +1986,7 @@ static const struct { #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS { "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT }, #endif - { "amdgpu_iova", &amdgpu_ttm_iova_fops, TTM_PL_SYSTEM }, + { "amdgpu_iomem", &amdgpu_ttm_iomem_fops, TTM_PL_SYSTEM }, }; #endif -- 2.14.1 ___ dri-devel mailing list dri-de...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 3/5] drm/radeon: remove extra TT unpopulated check
-Original Message- From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of Christian K?nig Sent: Saturday, February 03, 2018 3:10 AM To: amd-gfx@lists.freedesktop.org; dri-de...@lists.freedesktop.org Subject: [PATCH 3/5] drm/radeon: remove extra TT unpopulated check The subsystem chould check that, not the driver. Commit log typo, should be "should" rather than " chould". With that fix, this patch is Reviewed-by: Roger He Thanks Roger(Hongbo.He) Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_ttm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index a0a839bc39bf..42e3ee81a96e 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -728,9 +728,6 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm, struct radeon_device *rdev; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); - if (ttm->state != tt_unpopulated) - return 0; - if (gtt && gtt->userptr) { ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL); if (!ttm->sg) -- 2.14.1 ___ dri-devel mailing list dri-de...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH libdrm] admgpu: add amdgpu_query_sw_info for querying high bits of 32-bit address space
Just a typo in commit log: admgpu -> amdgpu Jerry On 02/03/2018 01:34 AM, Marek Olšák wrote: From: Marek Olšák --- amdgpu/amdgpu.h | 21 + amdgpu/amdgpu_device.c | 14 ++ amdgpu/amdgpu_internal.h | 1 + 3 files changed, 36 insertions(+) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 2eb03bf..928b2a6 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -87,20 +87,24 @@ enum amdgpu_bo_handle_type { amdgpu_bo_handle_type_dma_buf_fd = 2 }; /** Define known types of GPU VM VA ranges */ enum amdgpu_gpu_va_range { /** Allocate from "normal"/general range */ amdgpu_gpu_va_range_general = 0 }; +enum amdgpu_sw_info { + amdgpu_sw_info_address32_hi = 0, +}; + /*--*/ /* -- Datatypes --- */ /*--*/ /** * Define opaque pointer to context associated with fd. * This context will be returned as the result of * "initialize" function and should be pass as the first * parameter to any API call */ @@ -1079,20 +1083,37 @@ int amdgpu_query_gpu_info(amdgpu_device_handle dev, * \param value - \c [out] Pointer to the return value. * * \return 0 on success\n * <0 - Negative POSIX error code * */ int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, unsigned size, void *value); /** + * Query hardware or driver information. + * + * The return size is query-specific and depends on the "info_id" parameter. + * No more than "size" bytes is returned. + * + * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() + * \param info- \c [in] amdgpu_sw_info_* + * \param value - \c [out] Pointer to the return value. + * + * \return 0 on success\n + * <0 - Negative POSIX error code + * +*/ +int amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info, +void *value); + +/** * Query information about GDS * * \param dev- \c [in] Device handle. See #amdgpu_device_initialize() * \param gds_info - \c [out] Pointer to structure to get GDS information * * \return 0 on success\n * <0 - Negative POSIX Error code * */ int amdgpu_query_gds_info(amdgpu_device_handle dev, diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index f34e27a..6ee25a9 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -268,20 +268,21 @@ int amdgpu_device_initialize(int fd, start = dev->dev_info.high_va_offset; max = dev->dev_info.high_va_max; } else { start = dev->dev_info.virtual_address_offset; max = dev->dev_info.virtual_address_max; } max = MIN2(max, (start & ~0xULL) + 0x1ULL); amdgpu_vamgr_init(&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + dev->address32_hi = start >> 32; start = max; if (dev->dev_info.high_va_offset && dev->dev_info.high_va_max) max = dev->dev_info.high_va_max; else max = dev->dev_info.virtual_address_max; amdgpu_vamgr_init(&dev->vamgr, start, max, dev->dev_info.virtual_address_alignment); amdgpu_parse_asic_ids(dev); @@ -305,10 +306,23 @@ cleanup: int amdgpu_device_deinitialize(amdgpu_device_handle dev) { amdgpu_device_reference(&dev, NULL); return 0; } const char *amdgpu_get_marketing_name(amdgpu_device_handle dev) { return dev->marketing_name; } + +int amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info, +void *value) +{ + uint32_t *val32 = (uint32_t*)value; + + switch (info) { + case amdgpu_sw_info_address32_hi: + *val32 = dev->address32_hi; + return 0; + } + return -EINVAL; +} diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 3e044f1..802b162 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -68,20 +68,21 @@ struct amdgpu_va { enum amdgpu_gpu_va_range range; struct amdgpu_bo_va_mgr *vamgr; }; struct amdgpu_device { atomic_t refcount; int fd; int flink_fd; unsigned major_version; unsigned minor_version; + uint32_t address32_hi; char *marketing_name; /** List of buffer handles. Protected by bo_table_mutex. */ struct util_hash_table *bo_handles; /** List of buffer GEM flink names. Protected by bo_table_mutex. */ struct util_hash_table *bo_flink_names; /** This protects all hash tables. */ pthread_mutex_t bo_table_mutex; struct drm_amdgpu