Skip to content

Commit e8c28e1

Browse files
committed
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
1 parent 5c3c3e7 commit e8c28e1

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

drivers/accel/amdxdna/amdxdna_pci_drv.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,43 +105,38 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp)
105105
return ret;
106106
}
107107

108-
static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp)
108+
static void amdxdna_client_cleanup(struct amdxdna_client *client)
109109
{
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);
115112
xa_destroy(&client->hwctx_xa);
116113
cleanup_srcu_struct(&client->hwctx_srcu);
117114
mutex_destroy(&client->mm_lock);
115+
118116
if (client->dev_heap)
119117
drm_gem_object_put(to_gobj(client->dev_heap));
120118

121119
iommu_sva_unbind_device(client->sva);
122120

123-
XDNA_DBG(xdna, "pid %d closed", client->pid);
124121
kfree(client);
125122
}
126123

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)
128125
{
129-
struct drm_file *filp = f->private_data;
130126
struct amdxdna_client *client = filp->driver_priv;
131-
struct amdxdna_dev *xdna = client->xdna;
127+
struct amdxdna_dev *xdna = to_xdna_dev(ddev);
132128
int idx;
133129

134-
XDNA_DBG(xdna, "PID %d flushing...", client->pid);
130+
XDNA_DBG(xdna, "closing pid %d", client->pid);
131+
135132
if (!drm_dev_enter(&xdna->ddev, &idx))
136-
return 0;
133+
return;
137134

138135
mutex_lock(&xdna->dev_lock);
139-
list_del_init(&client->node);
140-
amdxdna_hwctx_remove_all(client);
136+
amdxdna_client_cleanup(client);
141137
mutex_unlock(&xdna->dev_lock);
142138

143139
drm_dev_exit(idx);
144-
return 0;
145140
}
146141

147142
static int amdxdna_drm_get_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
@@ -217,7 +212,6 @@ static const struct file_operations amdxdna_fops = {
217212
.owner = THIS_MODULE,
218213
.open = accel_open,
219214
.release = drm_release,
220-
.flush = amdxdna_flush,
221215
.unlocked_ioctl = drm_ioctl,
222216
.compat_ioctl = drm_compat_ioctl,
223217
.poll = drm_poll,
@@ -333,8 +327,7 @@ static void amdxdna_remove(struct pci_dev *pdev)
333327
client = list_first_entry_or_null(&xdna->client_list,
334328
struct amdxdna_client, node);
335329
while (client) {
336-
list_del_init(&client->node);
337-
amdxdna_hwctx_remove_all(client);
330+
amdxdna_client_cleanup(client);
338331

339332
client = list_first_entry_or_null(&xdna->client_list,
340333
struct amdxdna_client, node);

0 commit comments

Comments
 (0)