amdxdna_gem_vmap() logs an error whenever the mapping fails, which suits its callers: each of them treats a failure as fatal to the operation it is performing. The next patch adds one that does not, and an exporter that implements no vmap op fails every call without anything caching that, so a logging probe would print on every ioctl.
Split the mapping out into __amdxdna_gem_vmap(), which returns the error, and leave amdxdna_gem_vmap() as that plus the log. No caller changes: it still returns the address, or NULL after logging. The log takes the device from the GEM object rather than from abo->client. amdxdna_gem_obj_close() clears that pointer once the last handle to the BO is closed, which a job holding its own reference can outlive. Signed-off-by: Taimuraz Kaitmazov <[email protected]> --- drivers/accel/amdxdna/amdxdna_gem.c | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c index b66ec9e48..1b8e90cd7 100644 --- a/drivers/accel/amdxdna/amdxdna_gem.c +++ b/drivers/accel/amdxdna/amdxdna_gem.c @@ -191,12 +191,8 @@ amdxdna_gem_destroy_obj(struct amdxdna_gem_obj *abo) kfree(abo); } -/* - * Obtains a kernel virtual address on the BO (usually of small size). - * The mapping is established on the first call and stays valid until - * amdxdna_gem_vunmap() is called. - */ -void *amdxdna_gem_vmap(struct amdxdna_gem_obj *abo) +/* Returns the error instead of logging it. */ +static void *__amdxdna_gem_vmap(struct amdxdna_gem_obj *abo) { struct iosys_map map = IOSYS_MAP_INIT_VADDR(NULL); int ret; @@ -210,13 +206,29 @@ void *amdxdna_gem_vmap(struct amdxdna_gem_obj *abo) if (!abo->mem.kva) { ret = drm_gem_vmap(to_gobj(abo), &map); if (ret) - XDNA_ERR(abo->client->xdna, "Vmap bo failed, ret %d", ret); - else - abo->mem.kva = map.vaddr; + return ERR_PTR(ret); + abo->mem.kva = map.vaddr; } return abo->mem.kva; } +/* + * Obtains a kernel virtual address on the BO (usually of small size). + * The mapping is established on the first call and stays valid until + * amdxdna_gem_vunmap() is called. + */ +void *amdxdna_gem_vmap(struct amdxdna_gem_obj *abo) +{ + void *kva = __amdxdna_gem_vmap(abo); + + if (IS_ERR(kva)) { + XDNA_ERR(to_xdna_dev(to_gobj(abo)->dev), "Vmap bo failed, ret %ld", + PTR_ERR(kva)); + return NULL; + } + return kva; +} + /* * Free mapping established through amdxdna_gem_vmap() */ -- 2.55.0
