Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  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
 15#include <misc/cxl.h>
 16
 17#include "backend.h"
 18
 19/*
 20 * The following routines map the cxlflash backend operations to existing CXL
 21 * kernel API function and are largely simple shims that provide an abstraction
 22 * for converting generic context and AFU cookies into cxl_context or cxl_afu
 23 * pointers.
 24 */
 25
 26static void __iomem *cxlflash_psa_map(void *ctx_cookie)
 27{
 28	return cxl_psa_map(ctx_cookie);
 29}
 30
 31static void cxlflash_psa_unmap(void __iomem *addr)
 32{
 33	cxl_psa_unmap(addr);
 34}
 35
 36static int cxlflash_process_element(void *ctx_cookie)
 37{
 38	return cxl_process_element(ctx_cookie);
 39}
 40
 41static int cxlflash_map_afu_irq(void *ctx_cookie, int num,
 42				irq_handler_t handler, void *cookie, char *name)
 43{
 44	return cxl_map_afu_irq(ctx_cookie, num, handler, cookie, name);
 45}
 46
 47static void cxlflash_unmap_afu_irq(void *ctx_cookie, int num, void *cookie)
 48{
 49	cxl_unmap_afu_irq(ctx_cookie, num, cookie);
 50}
 51
 52static int cxlflash_start_context(void *ctx_cookie)
 53{
 54	return cxl_start_context(ctx_cookie, 0, NULL);
 55}
 56
 57static int cxlflash_stop_context(void *ctx_cookie)
 58{
 59	return cxl_stop_context(ctx_cookie);
 60}
 61
 62static int cxlflash_afu_reset(void *ctx_cookie)
 63{
 64	return cxl_afu_reset(ctx_cookie);
 65}
 66
 67static void cxlflash_set_master(void *ctx_cookie)
 68{
 69	cxl_set_master(ctx_cookie);
 70}
 71
 72static void *cxlflash_get_context(struct pci_dev *dev, void *afu_cookie)
 73{
 74	return cxl_get_context(dev);
 75}
 76
 77static void *cxlflash_dev_context_init(struct pci_dev *dev, void *afu_cookie)
 78{
 79	return cxl_dev_context_init(dev);
 80}
 81
 82static int cxlflash_release_context(void *ctx_cookie)
 83{
 84	return cxl_release_context(ctx_cookie);
 85}
 86
 87static void cxlflash_perst_reloads_same_image(void *afu_cookie, bool image)
 88{
 89	cxl_perst_reloads_same_image(afu_cookie, image);
 90}
 91
 92static ssize_t cxlflash_read_adapter_vpd(struct pci_dev *dev,
 93					 void *buf, size_t count)
 94{
 95	return cxl_read_adapter_vpd(dev, buf, count);
 96}
 97
 98static int cxlflash_allocate_afu_irqs(void *ctx_cookie, int num)
 99{
100	return cxl_allocate_afu_irqs(ctx_cookie, num);
101}
102
103static void cxlflash_free_afu_irqs(void *ctx_cookie)
104{
105	cxl_free_afu_irqs(ctx_cookie);
106}
107
108static void *cxlflash_create_afu(struct pci_dev *dev)
109{
110	return cxl_pci_to_afu(dev);
111}
112
113static struct file *cxlflash_get_fd(void *ctx_cookie,
114				    struct file_operations *fops, int *fd)
115{
116	return cxl_get_fd(ctx_cookie, fops, fd);
117}
118
119static void *cxlflash_fops_get_context(struct file *file)
120{
121	return cxl_fops_get_context(file);
122}
123
124static int cxlflash_start_work(void *ctx_cookie, u64 irqs)
125{
126	struct cxl_ioctl_start_work work = { 0 };
127
128	work.num_interrupts = irqs;
129	work.flags = CXL_START_WORK_NUM_IRQS;
130
131	return cxl_start_work(ctx_cookie, &work);
132}
133
134static int cxlflash_fd_mmap(struct file *file, struct vm_area_struct *vm)
135{
136	return cxl_fd_mmap(file, vm);
137}
138
139static int cxlflash_fd_release(struct inode *inode, struct file *file)
140{
141	return cxl_fd_release(inode, file);
142}
143
144const struct cxlflash_backend_ops cxlflash_cxl_ops = {
145	.module			= THIS_MODULE,
146	.psa_map		= cxlflash_psa_map,
147	.psa_unmap		= cxlflash_psa_unmap,
148	.process_element	= cxlflash_process_element,
149	.map_afu_irq		= cxlflash_map_afu_irq,
150	.unmap_afu_irq		= cxlflash_unmap_afu_irq,
151	.start_context		= cxlflash_start_context,
152	.stop_context		= cxlflash_stop_context,
153	.afu_reset		= cxlflash_afu_reset,
154	.set_master		= cxlflash_set_master,
155	.get_context		= cxlflash_get_context,
156	.dev_context_init	= cxlflash_dev_context_init,
157	.release_context	= cxlflash_release_context,
158	.perst_reloads_same_image = cxlflash_perst_reloads_same_image,
159	.read_adapter_vpd	= cxlflash_read_adapter_vpd,
160	.allocate_afu_irqs	= cxlflash_allocate_afu_irqs,
161	.free_afu_irqs		= cxlflash_free_afu_irqs,
162	.create_afu		= cxlflash_create_afu,
163	.get_fd			= cxlflash_get_fd,
164	.fops_get_context	= cxlflash_fops_get_context,
165	.start_work		= cxlflash_start_work,
166	.fd_mmap		= cxlflash_fd_mmap,
167	.fd_release		= cxlflash_fd_release,
168};