GNU Linux-libre 4.14.328-gnu1
[releases.git] / drivers / vfio / platform / vfio_platform_common.c
1 /*
2  * Copyright (C) 2013 - Virtual Open Systems
3  * Author: Antonios Motakis <a.motakis@virtualopensystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License, version 2, as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include <linux/device.h>
16 #include <linux/acpi.h>
17 #include <linux/iommu.h>
18 #include <linux/module.h>
19 #include <linux/mutex.h>
20 #include <linux/slab.h>
21 #include <linux/types.h>
22 #include <linux/uaccess.h>
23 #include <linux/vfio.h>
24
25 #include "vfio_platform_private.h"
26
27 #define DRIVER_VERSION  "0.10"
28 #define DRIVER_AUTHOR   "Antonios Motakis <a.motakis@virtualopensystems.com>"
29 #define DRIVER_DESC     "VFIO platform base module"
30
31 #define VFIO_PLATFORM_IS_ACPI(vdev) ((vdev)->acpihid != NULL)
32
33 static LIST_HEAD(reset_list);
34 static DEFINE_MUTEX(driver_lock);
35
36 static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat,
37                                         struct module **module)
38 {
39         struct vfio_platform_reset_node *iter;
40         vfio_platform_reset_fn_t reset_fn = NULL;
41
42         mutex_lock(&driver_lock);
43         list_for_each_entry(iter, &reset_list, link) {
44                 if (!strcmp(iter->compat, compat) &&
45                         try_module_get(iter->owner)) {
46                         *module = iter->owner;
47                         reset_fn = iter->of_reset;
48                         break;
49                 }
50         }
51         mutex_unlock(&driver_lock);
52         return reset_fn;
53 }
54
55 static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
56                                     struct device *dev)
57 {
58         struct acpi_device *adev;
59
60         if (acpi_disabled)
61                 return -ENOENT;
62
63         adev = ACPI_COMPANION(dev);
64         if (!adev) {
65                 pr_err("VFIO: ACPI companion device not found for %s\n",
66                         vdev->name);
67                 return -ENODEV;
68         }
69
70 #ifdef CONFIG_ACPI
71         vdev->acpihid = acpi_device_hid(adev);
72 #endif
73         return WARN_ON(!vdev->acpihid) ? -EINVAL : 0;
74 }
75
76 static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
77                                   const char **extra_dbg)
78 {
79 #ifdef CONFIG_ACPI
80         struct device *dev = vdev->device;
81         acpi_handle handle = ACPI_HANDLE(dev);
82         acpi_status acpi_ret;
83
84         acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
85         if (ACPI_FAILURE(acpi_ret)) {
86                 if (extra_dbg)
87                         *extra_dbg = acpi_format_exception(acpi_ret);
88                 return -EINVAL;
89         }
90
91         return 0;
92 #else
93         return -ENOENT;
94 #endif
95 }
96
97 static bool vfio_platform_acpi_has_reset(struct vfio_platform_device *vdev)
98 {
99 #ifdef CONFIG_ACPI
100         struct device *dev = vdev->device;
101         acpi_handle handle = ACPI_HANDLE(dev);
102
103         return acpi_has_method(handle, "_RST");
104 #else
105         return false;
106 #endif
107 }
108
109 static bool vfio_platform_has_reset(struct vfio_platform_device *vdev)
110 {
111         if (VFIO_PLATFORM_IS_ACPI(vdev))
112                 return vfio_platform_acpi_has_reset(vdev);
113
114         return vdev->of_reset ? true : false;
115 }
116
117 static int vfio_platform_get_reset(struct vfio_platform_device *vdev)
118 {
119         if (VFIO_PLATFORM_IS_ACPI(vdev))
120                 return vfio_platform_acpi_has_reset(vdev) ? 0 : -ENOENT;
121
122         vdev->of_reset = vfio_platform_lookup_reset(vdev->compat,
123                                                     &vdev->reset_module);
124         if (!vdev->of_reset) {
125                 request_module("vfio-reset:%s", vdev->compat);
126                 vdev->of_reset = vfio_platform_lookup_reset(vdev->compat,
127                                                         &vdev->reset_module);
128         }
129
130         return vdev->of_reset ? 0 : -ENOENT;
131 }
132
133 static void vfio_platform_put_reset(struct vfio_platform_device *vdev)
134 {
135         if (VFIO_PLATFORM_IS_ACPI(vdev))
136                 return;
137
138         if (vdev->of_reset)
139                 module_put(vdev->reset_module);
140 }
141
142 static int vfio_platform_regions_init(struct vfio_platform_device *vdev)
143 {
144         int cnt = 0, i;
145
146         while (vdev->get_resource(vdev, cnt))
147                 cnt++;
148
149         vdev->regions = kcalloc(cnt, sizeof(struct vfio_platform_region),
150                                 GFP_KERNEL);
151         if (!vdev->regions)
152                 return -ENOMEM;
153
154         for (i = 0; i < cnt;  i++) {
155                 struct resource *res =
156                         vdev->get_resource(vdev, i);
157
158                 if (!res)
159                         goto err;
160
161                 vdev->regions[i].addr = res->start;
162                 vdev->regions[i].size = resource_size(res);
163                 vdev->regions[i].flags = 0;
164
165                 switch (resource_type(res)) {
166                 case IORESOURCE_MEM:
167                         vdev->regions[i].type = VFIO_PLATFORM_REGION_TYPE_MMIO;
168                         vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ;
169                         if (!(res->flags & IORESOURCE_READONLY))
170                                 vdev->regions[i].flags |=
171                                         VFIO_REGION_INFO_FLAG_WRITE;
172
173                         /*
174                          * Only regions addressed with PAGE granularity may be
175                          * MMAPed securely.
176                          */
177                         if (!(vdev->regions[i].addr & ~PAGE_MASK) &&
178                                         !(vdev->regions[i].size & ~PAGE_MASK))
179                                 vdev->regions[i].flags |=
180                                         VFIO_REGION_INFO_FLAG_MMAP;
181
182                         break;
183                 case IORESOURCE_IO:
184                         vdev->regions[i].type = VFIO_PLATFORM_REGION_TYPE_PIO;
185                         break;
186                 default:
187                         goto err;
188                 }
189         }
190
191         vdev->num_regions = cnt;
192
193         return 0;
194 err:
195         kfree(vdev->regions);
196         return -EINVAL;
197 }
198
199 static void vfio_platform_regions_cleanup(struct vfio_platform_device *vdev)
200 {
201         int i;
202
203         for (i = 0; i < vdev->num_regions; i++)
204                 iounmap(vdev->regions[i].ioaddr);
205
206         vdev->num_regions = 0;
207         kfree(vdev->regions);
208 }
209
210 static int vfio_platform_call_reset(struct vfio_platform_device *vdev,
211                                     const char **extra_dbg)
212 {
213         if (VFIO_PLATFORM_IS_ACPI(vdev)) {
214                 dev_info(vdev->device, "reset\n");
215                 return vfio_platform_acpi_call_reset(vdev, extra_dbg);
216         } else if (vdev->of_reset) {
217                 dev_info(vdev->device, "reset\n");
218                 return vdev->of_reset(vdev);
219         }
220
221         dev_warn(vdev->device, "no reset function found!\n");
222         return -EINVAL;
223 }
224
225 static void vfio_platform_release(void *device_data)
226 {
227         struct vfio_platform_device *vdev = device_data;
228
229         mutex_lock(&driver_lock);
230
231         if (!(--vdev->refcnt)) {
232                 const char *extra_dbg = NULL;
233                 int ret;
234
235                 ret = vfio_platform_call_reset(vdev, &extra_dbg);
236                 if (ret && vdev->reset_required) {
237                         dev_warn(vdev->device, "reset driver is required and reset call failed in release (%d) %s\n",
238                                  ret, extra_dbg ? extra_dbg : "");
239                         WARN_ON(1);
240                 }
241                 vfio_platform_regions_cleanup(vdev);
242                 vfio_platform_irq_cleanup(vdev);
243         }
244
245         mutex_unlock(&driver_lock);
246
247         module_put(vdev->parent_module);
248 }
249
250 static int vfio_platform_open(void *device_data)
251 {
252         struct vfio_platform_device *vdev = device_data;
253         int ret;
254
255         if (!try_module_get(vdev->parent_module))
256                 return -ENODEV;
257
258         mutex_lock(&driver_lock);
259
260         if (!vdev->refcnt) {
261                 const char *extra_dbg = NULL;
262
263                 ret = vfio_platform_regions_init(vdev);
264                 if (ret)
265                         goto err_reg;
266
267                 ret = vfio_platform_irq_init(vdev);
268                 if (ret)
269                         goto err_irq;
270
271                 ret = vfio_platform_call_reset(vdev, &extra_dbg);
272                 if (ret && vdev->reset_required) {
273                         dev_warn(vdev->device, "reset driver is required and reset call failed in open (%d) %s\n",
274                                  ret, extra_dbg ? extra_dbg : "");
275                         goto err_rst;
276                 }
277         }
278
279         vdev->refcnt++;
280
281         mutex_unlock(&driver_lock);
282         return 0;
283
284 err_rst:
285         vfio_platform_irq_cleanup(vdev);
286 err_irq:
287         vfio_platform_regions_cleanup(vdev);
288 err_reg:
289         mutex_unlock(&driver_lock);
290         module_put(vdev->parent_module);
291         return ret;
292 }
293
294 static long vfio_platform_ioctl(void *device_data,
295                                 unsigned int cmd, unsigned long arg)
296 {
297         struct vfio_platform_device *vdev = device_data;
298         unsigned long minsz;
299
300         if (cmd == VFIO_DEVICE_GET_INFO) {
301                 struct vfio_device_info info;
302
303                 minsz = offsetofend(struct vfio_device_info, num_irqs);
304
305                 if (copy_from_user(&info, (void __user *)arg, minsz))
306                         return -EFAULT;
307
308                 if (info.argsz < minsz)
309                         return -EINVAL;
310
311                 if (vfio_platform_has_reset(vdev))
312                         vdev->flags |= VFIO_DEVICE_FLAGS_RESET;
313                 info.flags = vdev->flags;
314                 info.num_regions = vdev->num_regions;
315                 info.num_irqs = vdev->num_irqs;
316
317                 return copy_to_user((void __user *)arg, &info, minsz) ?
318                         -EFAULT : 0;
319
320         } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
321                 struct vfio_region_info info;
322
323                 minsz = offsetofend(struct vfio_region_info, offset);
324
325                 if (copy_from_user(&info, (void __user *)arg, minsz))
326                         return -EFAULT;
327
328                 if (info.argsz < minsz)
329                         return -EINVAL;
330
331                 if (info.index >= vdev->num_regions)
332                         return -EINVAL;
333
334                 /* map offset to the physical address  */
335                 info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index);
336                 info.size = vdev->regions[info.index].size;
337                 info.flags = vdev->regions[info.index].flags;
338
339                 return copy_to_user((void __user *)arg, &info, minsz) ?
340                         -EFAULT : 0;
341
342         } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) {
343                 struct vfio_irq_info info;
344
345                 minsz = offsetofend(struct vfio_irq_info, count);
346
347                 if (copy_from_user(&info, (void __user *)arg, minsz))
348                         return -EFAULT;
349
350                 if (info.argsz < minsz)
351                         return -EINVAL;
352
353                 if (info.index >= vdev->num_irqs)
354                         return -EINVAL;
355
356                 info.flags = vdev->irqs[info.index].flags;
357                 info.count = vdev->irqs[info.index].count;
358
359                 return copy_to_user((void __user *)arg, &info, minsz) ?
360                         -EFAULT : 0;
361
362         } else if (cmd == VFIO_DEVICE_SET_IRQS) {
363                 struct vfio_irq_set hdr;
364                 u8 *data = NULL;
365                 int ret = 0;
366                 size_t data_size = 0;
367
368                 minsz = offsetofend(struct vfio_irq_set, count);
369
370                 if (copy_from_user(&hdr, (void __user *)arg, minsz))
371                         return -EFAULT;
372
373                 ret = vfio_set_irqs_validate_and_prepare(&hdr, vdev->num_irqs,
374                                                  vdev->num_irqs, &data_size);
375                 if (ret)
376                         return ret;
377
378                 if (data_size) {
379                         data = memdup_user((void __user *)(arg + minsz),
380                                             data_size);
381                         if (IS_ERR(data))
382                                 return PTR_ERR(data);
383                 }
384
385                 mutex_lock(&vdev->igate);
386
387                 ret = vfio_platform_set_irqs_ioctl(vdev, hdr.flags, hdr.index,
388                                                    hdr.start, hdr.count, data);
389                 mutex_unlock(&vdev->igate);
390                 kfree(data);
391
392                 return ret;
393
394         } else if (cmd == VFIO_DEVICE_RESET) {
395                 return vfio_platform_call_reset(vdev, NULL);
396         }
397
398         return -ENOTTY;
399 }
400
401 static ssize_t vfio_platform_read_mmio(struct vfio_platform_region *reg,
402                                        char __user *buf, size_t count,
403                                        loff_t off)
404 {
405         unsigned int done = 0;
406
407         if (!reg->ioaddr) {
408                 reg->ioaddr =
409                         ioremap_nocache(reg->addr, reg->size);
410
411                 if (!reg->ioaddr)
412                         return -ENOMEM;
413         }
414
415         while (count) {
416                 size_t filled;
417
418                 if (count >= 4 && !(off % 4)) {
419                         u32 val;
420
421                         val = ioread32(reg->ioaddr + off);
422                         if (copy_to_user(buf, &val, 4))
423                                 goto err;
424
425                         filled = 4;
426                 } else if (count >= 2 && !(off % 2)) {
427                         u16 val;
428
429                         val = ioread16(reg->ioaddr + off);
430                         if (copy_to_user(buf, &val, 2))
431                                 goto err;
432
433                         filled = 2;
434                 } else {
435                         u8 val;
436
437                         val = ioread8(reg->ioaddr + off);
438                         if (copy_to_user(buf, &val, 1))
439                                 goto err;
440
441                         filled = 1;
442                 }
443
444
445                 count -= filled;
446                 done += filled;
447                 off += filled;
448                 buf += filled;
449         }
450
451         return done;
452 err:
453         return -EFAULT;
454 }
455
456 static ssize_t vfio_platform_read(void *device_data, char __user *buf,
457                                   size_t count, loff_t *ppos)
458 {
459         struct vfio_platform_device *vdev = device_data;
460         unsigned int index = VFIO_PLATFORM_OFFSET_TO_INDEX(*ppos);
461         loff_t off = *ppos & VFIO_PLATFORM_OFFSET_MASK;
462
463         if (index >= vdev->num_regions)
464                 return -EINVAL;
465
466         if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ))
467                 return -EINVAL;
468
469         if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_MMIO)
470                 return vfio_platform_read_mmio(&vdev->regions[index],
471                                                         buf, count, off);
472         else if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_PIO)
473                 return -EINVAL; /* not implemented */
474
475         return -EINVAL;
476 }
477
478 static ssize_t vfio_platform_write_mmio(struct vfio_platform_region *reg,
479                                         const char __user *buf, size_t count,
480                                         loff_t off)
481 {
482         unsigned int done = 0;
483
484         if (!reg->ioaddr) {
485                 reg->ioaddr =
486                         ioremap_nocache(reg->addr, reg->size);
487
488                 if (!reg->ioaddr)
489                         return -ENOMEM;
490         }
491
492         while (count) {
493                 size_t filled;
494
495                 if (count >= 4 && !(off % 4)) {
496                         u32 val;
497
498                         if (copy_from_user(&val, buf, 4))
499                                 goto err;
500                         iowrite32(val, reg->ioaddr + off);
501
502                         filled = 4;
503                 } else if (count >= 2 && !(off % 2)) {
504                         u16 val;
505
506                         if (copy_from_user(&val, buf, 2))
507                                 goto err;
508                         iowrite16(val, reg->ioaddr + off);
509
510                         filled = 2;
511                 } else {
512                         u8 val;
513
514                         if (copy_from_user(&val, buf, 1))
515                                 goto err;
516                         iowrite8(val, reg->ioaddr + off);
517
518                         filled = 1;
519                 }
520
521                 count -= filled;
522                 done += filled;
523                 off += filled;
524                 buf += filled;
525         }
526
527         return done;
528 err:
529         return -EFAULT;
530 }
531
532 static ssize_t vfio_platform_write(void *device_data, const char __user *buf,
533                                    size_t count, loff_t *ppos)
534 {
535         struct vfio_platform_device *vdev = device_data;
536         unsigned int index = VFIO_PLATFORM_OFFSET_TO_INDEX(*ppos);
537         loff_t off = *ppos & VFIO_PLATFORM_OFFSET_MASK;
538
539         if (index >= vdev->num_regions)
540                 return -EINVAL;
541
542         if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE))
543                 return -EINVAL;
544
545         if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_MMIO)
546                 return vfio_platform_write_mmio(&vdev->regions[index],
547                                                         buf, count, off);
548         else if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_PIO)
549                 return -EINVAL; /* not implemented */
550
551         return -EINVAL;
552 }
553
554 static int vfio_platform_mmap_mmio(struct vfio_platform_region region,
555                                    struct vm_area_struct *vma)
556 {
557         u64 req_len, pgoff, req_start;
558
559         req_len = vma->vm_end - vma->vm_start;
560         pgoff = vma->vm_pgoff &
561                 ((1U << (VFIO_PLATFORM_OFFSET_SHIFT - PAGE_SHIFT)) - 1);
562         req_start = pgoff << PAGE_SHIFT;
563
564         if (region.size < PAGE_SIZE || req_start + req_len > region.size)
565                 return -EINVAL;
566
567         vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
568         vma->vm_pgoff = (region.addr >> PAGE_SHIFT) + pgoff;
569
570         return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
571                                req_len, vma->vm_page_prot);
572 }
573
574 static int vfio_platform_mmap(void *device_data, struct vm_area_struct *vma)
575 {
576         struct vfio_platform_device *vdev = device_data;
577         unsigned int index;
578
579         index = vma->vm_pgoff >> (VFIO_PLATFORM_OFFSET_SHIFT - PAGE_SHIFT);
580
581         if (vma->vm_end < vma->vm_start)
582                 return -EINVAL;
583         if (!(vma->vm_flags & VM_SHARED))
584                 return -EINVAL;
585         if (index >= vdev->num_regions)
586                 return -EINVAL;
587         if (vma->vm_start & ~PAGE_MASK)
588                 return -EINVAL;
589         if (vma->vm_end & ~PAGE_MASK)
590                 return -EINVAL;
591
592         if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_MMAP))
593                 return -EINVAL;
594
595         if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ)
596                         && (vma->vm_flags & VM_READ))
597                 return -EINVAL;
598
599         if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE)
600                         && (vma->vm_flags & VM_WRITE))
601                 return -EINVAL;
602
603         vma->vm_private_data = vdev;
604
605         if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_MMIO)
606                 return vfio_platform_mmap_mmio(vdev->regions[index], vma);
607
608         else if (vdev->regions[index].type & VFIO_PLATFORM_REGION_TYPE_PIO)
609                 return -EINVAL; /* not implemented */
610
611         return -EINVAL;
612 }
613
614 static const struct vfio_device_ops vfio_platform_ops = {
615         .name           = "vfio-platform",
616         .open           = vfio_platform_open,
617         .release        = vfio_platform_release,
618         .ioctl          = vfio_platform_ioctl,
619         .read           = vfio_platform_read,
620         .write          = vfio_platform_write,
621         .mmap           = vfio_platform_mmap,
622 };
623
624 static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
625                            struct device *dev)
626 {
627         int ret;
628
629         ret = device_property_read_string(dev, "compatible",
630                                           &vdev->compat);
631         if (ret)
632                 pr_err("VFIO: cannot retrieve compat for %s\n",
633                         vdev->name);
634
635         return ret;
636 }
637
638 /*
639  * There can be two kernel build combinations. One build where
640  * ACPI is not selected in Kconfig and another one with the ACPI Kconfig.
641  *
642  * In the first case, vfio_platform_acpi_probe will return since
643  * acpi_disabled is 1. DT user will not see any kind of messages from
644  * ACPI.
645  *
646  * In the second case, both DT and ACPI is compiled in but the system is
647  * booting with any of these combinations.
648  *
649  * If the firmware is DT type, then acpi_disabled is 1. The ACPI probe routine
650  * terminates immediately without any messages.
651  *
652  * If the firmware is ACPI type, then acpi_disabled is 0. All other checks are
653  * valid checks. We cannot claim that this system is DT.
654  */
655 int vfio_platform_probe_common(struct vfio_platform_device *vdev,
656                                struct device *dev)
657 {
658         struct iommu_group *group;
659         int ret;
660
661         if (!vdev)
662                 return -EINVAL;
663
664         ret = vfio_platform_acpi_probe(vdev, dev);
665         if (ret)
666                 ret = vfio_platform_of_probe(vdev, dev);
667
668         if (ret)
669                 return ret;
670
671         vdev->device = dev;
672
673         ret = vfio_platform_get_reset(vdev);
674         if (ret && vdev->reset_required) {
675                 pr_err("vfio: no reset function found for device %s\n",
676                        vdev->name);
677                 return ret;
678         }
679
680         group = vfio_iommu_group_get(dev);
681         if (!group) {
682                 pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
683                 ret = -EINVAL;
684                 goto put_reset;
685         }
686
687         ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
688         if (ret)
689                 goto put_iommu;
690
691         mutex_init(&vdev->igate);
692
693         return 0;
694
695 put_iommu:
696         vfio_iommu_group_put(group, dev);
697 put_reset:
698         vfio_platform_put_reset(vdev);
699         return ret;
700 }
701 EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
702
703 struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
704 {
705         struct vfio_platform_device *vdev;
706
707         vdev = vfio_del_group_dev(dev);
708
709         if (vdev) {
710                 vfio_platform_put_reset(vdev);
711                 vfio_iommu_group_put(dev->iommu_group, dev);
712         }
713
714         return vdev;
715 }
716 EXPORT_SYMBOL_GPL(vfio_platform_remove_common);
717
718 void __vfio_platform_register_reset(struct vfio_platform_reset_node *node)
719 {
720         mutex_lock(&driver_lock);
721         list_add(&node->link, &reset_list);
722         mutex_unlock(&driver_lock);
723 }
724 EXPORT_SYMBOL_GPL(__vfio_platform_register_reset);
725
726 void vfio_platform_unregister_reset(const char *compat,
727                                     vfio_platform_reset_fn_t fn)
728 {
729         struct vfio_platform_reset_node *iter, *temp;
730
731         mutex_lock(&driver_lock);
732         list_for_each_entry_safe(iter, temp, &reset_list, link) {
733                 if (!strcmp(iter->compat, compat) && (iter->of_reset == fn)) {
734                         list_del(&iter->link);
735                         break;
736                 }
737         }
738
739         mutex_unlock(&driver_lock);
740
741 }
742 EXPORT_SYMBOL_GPL(vfio_platform_unregister_reset);
743
744 MODULE_VERSION(DRIVER_VERSION);
745 MODULE_LICENSE("GPL v2");
746 MODULE_AUTHOR(DRIVER_AUTHOR);
747 MODULE_DESCRIPTION(DRIVER_DESC);