Skip to content

Commit

Permalink
dmaengine: idxd: create kmem cache for event log fault items
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
davejiang authored and vinodkoul committed Apr 12, 2023
1 parent 2f30dec commit c2f156b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/dma/idxd/idxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ struct idxd_evl {
u16 head;
};

struct idxd_evl_fault {
struct work_struct work;
struct idxd_wq *wq;
u8 status;

/* make this last member always */
struct __evl_entry entry[];
};

struct idxd_device {
struct idxd_dev idxd_dev;
struct idxd_driver_data *data;
Expand Down Expand Up @@ -331,6 +340,7 @@ struct idxd_device {

unsigned long *opcap_bmap;
struct idxd_evl *evl;
struct kmem_cache *evl_cache;

struct dentry *dbgfs_dir;
struct dentry *dbgfs_evl_file;
Expand Down
9 changes: 9 additions & 0 deletions drivers/dma/idxd/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ static int idxd_init_evl(struct idxd_device *idxd)

spin_lock_init(&evl->lock);
evl->size = IDXD_EVL_SIZE_MIN;

idxd->evl_cache = kmem_cache_create(dev_name(idxd_confdev(idxd)),
sizeof(struct idxd_evl_fault) + evl_ent_size(idxd),
0, 0, NULL);
if (!idxd->evl_cache) {
kfree(evl);
return -ENOMEM;
}

idxd->evl = evl;
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/dma/idxd/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ static void idxd_conf_device_release(struct device *dev)
kfree(idxd->wqs);
kfree(idxd->engines);
kfree(idxd->evl);
kmem_cache_destroy(idxd->evl_cache);
ida_free(&idxd_ida, idxd->id);
bitmap_free(idxd->opcap_bmap);
kfree(idxd);
Expand Down

0 comments on commit c2f156b

Please sign in to comment.