Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 1 | /* |
| 2 | * CXL Flash Device Driver |
| 3 | * |
| 4 | * Written by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation |
| 5 | * Uma Krishnan <ukrishn@linux.vnet.ibm.com>, IBM Corporation |
| 6 | * |
| 7 | * Copyright (C) 2018 IBM Corporation |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation; either version |
| 12 | * 2 of the License, or (at your option) any later version. |
| 13 | */ |
| 14 | |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 15 | #include <linux/file.h> |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 16 | #include <linux/idr.h> |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 17 | #include <linux/module.h> |
| 18 | #include <linux/mount.h> |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 19 | #include <linux/poll.h> |
Uma Krishnan | 03aa9c5 | 2018-03-26 11:34:12 -0500 | [diff] [blame] | 20 | #include <linux/sched/signal.h> |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 21 | |
Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 22 | #include <misc/ocxl.h> |
| 23 | |
Uma Krishnan | 03aa9c5 | 2018-03-26 11:34:12 -0500 | [diff] [blame] | 24 | #include <uapi/misc/cxl.h> |
| 25 | |
Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 26 | #include "backend.h" |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 27 | #include "ocxl_hw.h" |
| 28 | |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 29 | /* |
| 30 | * Pseudo-filesystem to allocate inodes. |
| 31 | */ |
| 32 | |
| 33 | #define OCXLFLASH_FS_MAGIC 0x1697698f |
| 34 | |
| 35 | static int ocxlflash_fs_cnt; |
| 36 | static struct vfsmount *ocxlflash_vfs_mount; |
| 37 | |
| 38 | static const struct dentry_operations ocxlflash_fs_dops = { |
| 39 | .d_dname = simple_dname, |
| 40 | }; |
| 41 | |
| 42 | /* |
| 43 | * ocxlflash_fs_mount() - mount the pseudo-filesystem |
| 44 | * @fs_type: File system type. |
| 45 | * @flags: Flags for the filesystem. |
| 46 | * @dev_name: Device name associated with the filesystem. |
| 47 | * @data: Data pointer. |
| 48 | * |
| 49 | * Return: pointer to the directory entry structure |
| 50 | */ |
| 51 | static struct dentry *ocxlflash_fs_mount(struct file_system_type *fs_type, |
| 52 | int flags, const char *dev_name, |
| 53 | void *data) |
| 54 | { |
| 55 | return mount_pseudo(fs_type, "ocxlflash:", NULL, &ocxlflash_fs_dops, |
| 56 | OCXLFLASH_FS_MAGIC); |
| 57 | } |
| 58 | |
| 59 | static struct file_system_type ocxlflash_fs_type = { |
| 60 | .name = "ocxlflash", |
| 61 | .owner = THIS_MODULE, |
| 62 | .mount = ocxlflash_fs_mount, |
| 63 | .kill_sb = kill_anon_super, |
| 64 | }; |
| 65 | |
| 66 | /* |
| 67 | * ocxlflash_release_mapping() - release the memory mapping |
| 68 | * @ctx: Context whose mapping is to be released. |
| 69 | */ |
| 70 | static void ocxlflash_release_mapping(struct ocxlflash_context *ctx) |
| 71 | { |
| 72 | if (ctx->mapping) |
| 73 | simple_release_fs(&ocxlflash_vfs_mount, &ocxlflash_fs_cnt); |
| 74 | ctx->mapping = NULL; |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * ocxlflash_getfile() - allocate pseudo filesystem, inode, and the file |
| 79 | * @dev: Generic device of the host. |
| 80 | * @name: Name of the pseudo filesystem. |
| 81 | * @fops: File operations. |
| 82 | * @priv: Private data. |
| 83 | * @flags: Flags for the file. |
| 84 | * |
| 85 | * Return: pointer to the file on success, ERR_PTR on failure |
| 86 | */ |
| 87 | static struct file *ocxlflash_getfile(struct device *dev, const char *name, |
| 88 | const struct file_operations *fops, |
| 89 | void *priv, int flags) |
| 90 | { |
| 91 | struct qstr this; |
| 92 | struct path path; |
| 93 | struct file *file; |
| 94 | struct inode *inode = NULL; |
| 95 | int rc; |
| 96 | |
| 97 | if (fops->owner && !try_module_get(fops->owner)) { |
| 98 | dev_err(dev, "%s: Owner does not exist\n", __func__); |
| 99 | rc = -ENOENT; |
| 100 | goto err1; |
| 101 | } |
| 102 | |
| 103 | rc = simple_pin_fs(&ocxlflash_fs_type, &ocxlflash_vfs_mount, |
| 104 | &ocxlflash_fs_cnt); |
| 105 | if (unlikely(rc < 0)) { |
| 106 | dev_err(dev, "%s: Cannot mount ocxlflash pseudofs rc=%d\n", |
| 107 | __func__, rc); |
| 108 | goto err2; |
| 109 | } |
| 110 | |
| 111 | inode = alloc_anon_inode(ocxlflash_vfs_mount->mnt_sb); |
| 112 | if (IS_ERR(inode)) { |
| 113 | rc = PTR_ERR(inode); |
| 114 | dev_err(dev, "%s: alloc_anon_inode failed rc=%d\n", |
| 115 | __func__, rc); |
| 116 | goto err3; |
| 117 | } |
| 118 | |
| 119 | this.name = name; |
| 120 | this.len = strlen(name); |
| 121 | this.hash = 0; |
| 122 | path.dentry = d_alloc_pseudo(ocxlflash_vfs_mount->mnt_sb, &this); |
| 123 | if (!path.dentry) { |
| 124 | dev_err(dev, "%s: d_alloc_pseudo failed\n", __func__); |
| 125 | rc = -ENOMEM; |
| 126 | goto err4; |
| 127 | } |
| 128 | |
| 129 | path.mnt = mntget(ocxlflash_vfs_mount); |
| 130 | d_instantiate(path.dentry, inode); |
| 131 | |
| 132 | file = alloc_file(&path, OPEN_FMODE(flags), fops); |
| 133 | if (IS_ERR(file)) { |
| 134 | rc = PTR_ERR(file); |
| 135 | dev_err(dev, "%s: alloc_file failed rc=%d\n", |
| 136 | __func__, rc); |
| 137 | goto err5; |
| 138 | } |
| 139 | |
| 140 | file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); |
| 141 | file->private_data = priv; |
| 142 | out: |
| 143 | return file; |
| 144 | err5: |
| 145 | path_put(&path); |
| 146 | err4: |
| 147 | iput(inode); |
| 148 | err3: |
| 149 | simple_release_fs(&ocxlflash_vfs_mount, &ocxlflash_fs_cnt); |
| 150 | err2: |
| 151 | module_put(fops->owner); |
| 152 | err1: |
| 153 | file = ERR_PTR(rc); |
| 154 | goto out; |
| 155 | } |
| 156 | |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 157 | /** |
Uma Krishnan | 012f394 | 2018-03-26 11:32:56 -0500 | [diff] [blame] | 158 | * ocxlflash_psa_map() - map the process specific MMIO space |
| 159 | * @ctx_cookie: Adapter context for which the mapping needs to be done. |
| 160 | * |
| 161 | * Return: MMIO pointer of the mapped region |
| 162 | */ |
| 163 | static void __iomem *ocxlflash_psa_map(void *ctx_cookie) |
| 164 | { |
| 165 | struct ocxlflash_context *ctx = ctx_cookie; |
| 166 | |
| 167 | return ioremap(ctx->psn_phys, ctx->psn_size); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * ocxlflash_psa_unmap() - unmap the process specific MMIO space |
| 172 | * @addr: MMIO pointer to unmap. |
| 173 | */ |
| 174 | static void ocxlflash_psa_unmap(void __iomem *addr) |
| 175 | { |
| 176 | iounmap(addr); |
| 177 | } |
| 178 | |
| 179 | /** |
Uma Krishnan | b18718c | 2018-03-26 11:32:20 -0500 | [diff] [blame] | 180 | * ocxlflash_process_element() - get process element of the adapter context |
| 181 | * @ctx_cookie: Adapter context associated with the process element. |
| 182 | * |
| 183 | * Return: process element of the adapter context |
| 184 | */ |
| 185 | static int ocxlflash_process_element(void *ctx_cookie) |
| 186 | { |
| 187 | struct ocxlflash_context *ctx = ctx_cookie; |
| 188 | |
| 189 | return ctx->pe; |
| 190 | } |
| 191 | |
| 192 | /** |
Uma Krishnan | a06b1cf | 2018-03-26 11:33:48 -0500 | [diff] [blame] | 193 | * afu_map_irq() - map the interrupt of the adapter context |
| 194 | * @flags: Flags. |
| 195 | * @ctx: Adapter context. |
| 196 | * @num: Per-context AFU interrupt number. |
| 197 | * @handler: Interrupt handler to register. |
| 198 | * @cookie: Interrupt handler private data. |
| 199 | * @name: Name of the interrupt. |
| 200 | * |
| 201 | * Return: 0 on success, -errno on failure |
| 202 | */ |
| 203 | static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num, |
| 204 | irq_handler_t handler, void *cookie, char *name) |
| 205 | { |
| 206 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 207 | struct device *dev = afu->dev; |
| 208 | struct ocxlflash_irqs *irq; |
| 209 | void __iomem *vtrig; |
| 210 | u32 virq; |
| 211 | int rc = 0; |
| 212 | |
| 213 | if (num < 0 || num >= ctx->num_irqs) { |
| 214 | dev_err(dev, "%s: Interrupt %d not allocated\n", __func__, num); |
| 215 | rc = -ENOENT; |
| 216 | goto out; |
| 217 | } |
| 218 | |
| 219 | irq = &ctx->irqs[num]; |
| 220 | virq = irq_create_mapping(NULL, irq->hwirq); |
| 221 | if (unlikely(!virq)) { |
| 222 | dev_err(dev, "%s: irq_create_mapping failed\n", __func__); |
| 223 | rc = -ENOMEM; |
| 224 | goto out; |
| 225 | } |
| 226 | |
| 227 | rc = request_irq(virq, handler, 0, name, cookie); |
| 228 | if (unlikely(rc)) { |
| 229 | dev_err(dev, "%s: request_irq failed rc=%d\n", __func__, rc); |
| 230 | goto err1; |
| 231 | } |
| 232 | |
| 233 | vtrig = ioremap(irq->ptrig, PAGE_SIZE); |
| 234 | if (unlikely(!vtrig)) { |
| 235 | dev_err(dev, "%s: Trigger page mapping failed\n", __func__); |
| 236 | rc = -ENOMEM; |
| 237 | goto err2; |
| 238 | } |
| 239 | |
| 240 | irq->virq = virq; |
| 241 | irq->vtrig = vtrig; |
| 242 | out: |
| 243 | return rc; |
| 244 | err2: |
| 245 | free_irq(virq, cookie); |
| 246 | err1: |
| 247 | irq_dispose_mapping(virq); |
| 248 | goto out; |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * ocxlflash_map_afu_irq() - map the interrupt of the adapter context |
| 253 | * @ctx_cookie: Adapter context. |
| 254 | * @num: Per-context AFU interrupt number. |
| 255 | * @handler: Interrupt handler to register. |
| 256 | * @cookie: Interrupt handler private data. |
| 257 | * @name: Name of the interrupt. |
| 258 | * |
| 259 | * Return: 0 on success, -errno on failure |
| 260 | */ |
| 261 | static int ocxlflash_map_afu_irq(void *ctx_cookie, int num, |
| 262 | irq_handler_t handler, void *cookie, |
| 263 | char *name) |
| 264 | { |
| 265 | return afu_map_irq(0, ctx_cookie, num, handler, cookie, name); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * afu_unmap_irq() - unmap the interrupt |
| 270 | * @flags: Flags. |
| 271 | * @ctx: Adapter context. |
| 272 | * @num: Per-context AFU interrupt number. |
| 273 | * @cookie: Interrupt handler private data. |
| 274 | */ |
| 275 | static void afu_unmap_irq(u64 flags, struct ocxlflash_context *ctx, int num, |
| 276 | void *cookie) |
| 277 | { |
| 278 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 279 | struct device *dev = afu->dev; |
| 280 | struct ocxlflash_irqs *irq; |
| 281 | |
| 282 | if (num < 0 || num >= ctx->num_irqs) { |
| 283 | dev_err(dev, "%s: Interrupt %d not allocated\n", __func__, num); |
| 284 | return; |
| 285 | } |
| 286 | |
| 287 | irq = &ctx->irqs[num]; |
| 288 | if (irq->vtrig) |
| 289 | iounmap(irq->vtrig); |
| 290 | |
| 291 | if (irq_find_mapping(NULL, irq->hwirq)) { |
| 292 | free_irq(irq->virq, cookie); |
| 293 | irq_dispose_mapping(irq->virq); |
| 294 | } |
| 295 | |
| 296 | memset(irq, 0, sizeof(*irq)); |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * ocxlflash_unmap_afu_irq() - unmap the interrupt |
| 301 | * @ctx_cookie: Adapter context. |
| 302 | * @num: Per-context AFU interrupt number. |
| 303 | * @cookie: Interrupt handler private data. |
| 304 | */ |
| 305 | static void ocxlflash_unmap_afu_irq(void *ctx_cookie, int num, void *cookie) |
| 306 | { |
| 307 | return afu_unmap_irq(0, ctx_cookie, num, cookie); |
| 308 | } |
| 309 | |
| 310 | /** |
Uma Krishnan | 402a55e | 2018-03-26 11:34:35 -0500 | [diff] [blame^] | 311 | * ocxlflash_get_irq_objhndl() - get the object handle for an interrupt |
| 312 | * @ctx_cookie: Context associated with the interrupt. |
| 313 | * @irq: Interrupt number. |
| 314 | * |
| 315 | * Return: effective address of the mapped region |
| 316 | */ |
| 317 | static u64 ocxlflash_get_irq_objhndl(void *ctx_cookie, int irq) |
| 318 | { |
| 319 | struct ocxlflash_context *ctx = ctx_cookie; |
| 320 | |
| 321 | if (irq < 0 || irq >= ctx->num_irqs) |
| 322 | return 0; |
| 323 | |
| 324 | return (__force u64)ctx->irqs[irq].vtrig; |
| 325 | } |
| 326 | |
| 327 | /** |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 328 | * start_context() - local routine to start a context |
| 329 | * @ctx: Adapter context to be started. |
| 330 | * |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 331 | * Assign the context specific MMIO space, add and enable the PE. |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 332 | * |
| 333 | * Return: 0 on success, -errno on failure |
| 334 | */ |
| 335 | static int start_context(struct ocxlflash_context *ctx) |
| 336 | { |
| 337 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 338 | struct ocxl_afu_config *acfg = &afu->acfg; |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 339 | void *link_token = afu->link_token; |
| 340 | struct device *dev = afu->dev; |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 341 | bool master = ctx->master; |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 342 | struct mm_struct *mm; |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 343 | int rc = 0; |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 344 | u32 pid; |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 345 | |
| 346 | if (master) { |
| 347 | ctx->psn_size = acfg->global_mmio_size; |
| 348 | ctx->psn_phys = afu->gmmio_phys; |
| 349 | } else { |
| 350 | ctx->psn_size = acfg->pp_mmio_stride; |
| 351 | ctx->psn_phys = afu->ppmmio_phys + (ctx->pe * ctx->psn_size); |
| 352 | } |
| 353 | |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 354 | /* pid and mm not set for master contexts */ |
| 355 | if (master) { |
| 356 | pid = 0; |
| 357 | mm = NULL; |
| 358 | } else { |
| 359 | pid = current->mm->context.id; |
| 360 | mm = current->mm; |
| 361 | } |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 362 | |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 363 | rc = ocxl_link_add_pe(link_token, ctx->pe, pid, 0, 0, mm, NULL, NULL); |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 364 | if (unlikely(rc)) { |
| 365 | dev_err(dev, "%s: ocxl_link_add_pe failed rc=%d\n", |
| 366 | __func__, rc); |
| 367 | goto out; |
| 368 | } |
| 369 | out: |
| 370 | return rc; |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /** |
| 374 | * ocxlflash_start_context() - start a kernel context |
| 375 | * @ctx_cookie: Adapter context to be started. |
| 376 | * |
| 377 | * Return: 0 on success, -errno on failure |
| 378 | */ |
| 379 | static int ocxlflash_start_context(void *ctx_cookie) |
| 380 | { |
| 381 | struct ocxlflash_context *ctx = ctx_cookie; |
| 382 | |
| 383 | return start_context(ctx); |
| 384 | } |
| 385 | |
| 386 | /** |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 387 | * ocxlflash_stop_context() - stop a context |
| 388 | * @ctx_cookie: Adapter context to be stopped. |
| 389 | * |
| 390 | * Return: 0 on success, -errno on failure |
| 391 | */ |
| 392 | static int ocxlflash_stop_context(void *ctx_cookie) |
| 393 | { |
| 394 | struct ocxlflash_context *ctx = ctx_cookie; |
| 395 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 396 | struct ocxl_afu_config *acfg = &afu->acfg; |
| 397 | struct pci_dev *pdev = afu->pdev; |
| 398 | struct device *dev = afu->dev; |
| 399 | int rc; |
| 400 | |
| 401 | rc = ocxl_config_terminate_pasid(pdev, acfg->dvsec_afu_control_pos, |
| 402 | ctx->pe); |
| 403 | if (unlikely(rc)) { |
| 404 | dev_err(dev, "%s: ocxl_config_terminate_pasid failed rc=%d\n", |
| 405 | __func__, rc); |
| 406 | /* If EBUSY, PE could be referenced in future by the AFU */ |
| 407 | if (rc == -EBUSY) |
| 408 | goto out; |
| 409 | } |
| 410 | |
| 411 | rc = ocxl_link_remove_pe(afu->link_token, ctx->pe); |
| 412 | if (unlikely(rc)) { |
| 413 | dev_err(dev, "%s: ocxl_link_remove_pe failed rc=%d\n", |
| 414 | __func__, rc); |
| 415 | goto out; |
| 416 | } |
| 417 | out: |
| 418 | return rc; |
| 419 | } |
| 420 | |
| 421 | /** |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 422 | * ocxlflash_set_master() - sets the context as master |
| 423 | * @ctx_cookie: Adapter context to set as master. |
| 424 | */ |
| 425 | static void ocxlflash_set_master(void *ctx_cookie) |
| 426 | { |
| 427 | struct ocxlflash_context *ctx = ctx_cookie; |
| 428 | |
| 429 | ctx->master = true; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * ocxlflash_get_context() - obtains the context associated with the host |
| 434 | * @pdev: PCI device associated with the host. |
| 435 | * @afu_cookie: Hardware AFU associated with the host. |
| 436 | * |
| 437 | * Return: returns the pointer to host adapter context |
| 438 | */ |
| 439 | static void *ocxlflash_get_context(struct pci_dev *pdev, void *afu_cookie) |
| 440 | { |
| 441 | struct ocxl_hw_afu *afu = afu_cookie; |
| 442 | |
| 443 | return afu->ocxl_ctx; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * ocxlflash_dev_context_init() - allocate and initialize an adapter context |
| 448 | * @pdev: PCI device associated with the host. |
| 449 | * @afu_cookie: Hardware AFU associated with the host. |
| 450 | * |
| 451 | * Return: returns the adapter context on success, ERR_PTR on failure |
| 452 | */ |
| 453 | static void *ocxlflash_dev_context_init(struct pci_dev *pdev, void *afu_cookie) |
| 454 | { |
| 455 | struct ocxl_hw_afu *afu = afu_cookie; |
| 456 | struct device *dev = afu->dev; |
| 457 | struct ocxlflash_context *ctx; |
| 458 | int rc; |
| 459 | |
| 460 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
| 461 | if (unlikely(!ctx)) { |
| 462 | dev_err(dev, "%s: Context allocation failed\n", __func__); |
| 463 | rc = -ENOMEM; |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 464 | goto err1; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 465 | } |
| 466 | |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 467 | idr_preload(GFP_KERNEL); |
| 468 | rc = idr_alloc(&afu->idr, ctx, 0, afu->max_pasid, GFP_NOWAIT); |
| 469 | idr_preload_end(); |
| 470 | if (unlikely(rc < 0)) { |
| 471 | dev_err(dev, "%s: idr_alloc failed rc=%d\n", __func__, rc); |
| 472 | goto err2; |
| 473 | } |
| 474 | |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 475 | spin_lock_init(&ctx->slock); |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 476 | init_waitqueue_head(&ctx->wq); |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 477 | |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 478 | ctx->pe = rc; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 479 | ctx->master = false; |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 480 | ctx->mapping = NULL; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 481 | ctx->hw_afu = afu; |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 482 | ctx->irq_bitmap = 0; |
| 483 | ctx->pending_irq = false; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 484 | out: |
| 485 | return ctx; |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 486 | err2: |
| 487 | kfree(ctx); |
| 488 | err1: |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 489 | ctx = ERR_PTR(rc); |
| 490 | goto out; |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * ocxlflash_release_context() - releases an adapter context |
| 495 | * @ctx_cookie: Adapter context to be released. |
| 496 | * |
| 497 | * Return: 0 on success, -errno on failure |
| 498 | */ |
| 499 | static int ocxlflash_release_context(void *ctx_cookie) |
| 500 | { |
| 501 | struct ocxlflash_context *ctx = ctx_cookie; |
| 502 | int rc = 0; |
| 503 | |
| 504 | if (!ctx) |
| 505 | goto out; |
| 506 | |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 507 | idr_remove(&ctx->hw_afu->idr, ctx->pe); |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 508 | ocxlflash_release_mapping(ctx); |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 509 | kfree(ctx); |
| 510 | out: |
| 511 | return rc; |
| 512 | } |
| 513 | |
| 514 | /** |
Uma Krishnan | 8b7a552 | 2018-03-26 11:32:29 -0500 | [diff] [blame] | 515 | * ocxlflash_perst_reloads_same_image() - sets the image reload policy |
| 516 | * @afu_cookie: Hardware AFU associated with the host. |
| 517 | * @image: Whether to load the same image on PERST. |
| 518 | */ |
| 519 | static void ocxlflash_perst_reloads_same_image(void *afu_cookie, bool image) |
| 520 | { |
| 521 | struct ocxl_hw_afu *afu = afu_cookie; |
| 522 | |
| 523 | afu->perst_same_image = image; |
| 524 | } |
| 525 | |
| 526 | /** |
Uma Krishnan | 119c920 | 2018-03-26 11:33:14 -0500 | [diff] [blame] | 527 | * ocxlflash_read_adapter_vpd() - reads the adapter VPD |
| 528 | * @pdev: PCI device associated with the host. |
| 529 | * @buf: Buffer to get the VPD data. |
| 530 | * @count: Size of buffer (maximum bytes that can be read). |
| 531 | * |
| 532 | * Return: size of VPD on success, -errno on failure |
| 533 | */ |
| 534 | static ssize_t ocxlflash_read_adapter_vpd(struct pci_dev *pdev, void *buf, |
| 535 | size_t count) |
| 536 | { |
| 537 | return pci_read_vpd(pdev, 0, count, buf); |
| 538 | } |
| 539 | |
| 540 | /** |
Uma Krishnan | bc65c1c | 2018-03-26 11:33:41 -0500 | [diff] [blame] | 541 | * free_afu_irqs() - internal service to free interrupts |
| 542 | * @ctx: Adapter context. |
| 543 | */ |
| 544 | static void free_afu_irqs(struct ocxlflash_context *ctx) |
| 545 | { |
| 546 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 547 | struct device *dev = afu->dev; |
| 548 | int i; |
| 549 | |
| 550 | if (!ctx->irqs) { |
| 551 | dev_err(dev, "%s: Interrupts not allocated\n", __func__); |
| 552 | return; |
| 553 | } |
| 554 | |
| 555 | for (i = ctx->num_irqs; i >= 0; i--) |
| 556 | ocxl_link_free_irq(afu->link_token, ctx->irqs[i].hwirq); |
| 557 | |
| 558 | kfree(ctx->irqs); |
| 559 | ctx->irqs = NULL; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * alloc_afu_irqs() - internal service to allocate interrupts |
| 564 | * @ctx: Context associated with the request. |
| 565 | * @num: Number of interrupts requested. |
| 566 | * |
| 567 | * Return: 0 on success, -errno on failure |
| 568 | */ |
| 569 | static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num) |
| 570 | { |
| 571 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 572 | struct device *dev = afu->dev; |
| 573 | struct ocxlflash_irqs *irqs; |
| 574 | u64 addr; |
| 575 | int rc = 0; |
| 576 | int hwirq; |
| 577 | int i; |
| 578 | |
| 579 | if (ctx->irqs) { |
| 580 | dev_err(dev, "%s: Interrupts already allocated\n", __func__); |
| 581 | rc = -EEXIST; |
| 582 | goto out; |
| 583 | } |
| 584 | |
| 585 | if (num > OCXL_MAX_IRQS) { |
| 586 | dev_err(dev, "%s: Too many interrupts num=%d\n", __func__, num); |
| 587 | rc = -EINVAL; |
| 588 | goto out; |
| 589 | } |
| 590 | |
| 591 | irqs = kcalloc(num, sizeof(*irqs), GFP_KERNEL); |
| 592 | if (unlikely(!irqs)) { |
| 593 | dev_err(dev, "%s: Context irqs allocation failed\n", __func__); |
| 594 | rc = -ENOMEM; |
| 595 | goto out; |
| 596 | } |
| 597 | |
| 598 | for (i = 0; i < num; i++) { |
| 599 | rc = ocxl_link_irq_alloc(afu->link_token, &hwirq, &addr); |
| 600 | if (unlikely(rc)) { |
| 601 | dev_err(dev, "%s: ocxl_link_irq_alloc failed rc=%d\n", |
| 602 | __func__, rc); |
| 603 | goto err; |
| 604 | } |
| 605 | |
| 606 | irqs[i].hwirq = hwirq; |
| 607 | irqs[i].ptrig = addr; |
| 608 | } |
| 609 | |
| 610 | ctx->irqs = irqs; |
| 611 | ctx->num_irqs = num; |
| 612 | out: |
| 613 | return rc; |
| 614 | err: |
| 615 | for (i = i-1; i >= 0; i--) |
| 616 | ocxl_link_free_irq(afu->link_token, irqs[i].hwirq); |
| 617 | kfree(irqs); |
| 618 | goto out; |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * ocxlflash_allocate_afu_irqs() - allocates the requested number of interrupts |
| 623 | * @ctx_cookie: Context associated with the request. |
| 624 | * @num: Number of interrupts requested. |
| 625 | * |
| 626 | * Return: 0 on success, -errno on failure |
| 627 | */ |
| 628 | static int ocxlflash_allocate_afu_irqs(void *ctx_cookie, int num) |
| 629 | { |
| 630 | return alloc_afu_irqs(ctx_cookie, num); |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * ocxlflash_free_afu_irqs() - frees the interrupts of an adapter context |
| 635 | * @ctx_cookie: Adapter context. |
| 636 | */ |
| 637 | static void ocxlflash_free_afu_irqs(void *ctx_cookie) |
| 638 | { |
| 639 | free_afu_irqs(ctx_cookie); |
| 640 | } |
| 641 | |
| 642 | /** |
Uma Krishnan | 5437050 | 2018-03-26 11:32:37 -0500 | [diff] [blame] | 643 | * ocxlflash_unconfig_afu() - unconfigure the AFU |
| 644 | * @afu: AFU associated with the host. |
| 645 | */ |
| 646 | static void ocxlflash_unconfig_afu(struct ocxl_hw_afu *afu) |
| 647 | { |
| 648 | if (afu->gmmio_virt) { |
| 649 | iounmap(afu->gmmio_virt); |
| 650 | afu->gmmio_virt = NULL; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | /** |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 655 | * ocxlflash_destroy_afu() - destroy the AFU structure |
| 656 | * @afu_cookie: AFU to be freed. |
| 657 | */ |
| 658 | static void ocxlflash_destroy_afu(void *afu_cookie) |
| 659 | { |
| 660 | struct ocxl_hw_afu *afu = afu_cookie; |
Uma Krishnan | 3351e4f | 2018-03-26 11:33:05 -0500 | [diff] [blame] | 661 | int pos; |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 662 | |
| 663 | if (!afu) |
| 664 | return; |
| 665 | |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 666 | ocxlflash_release_context(afu->ocxl_ctx); |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 667 | idr_destroy(&afu->idr); |
Uma Krishnan | 3351e4f | 2018-03-26 11:33:05 -0500 | [diff] [blame] | 668 | |
| 669 | /* Disable the AFU */ |
| 670 | pos = afu->acfg.dvsec_afu_control_pos; |
| 671 | ocxl_config_set_afu_state(afu->pdev, pos, 0); |
| 672 | |
Uma Krishnan | 5437050 | 2018-03-26 11:32:37 -0500 | [diff] [blame] | 673 | ocxlflash_unconfig_afu(afu); |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 674 | kfree(afu); |
| 675 | } |
| 676 | |
| 677 | /** |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 678 | * ocxlflash_config_fn() - configure the host function |
| 679 | * @pdev: PCI device associated with the host. |
| 680 | * @afu: AFU associated with the host. |
| 681 | * |
| 682 | * Return: 0 on success, -errno on failure |
| 683 | */ |
| 684 | static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu) |
| 685 | { |
| 686 | struct ocxl_fn_config *fcfg = &afu->fcfg; |
| 687 | struct device *dev = &pdev->dev; |
Uma Krishnan | 2e22277 | 2018-03-26 11:31:21 -0500 | [diff] [blame] | 688 | u16 base, enabled, supported; |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 689 | int rc = 0; |
| 690 | |
| 691 | /* Read DVSEC config of the function */ |
| 692 | rc = ocxl_config_read_function(pdev, fcfg); |
| 693 | if (unlikely(rc)) { |
| 694 | dev_err(dev, "%s: ocxl_config_read_function failed rc=%d\n", |
| 695 | __func__, rc); |
| 696 | goto out; |
| 697 | } |
| 698 | |
| 699 | /* Check if function has AFUs defined, only 1 per function supported */ |
| 700 | if (fcfg->max_afu_index >= 0) { |
| 701 | afu->is_present = true; |
| 702 | if (fcfg->max_afu_index != 0) |
| 703 | dev_warn(dev, "%s: Unexpected AFU index value %d\n", |
| 704 | __func__, fcfg->max_afu_index); |
| 705 | } |
Uma Krishnan | 2e22277 | 2018-03-26 11:31:21 -0500 | [diff] [blame] | 706 | |
| 707 | rc = ocxl_config_get_actag_info(pdev, &base, &enabled, &supported); |
| 708 | if (unlikely(rc)) { |
| 709 | dev_err(dev, "%s: ocxl_config_get_actag_info failed rc=%d\n", |
| 710 | __func__, rc); |
| 711 | goto out; |
| 712 | } |
| 713 | |
| 714 | afu->fn_actag_base = base; |
| 715 | afu->fn_actag_enabled = enabled; |
| 716 | |
| 717 | ocxl_config_set_actag(pdev, fcfg->dvsec_function_pos, base, enabled); |
| 718 | dev_dbg(dev, "%s: Function acTag range base=%u enabled=%u\n", |
| 719 | __func__, base, enabled); |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 720 | |
| 721 | rc = ocxl_link_setup(pdev, 0, &afu->link_token); |
| 722 | if (unlikely(rc)) { |
| 723 | dev_err(dev, "%s: ocxl_link_setup failed rc=%d\n", |
| 724 | __func__, rc); |
| 725 | goto out; |
| 726 | } |
Uma Krishnan | c52bf5b | 2018-03-26 11:33:28 -0500 | [diff] [blame] | 727 | |
| 728 | rc = ocxl_config_set_TL(pdev, fcfg->dvsec_tl_pos); |
| 729 | if (unlikely(rc)) { |
| 730 | dev_err(dev, "%s: ocxl_config_set_TL failed rc=%d\n", |
| 731 | __func__, rc); |
| 732 | goto err; |
| 733 | } |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 734 | out: |
| 735 | return rc; |
Uma Krishnan | c52bf5b | 2018-03-26 11:33:28 -0500 | [diff] [blame] | 736 | err: |
| 737 | ocxl_link_release(pdev, afu->link_token); |
| 738 | goto out; |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | /** |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 742 | * ocxlflash_unconfig_fn() - unconfigure the host function |
| 743 | * @pdev: PCI device associated with the host. |
| 744 | * @afu: AFU associated with the host. |
| 745 | */ |
| 746 | static void ocxlflash_unconfig_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu) |
| 747 | { |
| 748 | ocxl_link_release(pdev, afu->link_token); |
| 749 | } |
| 750 | |
| 751 | /** |
Uma Krishnan | 5437050 | 2018-03-26 11:32:37 -0500 | [diff] [blame] | 752 | * ocxlflash_map_mmio() - map the AFU MMIO space |
| 753 | * @afu: AFU associated with the host. |
| 754 | * |
| 755 | * Return: 0 on success, -errno on failure |
| 756 | */ |
| 757 | static int ocxlflash_map_mmio(struct ocxl_hw_afu *afu) |
| 758 | { |
| 759 | struct ocxl_afu_config *acfg = &afu->acfg; |
| 760 | struct pci_dev *pdev = afu->pdev; |
| 761 | struct device *dev = afu->dev; |
| 762 | phys_addr_t gmmio, ppmmio; |
| 763 | int rc = 0; |
| 764 | |
| 765 | rc = pci_request_region(pdev, acfg->global_mmio_bar, "ocxlflash"); |
| 766 | if (unlikely(rc)) { |
| 767 | dev_err(dev, "%s: pci_request_region for global failed rc=%d\n", |
| 768 | __func__, rc); |
| 769 | goto out; |
| 770 | } |
| 771 | gmmio = pci_resource_start(pdev, acfg->global_mmio_bar); |
| 772 | gmmio += acfg->global_mmio_offset; |
| 773 | |
| 774 | rc = pci_request_region(pdev, acfg->pp_mmio_bar, "ocxlflash"); |
| 775 | if (unlikely(rc)) { |
| 776 | dev_err(dev, "%s: pci_request_region for pp bar failed rc=%d\n", |
| 777 | __func__, rc); |
| 778 | goto err1; |
| 779 | } |
| 780 | ppmmio = pci_resource_start(pdev, acfg->pp_mmio_bar); |
| 781 | ppmmio += acfg->pp_mmio_offset; |
| 782 | |
| 783 | afu->gmmio_virt = ioremap(gmmio, acfg->global_mmio_size); |
| 784 | if (unlikely(!afu->gmmio_virt)) { |
| 785 | dev_err(dev, "%s: MMIO mapping failed\n", __func__); |
| 786 | rc = -ENOMEM; |
| 787 | goto err2; |
| 788 | } |
| 789 | |
| 790 | afu->gmmio_phys = gmmio; |
| 791 | afu->ppmmio_phys = ppmmio; |
| 792 | out: |
| 793 | return rc; |
| 794 | err2: |
| 795 | pci_release_region(pdev, acfg->pp_mmio_bar); |
| 796 | err1: |
| 797 | pci_release_region(pdev, acfg->global_mmio_bar); |
| 798 | goto out; |
| 799 | } |
| 800 | |
| 801 | /** |
Uma Krishnan | 9cc8429 | 2018-03-26 11:31:29 -0500 | [diff] [blame] | 802 | * ocxlflash_config_afu() - configure the host AFU |
| 803 | * @pdev: PCI device associated with the host. |
| 804 | * @afu: AFU associated with the host. |
| 805 | * |
| 806 | * Must be called _after_ host function configuration. |
| 807 | * |
| 808 | * Return: 0 on success, -errno on failure |
| 809 | */ |
| 810 | static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu) |
| 811 | { |
| 812 | struct ocxl_afu_config *acfg = &afu->acfg; |
| 813 | struct ocxl_fn_config *fcfg = &afu->fcfg; |
| 814 | struct device *dev = &pdev->dev; |
Uma Krishnan | d926519e | 2018-03-26 11:31:36 -0500 | [diff] [blame] | 815 | int count; |
| 816 | int base; |
| 817 | int pos; |
Uma Krishnan | 9cc8429 | 2018-03-26 11:31:29 -0500 | [diff] [blame] | 818 | int rc = 0; |
| 819 | |
| 820 | /* This HW AFU function does not have any AFUs defined */ |
| 821 | if (!afu->is_present) |
| 822 | goto out; |
| 823 | |
| 824 | /* Read AFU config at index 0 */ |
| 825 | rc = ocxl_config_read_afu(pdev, fcfg, acfg, 0); |
| 826 | if (unlikely(rc)) { |
| 827 | dev_err(dev, "%s: ocxl_config_read_afu failed rc=%d\n", |
| 828 | __func__, rc); |
| 829 | goto out; |
| 830 | } |
Uma Krishnan | d926519e | 2018-03-26 11:31:36 -0500 | [diff] [blame] | 831 | |
| 832 | /* Only one AFU per function is supported, so actag_base is same */ |
| 833 | base = afu->fn_actag_base; |
| 834 | count = min_t(int, acfg->actag_supported, afu->fn_actag_enabled); |
| 835 | pos = acfg->dvsec_afu_control_pos; |
| 836 | |
| 837 | ocxl_config_set_afu_actag(pdev, pos, base, count); |
| 838 | dev_dbg(dev, "%s: acTag base=%d enabled=%d\n", __func__, base, count); |
| 839 | afu->afu_actag_base = base; |
| 840 | afu->afu_actag_enabled = count; |
Uma Krishnan | 41df40d | 2018-03-26 11:31:44 -0500 | [diff] [blame] | 841 | afu->max_pasid = 1 << acfg->pasid_supported_log; |
| 842 | |
| 843 | ocxl_config_set_afu_pasid(pdev, pos, 0, acfg->pasid_supported_log); |
Uma Krishnan | 5437050 | 2018-03-26 11:32:37 -0500 | [diff] [blame] | 844 | |
| 845 | rc = ocxlflash_map_mmio(afu); |
| 846 | if (unlikely(rc)) { |
| 847 | dev_err(dev, "%s: ocxlflash_map_mmio failed rc=%d\n", |
| 848 | __func__, rc); |
| 849 | goto out; |
| 850 | } |
Uma Krishnan | 3351e4f | 2018-03-26 11:33:05 -0500 | [diff] [blame] | 851 | |
| 852 | /* Enable the AFU */ |
| 853 | ocxl_config_set_afu_state(pdev, acfg->dvsec_afu_control_pos, 1); |
Uma Krishnan | 9cc8429 | 2018-03-26 11:31:29 -0500 | [diff] [blame] | 854 | out: |
| 855 | return rc; |
| 856 | } |
| 857 | |
| 858 | /** |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 859 | * ocxlflash_create_afu() - create the AFU for OCXL |
| 860 | * @pdev: PCI device associated with the host. |
| 861 | * |
| 862 | * Return: AFU on success, NULL on failure |
| 863 | */ |
| 864 | static void *ocxlflash_create_afu(struct pci_dev *pdev) |
| 865 | { |
| 866 | struct device *dev = &pdev->dev; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 867 | struct ocxlflash_context *ctx; |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 868 | struct ocxl_hw_afu *afu; |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 869 | int rc; |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 870 | |
| 871 | afu = kzalloc(sizeof(*afu), GFP_KERNEL); |
| 872 | if (unlikely(!afu)) { |
| 873 | dev_err(dev, "%s: HW AFU allocation failed\n", __func__); |
| 874 | goto out; |
| 875 | } |
| 876 | |
| 877 | afu->pdev = pdev; |
| 878 | afu->dev = dev; |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 879 | idr_init(&afu->idr); |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 880 | |
| 881 | rc = ocxlflash_config_fn(pdev, afu); |
| 882 | if (unlikely(rc)) { |
| 883 | dev_err(dev, "%s: Function configuration failed rc=%d\n", |
| 884 | __func__, rc); |
| 885 | goto err1; |
| 886 | } |
Uma Krishnan | 9cc8429 | 2018-03-26 11:31:29 -0500 | [diff] [blame] | 887 | |
| 888 | rc = ocxlflash_config_afu(pdev, afu); |
| 889 | if (unlikely(rc)) { |
| 890 | dev_err(dev, "%s: AFU configuration failed rc=%d\n", |
| 891 | __func__, rc); |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 892 | goto err2; |
Uma Krishnan | 9cc8429 | 2018-03-26 11:31:29 -0500 | [diff] [blame] | 893 | } |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 894 | |
| 895 | ctx = ocxlflash_dev_context_init(pdev, afu); |
| 896 | if (IS_ERR(ctx)) { |
| 897 | rc = PTR_ERR(ctx); |
| 898 | dev_err(dev, "%s: ocxlflash_dev_context_init failed rc=%d\n", |
| 899 | __func__, rc); |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 900 | goto err3; |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | afu->ocxl_ctx = ctx; |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 904 | out: |
| 905 | return afu; |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 906 | err3: |
Uma Krishnan | 5437050 | 2018-03-26 11:32:37 -0500 | [diff] [blame] | 907 | ocxlflash_unconfig_afu(afu); |
Uma Krishnan | 7390482 | 2018-03-26 11:33:21 -0500 | [diff] [blame] | 908 | err2: |
| 909 | ocxlflash_unconfig_fn(pdev, afu); |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 910 | err1: |
Uma Krishnan | 429ebfa | 2018-03-26 11:32:00 -0500 | [diff] [blame] | 911 | idr_destroy(&afu->idr); |
Uma Krishnan | e9dfced | 2018-03-26 11:31:09 -0500 | [diff] [blame] | 912 | kfree(afu); |
| 913 | afu = NULL; |
| 914 | goto out; |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 915 | } |
Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 916 | |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 917 | /** |
| 918 | * ctx_event_pending() - check for any event pending on the context |
| 919 | * @ctx: Context to be checked. |
| 920 | * |
| 921 | * Return: true if there is an event pending, false if none pending |
| 922 | */ |
| 923 | static inline bool ctx_event_pending(struct ocxlflash_context *ctx) |
| 924 | { |
| 925 | if (ctx->pending_irq) |
| 926 | return true; |
| 927 | |
| 928 | return false; |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * afu_poll() - poll the AFU for events on the context |
| 933 | * @file: File associated with the adapter context. |
| 934 | * @poll: Poll structure from the user. |
| 935 | * |
| 936 | * Return: poll mask |
| 937 | */ |
| 938 | static unsigned int afu_poll(struct file *file, struct poll_table_struct *poll) |
| 939 | { |
| 940 | struct ocxlflash_context *ctx = file->private_data; |
| 941 | struct device *dev = ctx->hw_afu->dev; |
| 942 | ulong lock_flags; |
| 943 | int mask = 0; |
| 944 | |
| 945 | poll_wait(file, &ctx->wq, poll); |
| 946 | |
| 947 | spin_lock_irqsave(&ctx->slock, lock_flags); |
| 948 | if (ctx_event_pending(ctx)) |
| 949 | mask |= POLLIN | POLLRDNORM; |
| 950 | else |
| 951 | mask |= POLLERR; |
| 952 | spin_unlock_irqrestore(&ctx->slock, lock_flags); |
| 953 | |
| 954 | dev_dbg(dev, "%s: Poll wait completed for pe %i mask %i\n", |
| 955 | __func__, ctx->pe, mask); |
| 956 | |
| 957 | return mask; |
| 958 | } |
| 959 | |
Uma Krishnan | 03aa9c5 | 2018-03-26 11:34:12 -0500 | [diff] [blame] | 960 | /** |
| 961 | * afu_read() - perform a read on the context for any event |
| 962 | * @file: File associated with the adapter context. |
| 963 | * @buf: Buffer to receive the data. |
| 964 | * @count: Size of buffer (maximum bytes that can be read). |
| 965 | * @off: Offset. |
| 966 | * |
| 967 | * Return: size of the data read on success, -errno on failure |
| 968 | */ |
| 969 | static ssize_t afu_read(struct file *file, char __user *buf, size_t count, |
| 970 | loff_t *off) |
| 971 | { |
| 972 | struct ocxlflash_context *ctx = file->private_data; |
| 973 | struct device *dev = ctx->hw_afu->dev; |
| 974 | struct cxl_event event; |
| 975 | ulong lock_flags; |
| 976 | ssize_t esize; |
| 977 | ssize_t rc; |
| 978 | int bit; |
| 979 | DEFINE_WAIT(event_wait); |
| 980 | |
| 981 | if (*off != 0) { |
| 982 | dev_err(dev, "%s: Non-zero offset not supported, off=%lld\n", |
| 983 | __func__, *off); |
| 984 | rc = -EINVAL; |
| 985 | goto out; |
| 986 | } |
| 987 | |
| 988 | spin_lock_irqsave(&ctx->slock, lock_flags); |
| 989 | |
| 990 | for (;;) { |
| 991 | prepare_to_wait(&ctx->wq, &event_wait, TASK_INTERRUPTIBLE); |
| 992 | |
| 993 | if (ctx_event_pending(ctx)) |
| 994 | break; |
| 995 | |
| 996 | if (file->f_flags & O_NONBLOCK) { |
| 997 | dev_err(dev, "%s: File cannot be blocked on I/O\n", |
| 998 | __func__); |
| 999 | rc = -EAGAIN; |
| 1000 | goto err; |
| 1001 | } |
| 1002 | |
| 1003 | if (signal_pending(current)) { |
| 1004 | dev_err(dev, "%s: Signal pending on the process\n", |
| 1005 | __func__); |
| 1006 | rc = -ERESTARTSYS; |
| 1007 | goto err; |
| 1008 | } |
| 1009 | |
| 1010 | spin_unlock_irqrestore(&ctx->slock, lock_flags); |
| 1011 | schedule(); |
| 1012 | spin_lock_irqsave(&ctx->slock, lock_flags); |
| 1013 | } |
| 1014 | |
| 1015 | finish_wait(&ctx->wq, &event_wait); |
| 1016 | |
| 1017 | memset(&event, 0, sizeof(event)); |
| 1018 | event.header.process_element = ctx->pe; |
| 1019 | event.header.size = sizeof(struct cxl_event_header); |
| 1020 | if (ctx->pending_irq) { |
| 1021 | esize = sizeof(struct cxl_event_afu_interrupt); |
| 1022 | event.header.size += esize; |
| 1023 | event.header.type = CXL_EVENT_AFU_INTERRUPT; |
| 1024 | |
| 1025 | bit = find_first_bit(&ctx->irq_bitmap, ctx->num_irqs); |
| 1026 | clear_bit(bit, &ctx->irq_bitmap); |
| 1027 | event.irq.irq = bit + 1; |
| 1028 | if (bitmap_empty(&ctx->irq_bitmap, ctx->num_irqs)) |
| 1029 | ctx->pending_irq = false; |
| 1030 | } |
| 1031 | |
| 1032 | spin_unlock_irqrestore(&ctx->slock, lock_flags); |
| 1033 | |
| 1034 | if (copy_to_user(buf, &event, event.header.size)) { |
| 1035 | dev_err(dev, "%s: copy_to_user failed\n", __func__); |
| 1036 | rc = -EFAULT; |
| 1037 | goto out; |
| 1038 | } |
| 1039 | |
| 1040 | rc = event.header.size; |
| 1041 | out: |
| 1042 | return rc; |
| 1043 | err: |
| 1044 | finish_wait(&ctx->wq, &event_wait); |
| 1045 | spin_unlock_irqrestore(&ctx->slock, lock_flags); |
| 1046 | goto out; |
| 1047 | } |
| 1048 | |
Uma Krishnan | 93b8f8d | 2018-03-26 11:34:20 -0500 | [diff] [blame] | 1049 | /** |
| 1050 | * afu_release() - release and free the context |
| 1051 | * @inode: File inode pointer. |
| 1052 | * @file: File associated with the context. |
| 1053 | * |
| 1054 | * Return: 0 on success, -errno on failure |
| 1055 | */ |
| 1056 | static int afu_release(struct inode *inode, struct file *file) |
| 1057 | { |
| 1058 | struct ocxlflash_context *ctx = file->private_data; |
| 1059 | int i; |
| 1060 | |
| 1061 | /* Unmap and free the interrupts associated with the context */ |
| 1062 | for (i = ctx->num_irqs; i >= 0; i--) |
| 1063 | afu_unmap_irq(0, ctx, i, ctx); |
| 1064 | free_afu_irqs(ctx); |
| 1065 | |
| 1066 | return ocxlflash_release_context(ctx); |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * ocxlflash_mmap_fault() - mmap fault handler |
| 1071 | * @vmf: VM fault associated with current fault. |
| 1072 | * |
| 1073 | * Return: 0 on success, -errno on failure |
| 1074 | */ |
| 1075 | static int ocxlflash_mmap_fault(struct vm_fault *vmf) |
| 1076 | { |
| 1077 | struct vm_area_struct *vma = vmf->vma; |
| 1078 | struct ocxlflash_context *ctx = vma->vm_file->private_data; |
| 1079 | u64 mmio_area, offset; |
| 1080 | |
| 1081 | offset = vmf->pgoff << PAGE_SHIFT; |
| 1082 | if (offset >= ctx->psn_size) |
| 1083 | return VM_FAULT_SIGBUS; |
| 1084 | |
| 1085 | mmio_area = ctx->psn_phys; |
| 1086 | mmio_area += offset; |
| 1087 | |
| 1088 | vm_insert_pfn(vma, vmf->address, mmio_area >> PAGE_SHIFT); |
| 1089 | return VM_FAULT_NOPAGE; |
| 1090 | } |
| 1091 | |
| 1092 | static const struct vm_operations_struct ocxlflash_vmops = { |
| 1093 | .fault = ocxlflash_mmap_fault, |
| 1094 | }; |
| 1095 | |
| 1096 | /** |
| 1097 | * afu_mmap() - map the fault handler operations |
| 1098 | * @file: File associated with the context. |
| 1099 | * @vma: VM area associated with mapping. |
| 1100 | * |
| 1101 | * Return: 0 on success, -errno on failure |
| 1102 | */ |
| 1103 | static int afu_mmap(struct file *file, struct vm_area_struct *vma) |
| 1104 | { |
| 1105 | struct ocxlflash_context *ctx = file->private_data; |
| 1106 | |
| 1107 | if ((vma_pages(vma) + vma->vm_pgoff) > |
| 1108 | (ctx->psn_size >> PAGE_SHIFT)) |
| 1109 | return -EINVAL; |
| 1110 | |
| 1111 | vma->vm_flags |= VM_IO | VM_PFNMAP; |
| 1112 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
| 1113 | vma->vm_ops = &ocxlflash_vmops; |
| 1114 | return 0; |
| 1115 | } |
| 1116 | |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 1117 | static const struct file_operations ocxl_afu_fops = { |
| 1118 | .owner = THIS_MODULE, |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 1119 | .poll = afu_poll, |
Uma Krishnan | 03aa9c5 | 2018-03-26 11:34:12 -0500 | [diff] [blame] | 1120 | .read = afu_read, |
Uma Krishnan | 93b8f8d | 2018-03-26 11:34:20 -0500 | [diff] [blame] | 1121 | .release = afu_release, |
| 1122 | .mmap = afu_mmap, |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 1123 | }; |
| 1124 | |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 1125 | #define PATCH_FOPS(NAME) \ |
| 1126 | do { if (!fops->NAME) fops->NAME = ocxl_afu_fops.NAME; } while (0) |
| 1127 | |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 1128 | /** |
| 1129 | * ocxlflash_get_fd() - get file descriptor for an adapter context |
| 1130 | * @ctx_cookie: Adapter context. |
| 1131 | * @fops: File operations to be associated. |
| 1132 | * @fd: File descriptor to be returned back. |
| 1133 | * |
| 1134 | * Return: pointer to the file on success, ERR_PTR on failure |
| 1135 | */ |
| 1136 | static struct file *ocxlflash_get_fd(void *ctx_cookie, |
| 1137 | struct file_operations *fops, int *fd) |
| 1138 | { |
| 1139 | struct ocxlflash_context *ctx = ctx_cookie; |
| 1140 | struct device *dev = ctx->hw_afu->dev; |
| 1141 | struct file *file; |
| 1142 | int flags, fdtmp; |
| 1143 | int rc = 0; |
| 1144 | char *name = NULL; |
| 1145 | |
| 1146 | /* Only allow one fd per context */ |
| 1147 | if (ctx->mapping) { |
| 1148 | dev_err(dev, "%s: Context is already mapped to an fd\n", |
| 1149 | __func__); |
| 1150 | rc = -EEXIST; |
| 1151 | goto err1; |
| 1152 | } |
| 1153 | |
| 1154 | flags = O_RDWR | O_CLOEXEC; |
| 1155 | |
| 1156 | /* This code is similar to anon_inode_getfd() */ |
| 1157 | rc = get_unused_fd_flags(flags); |
| 1158 | if (unlikely(rc < 0)) { |
| 1159 | dev_err(dev, "%s: get_unused_fd_flags failed rc=%d\n", |
| 1160 | __func__, rc); |
| 1161 | goto err1; |
| 1162 | } |
| 1163 | fdtmp = rc; |
| 1164 | |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 1165 | /* Patch the file ops that are not defined */ |
| 1166 | if (fops) { |
| 1167 | PATCH_FOPS(poll); |
Uma Krishnan | 03aa9c5 | 2018-03-26 11:34:12 -0500 | [diff] [blame] | 1168 | PATCH_FOPS(read); |
Uma Krishnan | 93b8f8d | 2018-03-26 11:34:20 -0500 | [diff] [blame] | 1169 | PATCH_FOPS(release); |
| 1170 | PATCH_FOPS(mmap); |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 1171 | } else /* Use default ops */ |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 1172 | fops = (struct file_operations *)&ocxl_afu_fops; |
| 1173 | |
| 1174 | name = kasprintf(GFP_KERNEL, "ocxlflash:%d", ctx->pe); |
| 1175 | file = ocxlflash_getfile(dev, name, fops, ctx, flags); |
| 1176 | kfree(name); |
| 1177 | if (IS_ERR(file)) { |
| 1178 | rc = PTR_ERR(file); |
| 1179 | dev_err(dev, "%s: ocxlflash_getfile failed rc=%d\n", |
| 1180 | __func__, rc); |
| 1181 | goto err2; |
| 1182 | } |
| 1183 | |
| 1184 | ctx->mapping = file->f_mapping; |
| 1185 | *fd = fdtmp; |
| 1186 | out: |
| 1187 | return file; |
| 1188 | err2: |
| 1189 | put_unused_fd(fdtmp); |
| 1190 | err1: |
| 1191 | file = ERR_PTR(rc); |
| 1192 | goto out; |
| 1193 | } |
| 1194 | |
Uma Krishnan | b18718c | 2018-03-26 11:32:20 -0500 | [diff] [blame] | 1195 | /** |
| 1196 | * ocxlflash_fops_get_context() - get the context associated with the file |
| 1197 | * @file: File associated with the adapter context. |
| 1198 | * |
| 1199 | * Return: pointer to the context |
| 1200 | */ |
| 1201 | static void *ocxlflash_fops_get_context(struct file *file) |
| 1202 | { |
| 1203 | return file->private_data; |
| 1204 | } |
| 1205 | |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 1206 | /** |
| 1207 | * ocxlflash_afu_irq() - interrupt handler for user contexts |
| 1208 | * @irq: Interrupt number. |
| 1209 | * @data: Private data provided at interrupt registration, the context. |
| 1210 | * |
| 1211 | * Return: Always return IRQ_HANDLED. |
| 1212 | */ |
| 1213 | static irqreturn_t ocxlflash_afu_irq(int irq, void *data) |
| 1214 | { |
| 1215 | struct ocxlflash_context *ctx = data; |
| 1216 | struct device *dev = ctx->hw_afu->dev; |
| 1217 | int i; |
| 1218 | |
| 1219 | dev_dbg(dev, "%s: Interrupt raised for pe %i virq %i\n", |
| 1220 | __func__, ctx->pe, irq); |
| 1221 | |
| 1222 | for (i = 0; i < ctx->num_irqs; i++) { |
| 1223 | if (ctx->irqs[i].virq == irq) |
| 1224 | break; |
| 1225 | } |
| 1226 | if (unlikely(i >= ctx->num_irqs)) { |
| 1227 | dev_err(dev, "%s: Received AFU IRQ out of range\n", __func__); |
| 1228 | goto out; |
| 1229 | } |
| 1230 | |
| 1231 | spin_lock(&ctx->slock); |
| 1232 | set_bit(i - 1, &ctx->irq_bitmap); |
| 1233 | ctx->pending_irq = true; |
| 1234 | spin_unlock(&ctx->slock); |
Uma Krishnan | 56f1db1 | 2018-03-26 11:34:03 -0500 | [diff] [blame] | 1235 | |
| 1236 | wake_up_all(&ctx->wq); |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 1237 | out: |
| 1238 | return IRQ_HANDLED; |
| 1239 | } |
| 1240 | |
| 1241 | /** |
| 1242 | * ocxlflash_start_work() - start a user context |
| 1243 | * @ctx_cookie: Context to be started. |
| 1244 | * @num_irqs: Number of interrupts requested. |
| 1245 | * |
| 1246 | * Return: 0 on success, -errno on failure |
| 1247 | */ |
| 1248 | static int ocxlflash_start_work(void *ctx_cookie, u64 num_irqs) |
| 1249 | { |
| 1250 | struct ocxlflash_context *ctx = ctx_cookie; |
| 1251 | struct ocxl_hw_afu *afu = ctx->hw_afu; |
| 1252 | struct device *dev = afu->dev; |
| 1253 | char *name; |
| 1254 | int rc = 0; |
| 1255 | int i; |
| 1256 | |
| 1257 | rc = alloc_afu_irqs(ctx, num_irqs); |
| 1258 | if (unlikely(rc < 0)) { |
| 1259 | dev_err(dev, "%s: alloc_afu_irqs failed rc=%d\n", __func__, rc); |
| 1260 | goto out; |
| 1261 | } |
| 1262 | |
| 1263 | for (i = 0; i < num_irqs; i++) { |
| 1264 | name = kasprintf(GFP_KERNEL, "ocxlflash-%s-pe%i-%i", |
| 1265 | dev_name(dev), ctx->pe, i); |
| 1266 | rc = afu_map_irq(0, ctx, i, ocxlflash_afu_irq, ctx, name); |
| 1267 | kfree(name); |
| 1268 | if (unlikely(rc < 0)) { |
| 1269 | dev_err(dev, "%s: afu_map_irq failed rc=%d\n", |
| 1270 | __func__, rc); |
| 1271 | goto err; |
| 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | rc = start_context(ctx); |
| 1276 | if (unlikely(rc)) { |
| 1277 | dev_err(dev, "%s: start_context failed rc=%d\n", __func__, rc); |
| 1278 | goto err; |
| 1279 | } |
| 1280 | out: |
| 1281 | return rc; |
| 1282 | err: |
| 1283 | for (i = i-1; i >= 0; i--) |
| 1284 | afu_unmap_irq(0, ctx, i, ctx); |
| 1285 | free_afu_irqs(ctx); |
| 1286 | goto out; |
Uma Krishnan | e117c3c | 2018-03-26 11:34:27 -0500 | [diff] [blame] | 1287 | }; |
| 1288 | |
| 1289 | /** |
| 1290 | * ocxlflash_fd_mmap() - mmap handler for adapter file descriptor |
| 1291 | * @file: File installed with adapter file descriptor. |
| 1292 | * @vma: VM area associated with mapping. |
| 1293 | * |
| 1294 | * Return: 0 on success, -errno on failure |
| 1295 | */ |
| 1296 | static int ocxlflash_fd_mmap(struct file *file, struct vm_area_struct *vma) |
| 1297 | { |
| 1298 | return afu_mmap(file, vma); |
| 1299 | } |
| 1300 | |
| 1301 | /** |
| 1302 | * ocxlflash_fd_release() - release the context associated with the file |
| 1303 | * @inode: File inode pointer. |
| 1304 | * @file: File associated with the adapter context. |
| 1305 | * |
| 1306 | * Return: 0 on success, -errno on failure |
| 1307 | */ |
| 1308 | static int ocxlflash_fd_release(struct inode *inode, struct file *file) |
| 1309 | { |
| 1310 | return afu_release(inode, file); |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 1311 | } |
| 1312 | |
Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 1313 | /* Backend ops to ocxlflash services */ |
| 1314 | const struct cxlflash_backend_ops cxlflash_ocxl_ops = { |
| 1315 | .module = THIS_MODULE, |
Uma Krishnan | 012f394 | 2018-03-26 11:32:56 -0500 | [diff] [blame] | 1316 | .psa_map = ocxlflash_psa_map, |
| 1317 | .psa_unmap = ocxlflash_psa_unmap, |
Uma Krishnan | b18718c | 2018-03-26 11:32:20 -0500 | [diff] [blame] | 1318 | .process_element = ocxlflash_process_element, |
Uma Krishnan | a06b1cf | 2018-03-26 11:33:48 -0500 | [diff] [blame] | 1319 | .map_afu_irq = ocxlflash_map_afu_irq, |
| 1320 | .unmap_afu_irq = ocxlflash_unmap_afu_irq, |
Uma Krishnan | 402a55e | 2018-03-26 11:34:35 -0500 | [diff] [blame^] | 1321 | .get_irq_objhndl = ocxlflash_get_irq_objhndl, |
Uma Krishnan | 6b938ac | 2018-03-26 11:32:48 -0500 | [diff] [blame] | 1322 | .start_context = ocxlflash_start_context, |
Uma Krishnan | c207b57 | 2018-03-26 11:33:35 -0500 | [diff] [blame] | 1323 | .stop_context = ocxlflash_stop_context, |
Uma Krishnan | f6b4557c | 2018-03-26 11:31:53 -0500 | [diff] [blame] | 1324 | .set_master = ocxlflash_set_master, |
| 1325 | .get_context = ocxlflash_get_context, |
| 1326 | .dev_context_init = ocxlflash_dev_context_init, |
| 1327 | .release_context = ocxlflash_release_context, |
Uma Krishnan | 8b7a552 | 2018-03-26 11:32:29 -0500 | [diff] [blame] | 1328 | .perst_reloads_same_image = ocxlflash_perst_reloads_same_image, |
Uma Krishnan | 119c920 | 2018-03-26 11:33:14 -0500 | [diff] [blame] | 1329 | .read_adapter_vpd = ocxlflash_read_adapter_vpd, |
Uma Krishnan | bc65c1c | 2018-03-26 11:33:41 -0500 | [diff] [blame] | 1330 | .allocate_afu_irqs = ocxlflash_allocate_afu_irqs, |
| 1331 | .free_afu_irqs = ocxlflash_free_afu_irqs, |
Uma Krishnan | 48e077d | 2018-03-26 11:31:01 -0500 | [diff] [blame] | 1332 | .create_afu = ocxlflash_create_afu, |
| 1333 | .destroy_afu = ocxlflash_destroy_afu, |
Uma Krishnan | 926a62f | 2018-03-26 11:32:09 -0500 | [diff] [blame] | 1334 | .get_fd = ocxlflash_get_fd, |
Uma Krishnan | b18718c | 2018-03-26 11:32:20 -0500 | [diff] [blame] | 1335 | .fops_get_context = ocxlflash_fops_get_context, |
Uma Krishnan | 762c7e9 | 2018-03-26 11:33:55 -0500 | [diff] [blame] | 1336 | .start_work = ocxlflash_start_work, |
Uma Krishnan | e117c3c | 2018-03-26 11:34:27 -0500 | [diff] [blame] | 1337 | .fd_mmap = ocxlflash_fd_mmap, |
| 1338 | .fd_release = ocxlflash_fd_release, |
Uma Krishnan | 76ebe01 | 2018-03-26 11:30:51 -0500 | [diff] [blame] | 1339 | }; |