mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: Update KMDI mapping interface
Finding gpu va mapping inside a given range is a two step process where in first step number of mapping are queried and at second step it queries for all the continues mapping range for that given gpu va range. Mapping interface should count and return number of mappings if input count is 0 in place of failing it. Patch make the change for this two step process and only returns count at first step and in second step returns the continues memory ranges. Patch also replaces nvgpu_zalloc with nvgpu_big_zalloc to handle bigger size allocation. Bug 200722275 Change-Id: I56428deafa560ac8471c78f102bb1f9dbe20cabc Signed-off-by: prsethi <prsethi@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2591043 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
79ab0ba6c4
commit
dd94573e55
@@ -2300,6 +2300,7 @@ static void nvgpu_dbg_gpu_get_valid_mappings(struct nvgpu_channel *ch, u64 start
|
|||||||
struct dma_buf *dmabuf = NULL;
|
struct dma_buf *dmabuf = NULL;
|
||||||
u32 f_mode = FMODE_READ;
|
u32 f_mode = FMODE_READ;
|
||||||
u32 count = 0;
|
u32 count = 0;
|
||||||
|
bool just_count = *buf_count ? false : true;
|
||||||
|
|
||||||
nvgpu_mutex_acquire(&vm->update_gmmu_lock);
|
nvgpu_mutex_acquire(&vm->update_gmmu_lock);
|
||||||
|
|
||||||
@@ -2340,10 +2341,14 @@ static void nvgpu_dbg_gpu_get_valid_mappings(struct nvgpu_channel *ch, u64 start
|
|||||||
} else {
|
} else {
|
||||||
size = min(end, mbuf_curr->addr
|
size = min(end, mbuf_curr->addr
|
||||||
+ mbuf_curr->size) - key;
|
+ mbuf_curr->size) - key;
|
||||||
buffer[count].gpu_va = mbuf_curr->addr;
|
if (just_count == false) {
|
||||||
|
buffer[count].gpu_va = mbuf_curr->addr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[count].size = size;
|
if (just_count == false) {
|
||||||
|
buffer[count].size = size;
|
||||||
|
}
|
||||||
|
|
||||||
(count)++;
|
(count)++;
|
||||||
if (count == count_lmt) {
|
if (count == count_lmt) {
|
||||||
@@ -2368,7 +2373,7 @@ static int nvgpu_dbg_gpu_get_mappings(struct dbg_session_gk20a *dbg_s,
|
|||||||
struct nvgpu_channel *ch;
|
struct nvgpu_channel *ch;
|
||||||
u64 start = arg->va_lo;
|
u64 start = arg->va_lo;
|
||||||
u64 end = arg->va_hi;
|
u64 end = arg->va_hi;
|
||||||
u32 count_in = 0U;
|
u32 count_in = arg->count;
|
||||||
u32 buf_len = 0U;
|
u32 buf_len = 0U;
|
||||||
struct nvgpu_dbg_gpu_get_mappings_entry *buffer = NULL;
|
struct nvgpu_dbg_gpu_get_mappings_entry *buffer = NULL;
|
||||||
|
|
||||||
@@ -2377,12 +2382,6 @@ static int nvgpu_dbg_gpu_get_mappings(struct dbg_session_gk20a *dbg_s,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
count_in = arg->count;
|
|
||||||
if (count_in == 0U) {
|
|
||||||
nvgpu_err(g, "Invalid input param");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gk20a_busy(g);
|
err = gk20a_busy(g);
|
||||||
if (err) {
|
if (err) {
|
||||||
nvgpu_err(g, "failed to poweron");
|
nvgpu_err(g, "failed to poweron");
|
||||||
@@ -2396,11 +2395,18 @@ static int nvgpu_dbg_gpu_get_mappings(struct dbg_session_gk20a *dbg_s,
|
|||||||
goto clean_up;
|
goto clean_up;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf_len = sizeof(*buffer) * count_in;
|
if (count_in) {
|
||||||
buffer = nvgpu_kzalloc(g, buf_len);
|
if (arg->ops_buffer == 0UL) {
|
||||||
if (!buffer) {
|
err = -EINVAL;
|
||||||
err = -ENOMEM;
|
nvgpu_err(g, "ops_buffer is pointing to NULL");
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
|
}
|
||||||
|
buf_len = sizeof(*buffer) * count_in;
|
||||||
|
buffer = nvgpu_kzalloc(g, buf_len);
|
||||||
|
if (!buffer) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto clean_up;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nvgpu_dbg_gpu_get_valid_mappings(ch, start, end, &arg->count,
|
nvgpu_dbg_gpu_get_valid_mappings(ch, start, end, &arg->count,
|
||||||
@@ -2410,7 +2416,7 @@ static int nvgpu_dbg_gpu_get_mappings(struct dbg_session_gk20a *dbg_s,
|
|||||||
* Buffer will be copied to userspace only when arg->ops_buffer is not
|
* Buffer will be copied to userspace only when arg->ops_buffer is not
|
||||||
* 0. If value of arg->ops_buffer is 0 then interface only sets count.
|
* 0. If value of arg->ops_buffer is 0 then interface only sets count.
|
||||||
*/
|
*/
|
||||||
if (arg->ops_buffer) {
|
if (count_in) {
|
||||||
err = copy_to_user((void __user *)arg->ops_buffer, buffer,
|
err = copy_to_user((void __user *)arg->ops_buffer, buffer,
|
||||||
(arg->count * sizeof(*buffer)));
|
(arg->count * sizeof(*buffer)));
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
@@ -2674,11 +2680,11 @@ static int nvgpu_dbg_gpu_access_gpu_va(struct dbg_session_gk20a *dbg_s,
|
|||||||
|
|
||||||
if (size > allocated_size) {
|
if (size > allocated_size) {
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
nvgpu_kfree(g, buffer);
|
nvgpu_big_free(g, buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = nvgpu_kzalloc(g, size);
|
buffer = nvgpu_big_zalloc(g, size);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -2713,7 +2719,7 @@ static int nvgpu_dbg_gpu_access_gpu_va(struct dbg_session_gk20a *dbg_s,
|
|||||||
}
|
}
|
||||||
fail:
|
fail:
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
nvgpu_kfree(g, buffer);
|
nvgpu_big_free(g, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ops_buffer) {
|
if (ops_buffer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user