Skip to content

Commit c2f156b

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: create kmem cache for event log fault items
Add a kmem cache per device for allocating event log fault context. The context allows an event log entry to be copied and passed to a software workqueue to be processed. Due to each device can have different sized event log entry depending on device type, it's not possible to have a global kmem cache. Tested-by: Tony Zhu <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Co-developed-by: Fenghua Yu <[email protected]> Signed-off-by: Fenghua Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 2f30dec commit c2f156b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

drivers/dma/idxd/idxd.h

+10
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ struct idxd_evl {
274274
u16 head;
275275
};
276276

277+
struct idxd_evl_fault {
278+
struct work_struct work;
279+
struct idxd_wq *wq;
280+
u8 status;
281+
282+
/* make this last member always */
283+
struct __evl_entry entry[];
284+
};
285+
277286
struct idxd_device {
278287
struct idxd_dev idxd_dev;
279288
struct idxd_driver_data *data;
@@ -331,6 +340,7 @@ struct idxd_device {
331340

332341
unsigned long *opcap_bmap;
333342
struct idxd_evl *evl;
343+
struct kmem_cache *evl_cache;
334344

335345
struct dentry *dbgfs_dir;
336346
struct dentry *dbgfs_evl_file;

drivers/dma/idxd/init.c

+9
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ static int idxd_init_evl(struct idxd_device *idxd)
345345

346346
spin_lock_init(&evl->lock);
347347
evl->size = IDXD_EVL_SIZE_MIN;
348+
349+
idxd->evl_cache = kmem_cache_create(dev_name(idxd_confdev(idxd)),
350+
sizeof(struct idxd_evl_fault) + evl_ent_size(idxd),
351+
0, 0, NULL);
352+
if (!idxd->evl_cache) {
353+
kfree(evl);
354+
return -ENOMEM;
355+
}
356+
348357
idxd->evl = evl;
349358
return 0;
350359
}

drivers/dma/idxd/sysfs.c

+1
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ static void idxd_conf_device_release(struct device *dev)
17181718
kfree(idxd->wqs);
17191719
kfree(idxd->engines);
17201720
kfree(idxd->evl);
1721+
kmem_cache_destroy(idxd->evl_cache);
17211722
ida_free(&idxd_ida, idxd->id);
17221723
bitmap_free(idxd->opcap_bmap);
17231724
kfree(idxd);

0 commit comments

Comments
 (0)