diff options
author | Mark Brown <broonie@kernel.org> | 2015-10-12 13:09:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-10-12 13:09:27 -0400 |
commit | 79828b4fa835f73cdaf4bffa48696abdcbea9d02 (patch) | |
tree | 5e0fa7156acb75ba603022bc807df8f2fedb97a8 /drivers/misc/cxl/api.c | |
parent | 721b51fcf91898299d96f4b72cb9434cda29dce6 (diff) | |
parent | 8c1a9d6323abf0fb1e5dad96cf3f1c783505ea5a (diff) |
Merge remote-tracking branch 'asoc/fix/rt5645' into asoc-fix-rt5645
Diffstat (limited to 'drivers/misc/cxl/api.c')
-rw-r--r-- | drivers/misc/cxl/api.c | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 729e0851167d..8af12c884b04 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c | |||
@@ -12,11 +12,13 @@ | |||
12 | #include <linux/anon_inodes.h> | 12 | #include <linux/anon_inodes.h> |
13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
14 | #include <misc/cxl.h> | 14 | #include <misc/cxl.h> |
15 | #include <linux/fs.h> | ||
15 | 16 | ||
16 | #include "cxl.h" | 17 | #include "cxl.h" |
17 | 18 | ||
18 | struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) | 19 | struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) |
19 | { | 20 | { |
21 | struct address_space *mapping; | ||
20 | struct cxl_afu *afu; | 22 | struct cxl_afu *afu; |
21 | struct cxl_context *ctx; | 23 | struct cxl_context *ctx; |
22 | int rc; | 24 | int rc; |
@@ -25,19 +27,42 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) | |||
25 | 27 | ||
26 | get_device(&afu->dev); | 28 | get_device(&afu->dev); |
27 | ctx = cxl_context_alloc(); | 29 | ctx = cxl_context_alloc(); |
28 | if (IS_ERR(ctx)) | 30 | if (IS_ERR(ctx)) { |
29 | return ctx; | 31 | rc = PTR_ERR(ctx); |
32 | goto err_dev; | ||
33 | } | ||
30 | 34 | ||
31 | /* Make it a slave context. We can promote it later? */ | 35 | ctx->kernelapi = true; |
32 | rc = cxl_context_init(ctx, afu, false, NULL); | 36 | |
33 | if (rc) { | 37 | /* |
34 | kfree(ctx); | 38 | * Make our own address space since we won't have one from the |
35 | put_device(&afu->dev); | 39 | * filesystem like the user api has, and even if we do associate a file |
36 | return ERR_PTR(-ENOMEM); | 40 | * with this context we don't want to use the global anonymous inode's |
41 | * address space as that can invalidate unrelated users: | ||
42 | */ | ||
43 | mapping = kmalloc(sizeof(struct address_space), GFP_KERNEL); | ||
44 | if (!mapping) { | ||
45 | rc = -ENOMEM; | ||
46 | goto err_ctx; | ||
37 | } | 47 | } |
48 | address_space_init_once(mapping); | ||
49 | |||
50 | /* Make it a slave context. We can promote it later? */ | ||
51 | rc = cxl_context_init(ctx, afu, false, mapping); | ||
52 | if (rc) | ||
53 | goto err_mapping; | ||
54 | |||
38 | cxl_assign_psn_space(ctx); | 55 | cxl_assign_psn_space(ctx); |
39 | 56 | ||
40 | return ctx; | 57 | return ctx; |
58 | |||
59 | err_mapping: | ||
60 | kfree(mapping); | ||
61 | err_ctx: | ||
62 | kfree(ctx); | ||
63 | err_dev: | ||
64 | put_device(&afu->dev); | ||
65 | return ERR_PTR(rc); | ||
41 | } | 66 | } |
42 | EXPORT_SYMBOL_GPL(cxl_dev_context_init); | 67 | EXPORT_SYMBOL_GPL(cxl_dev_context_init); |
43 | 68 | ||
@@ -59,7 +84,7 @@ EXPORT_SYMBOL_GPL(cxl_get_phys_dev); | |||
59 | 84 | ||
60 | int cxl_release_context(struct cxl_context *ctx) | 85 | int cxl_release_context(struct cxl_context *ctx) |
61 | { | 86 | { |
62 | if (ctx->status != CLOSED) | 87 | if (ctx->status >= STARTED) |
63 | return -EBUSY; | 88 | return -EBUSY; |
64 | 89 | ||
65 | put_device(&ctx->afu->dev); | 90 | put_device(&ctx->afu->dev); |
@@ -255,9 +280,16 @@ struct file *cxl_get_fd(struct cxl_context *ctx, struct file_operations *fops, | |||
255 | 280 | ||
256 | file = anon_inode_getfile("cxl", fops, ctx, flags); | 281 | file = anon_inode_getfile("cxl", fops, ctx, flags); |
257 | if (IS_ERR(file)) | 282 | if (IS_ERR(file)) |
258 | put_unused_fd(fdtmp); | 283 | goto err_fd; |
284 | |||
285 | file->f_mapping = ctx->mapping; | ||
286 | |||
259 | *fd = fdtmp; | 287 | *fd = fdtmp; |
260 | return file; | 288 | return file; |
289 | |||
290 | err_fd: | ||
291 | put_unused_fd(fdtmp); | ||
292 | return NULL; | ||
261 | } | 293 | } |
262 | EXPORT_SYMBOL_GPL(cxl_get_fd); | 294 | EXPORT_SYMBOL_GPL(cxl_get_fd); |
263 | 295 | ||
@@ -327,3 +359,10 @@ int cxl_afu_reset(struct cxl_context *ctx) | |||
327 | return cxl_afu_check_and_enable(afu); | 359 | return cxl_afu_check_and_enable(afu); |
328 | } | 360 | } |
329 | EXPORT_SYMBOL_GPL(cxl_afu_reset); | 361 | EXPORT_SYMBOL_GPL(cxl_afu_reset); |
362 | |||
363 | void cxl_perst_reloads_same_image(struct cxl_afu *afu, | ||
364 | bool perst_reloads_same_image) | ||
365 | { | ||
366 | afu->adapter->perst_same_image = perst_reloads_same_image; | ||
367 | } | ||
368 | EXPORT_SYMBOL_GPL(cxl_perst_reloads_same_image); | ||