Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

accel/amdxdna: Remove amdxdna_flush()

amdxdna_flush() was introduced to ensure that the device does not access
a process address space after it has been freed. However, this is no
longer necessary because the driver now increments the mm reference count
when a command is submitted and decrements it only after the command has
completed. This guarantees that the process address space remains valid
for the entire duration of command execution. Remove amdxdna_flush to
simplify the teardown path.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20251216031311.2033399-1-lizhi.hou@amd.com

Lizhi Hou e8c28e16 5c3c3e7b

+11 -18
+11 -18
drivers/accel/amdxdna/amdxdna_pci_drv.c
··· 105 105 return ret; 106 106 } 107 107 108 - static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp) 108 + static void amdxdna_client_cleanup(struct amdxdna_client *client) 109 109 { 110 - struct amdxdna_client *client = filp->driver_priv; 111 - struct amdxdna_dev *xdna = to_xdna_dev(ddev); 112 - 113 - XDNA_DBG(xdna, "closing pid %d", client->pid); 114 - 110 + list_del(&client->node); 111 + amdxdna_hwctx_remove_all(client); 115 112 xa_destroy(&client->hwctx_xa); 116 113 cleanup_srcu_struct(&client->hwctx_srcu); 117 114 mutex_destroy(&client->mm_lock); 115 + 118 116 if (client->dev_heap) 119 117 drm_gem_object_put(to_gobj(client->dev_heap)); 120 118 121 119 iommu_sva_unbind_device(client->sva); 122 120 123 - XDNA_DBG(xdna, "pid %d closed", client->pid); 124 121 kfree(client); 125 122 } 126 123 127 - static int amdxdna_flush(struct file *f, fl_owner_t id) 124 + static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp) 128 125 { 129 - struct drm_file *filp = f->private_data; 130 126 struct amdxdna_client *client = filp->driver_priv; 131 - struct amdxdna_dev *xdna = client->xdna; 127 + struct amdxdna_dev *xdna = to_xdna_dev(ddev); 132 128 int idx; 133 129 134 - XDNA_DBG(xdna, "PID %d flushing...", client->pid); 130 + XDNA_DBG(xdna, "closing pid %d", client->pid); 131 + 135 132 if (!drm_dev_enter(&xdna->ddev, &idx)) 136 - return 0; 133 + return; 137 134 138 135 mutex_lock(&xdna->dev_lock); 139 - list_del_init(&client->node); 140 - amdxdna_hwctx_remove_all(client); 136 + amdxdna_client_cleanup(client); 141 137 mutex_unlock(&xdna->dev_lock); 142 138 143 139 drm_dev_exit(idx); 144 - return 0; 145 140 } 146 141 147 142 static int amdxdna_drm_get_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ··· 212 217 .owner = THIS_MODULE, 213 218 .open = accel_open, 214 219 .release = drm_release, 215 - .flush = amdxdna_flush, 216 220 .unlocked_ioctl = drm_ioctl, 217 221 .compat_ioctl = drm_compat_ioctl, 218 222 .poll = drm_poll, ··· 327 333 client = list_first_entry_or_null(&xdna->client_list, 328 334 struct amdxdna_client, node); 329 335 while (client) { 330 - list_del_init(&client->node); 331 - amdxdna_hwctx_remove_all(client); 336 + amdxdna_client_cleanup(client); 332 337 333 338 client = list_first_entry_or_null(&xdna->client_list, 334 339 struct amdxdna_client, node);