2 * Volume Management Device driver
3 * Copyright (c) 2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include <linux/device.h>
16 #include <linux/interrupt.h>
17 #include <linux/irq.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/msi.h>
21 #include <linux/pci.h>
22 #include <linux/srcu.h>
23 #include <linux/rculist.h>
24 #include <linux/rcupdate.h>
26 #include <asm/irqdomain.h>
27 #include <asm/device.h>
29 #include <asm/msidef.h>
36 * Lock for manipulating VMD IRQ lists.
38 static DEFINE_RAW_SPINLOCK(list_lock
);
41 * struct vmd_irq - private data to map driver IRQ to the VMD shared vector
42 * @node: list item for parent traversal.
43 * @irq: back pointer to parent.
44 * @enabled: true if driver enabled IRQ
45 * @virq: the virtual IRQ value provided to the requesting driver.
47 * Every MSI/MSI-X IRQ requested for a device in a VMD domain will be mapped to
48 * a VMD IRQ using this structure.
51 struct list_head node
;
52 struct vmd_irq_list
*irq
;
58 * struct vmd_irq_list - list of driver requested IRQs mapping to a VMD vector
59 * @irq_list: the list of irq's the VMD one demuxes to.
60 * @srcu: SRCU struct for local synchronization.
61 * @count: number of child IRQs assigned to this vector; used to track
65 struct list_head irq_list
;
66 struct srcu_struct srcu
;
77 struct vmd_irq_list
*irqs
;
79 struct pci_sysdata sysdata
;
80 struct resource resources
[3];
81 struct irq_domain
*irq_domain
;
84 #ifdef CONFIG_X86_DEV_DMA_OPS
85 struct dma_map_ops dma_ops
;
86 struct dma_domain dma_domain
;
90 static inline struct vmd_dev
*vmd_from_bus(struct pci_bus
*bus
)
92 return container_of(bus
->sysdata
, struct vmd_dev
, sysdata
);
95 static inline unsigned int index_from_irqs(struct vmd_dev
*vmd
,
96 struct vmd_irq_list
*irqs
)
98 return irqs
- vmd
->irqs
;
102 * Drivers managing a device in a VMD domain allocate their own IRQs as before,
103 * but the MSI entry for the hardware it's driving will be programmed with a
104 * destination ID for the VMD MSI-X table. The VMD muxes interrupts in its
105 * domain into one of its own, and the VMD driver de-muxes these for the
106 * handlers sharing that VMD IRQ. The vmd irq_domain provides the operations
107 * and irq_chip to set this up.
109 static void vmd_compose_msi_msg(struct irq_data
*data
, struct msi_msg
*msg
)
111 struct vmd_irq
*vmdirq
= data
->chip_data
;
112 struct vmd_irq_list
*irq
= vmdirq
->irq
;
113 struct vmd_dev
*vmd
= irq_data_get_irq_handler_data(data
);
115 msg
->address_hi
= MSI_ADDR_BASE_HI
;
116 msg
->address_lo
= MSI_ADDR_BASE_LO
|
117 MSI_ADDR_DEST_ID(index_from_irqs(vmd
, irq
));
122 * We rely on MSI_FLAG_USE_DEF_CHIP_OPS to set the IRQ mask/unmask ops.
124 static void vmd_irq_enable(struct irq_data
*data
)
126 struct vmd_irq
*vmdirq
= data
->chip_data
;
129 raw_spin_lock_irqsave(&list_lock
, flags
);
130 WARN_ON(vmdirq
->enabled
);
131 list_add_tail_rcu(&vmdirq
->node
, &vmdirq
->irq
->irq_list
);
132 vmdirq
->enabled
= true;
133 raw_spin_unlock_irqrestore(&list_lock
, flags
);
135 data
->chip
->irq_unmask(data
);
138 static void vmd_irq_disable(struct irq_data
*data
)
140 struct vmd_irq
*vmdirq
= data
->chip_data
;
143 data
->chip
->irq_mask(data
);
145 raw_spin_lock_irqsave(&list_lock
, flags
);
146 if (vmdirq
->enabled
) {
147 list_del_rcu(&vmdirq
->node
);
148 vmdirq
->enabled
= false;
150 raw_spin_unlock_irqrestore(&list_lock
, flags
);
154 * XXX: Stubbed until we develop acceptable way to not create conflicts with
155 * other devices sharing the same vector.
157 static int vmd_irq_set_affinity(struct irq_data
*data
,
158 const struct cpumask
*dest
, bool force
)
163 static struct irq_chip vmd_msi_controller
= {
165 .irq_enable
= vmd_irq_enable
,
166 .irq_disable
= vmd_irq_disable
,
167 .irq_compose_msi_msg
= vmd_compose_msi_msg
,
168 .irq_set_affinity
= vmd_irq_set_affinity
,
171 static irq_hw_number_t
vmd_get_hwirq(struct msi_domain_info
*info
,
172 msi_alloc_info_t
*arg
)
178 * XXX: We can be even smarter selecting the best IRQ once we solve the
181 static struct vmd_irq_list
*vmd_next_irq(struct vmd_dev
*vmd
, struct msi_desc
*desc
)
186 if (!desc
->msi_attrib
.is_msix
|| vmd
->msix_count
== 1)
187 return &vmd
->irqs
[0];
189 raw_spin_lock_irqsave(&list_lock
, flags
);
190 for (i
= 1; i
< vmd
->msix_count
; i
++)
191 if (vmd
->irqs
[i
].count
< vmd
->irqs
[best
].count
)
193 vmd
->irqs
[best
].count
++;
194 raw_spin_unlock_irqrestore(&list_lock
, flags
);
196 return &vmd
->irqs
[best
];
199 static int vmd_msi_init(struct irq_domain
*domain
, struct msi_domain_info
*info
,
200 unsigned int virq
, irq_hw_number_t hwirq
,
201 msi_alloc_info_t
*arg
)
203 struct msi_desc
*desc
= arg
->desc
;
204 struct vmd_dev
*vmd
= vmd_from_bus(msi_desc_to_pci_dev(desc
)->bus
);
205 struct vmd_irq
*vmdirq
= kzalloc(sizeof(*vmdirq
), GFP_KERNEL
);
206 unsigned int index
, vector
;
211 INIT_LIST_HEAD(&vmdirq
->node
);
212 vmdirq
->irq
= vmd_next_irq(vmd
, desc
);
214 index
= index_from_irqs(vmd
, vmdirq
->irq
);
215 vector
= pci_irq_vector(vmd
->dev
, index
);
217 irq_domain_set_info(domain
, virq
, vector
, info
->chip
, vmdirq
,
218 handle_untracked_irq
, vmd
, NULL
);
222 static void vmd_msi_free(struct irq_domain
*domain
,
223 struct msi_domain_info
*info
, unsigned int virq
)
225 struct vmd_irq
*vmdirq
= irq_get_chip_data(virq
);
228 synchronize_srcu(&vmdirq
->irq
->srcu
);
230 /* XXX: Potential optimization to rebalance */
231 raw_spin_lock_irqsave(&list_lock
, flags
);
232 vmdirq
->irq
->count
--;
233 raw_spin_unlock_irqrestore(&list_lock
, flags
);
238 static int vmd_msi_prepare(struct irq_domain
*domain
, struct device
*dev
,
239 int nvec
, msi_alloc_info_t
*arg
)
241 struct pci_dev
*pdev
= to_pci_dev(dev
);
242 struct vmd_dev
*vmd
= vmd_from_bus(pdev
->bus
);
244 if (nvec
> vmd
->msix_count
)
245 return vmd
->msix_count
;
247 memset(arg
, 0, sizeof(*arg
));
251 static void vmd_set_desc(msi_alloc_info_t
*arg
, struct msi_desc
*desc
)
256 static struct msi_domain_ops vmd_msi_domain_ops
= {
257 .get_hwirq
= vmd_get_hwirq
,
258 .msi_init
= vmd_msi_init
,
259 .msi_free
= vmd_msi_free
,
260 .msi_prepare
= vmd_msi_prepare
,
261 .set_desc
= vmd_set_desc
,
264 static struct msi_domain_info vmd_msi_domain_info
= {
265 .flags
= MSI_FLAG_USE_DEF_DOM_OPS
| MSI_FLAG_USE_DEF_CHIP_OPS
|
267 .ops
= &vmd_msi_domain_ops
,
268 .chip
= &vmd_msi_controller
,
271 #ifdef CONFIG_X86_DEV_DMA_OPS
273 * VMD replaces the requester ID with its own. DMA mappings for devices in a
274 * VMD domain need to be mapped for the VMD, not the device requiring
277 static struct device
*to_vmd_dev(struct device
*dev
)
279 struct pci_dev
*pdev
= to_pci_dev(dev
);
280 struct vmd_dev
*vmd
= vmd_from_bus(pdev
->bus
);
282 return &vmd
->dev
->dev
;
285 static struct dma_map_ops
*vmd_dma_ops(struct device
*dev
)
287 return get_dma_ops(to_vmd_dev(dev
));
290 static void *vmd_alloc(struct device
*dev
, size_t size
, dma_addr_t
*addr
,
291 gfp_t flag
, unsigned long attrs
)
293 return vmd_dma_ops(dev
)->alloc(to_vmd_dev(dev
), size
, addr
, flag
,
297 static void vmd_free(struct device
*dev
, size_t size
, void *vaddr
,
298 dma_addr_t addr
, unsigned long attrs
)
300 return vmd_dma_ops(dev
)->free(to_vmd_dev(dev
), size
, vaddr
, addr
,
304 static int vmd_mmap(struct device
*dev
, struct vm_area_struct
*vma
,
305 void *cpu_addr
, dma_addr_t addr
, size_t size
,
308 return vmd_dma_ops(dev
)->mmap(to_vmd_dev(dev
), vma
, cpu_addr
, addr
,
312 static int vmd_get_sgtable(struct device
*dev
, struct sg_table
*sgt
,
313 void *cpu_addr
, dma_addr_t addr
, size_t size
,
316 return vmd_dma_ops(dev
)->get_sgtable(to_vmd_dev(dev
), sgt
, cpu_addr
,
320 static dma_addr_t
vmd_map_page(struct device
*dev
, struct page
*page
,
321 unsigned long offset
, size_t size
,
322 enum dma_data_direction dir
,
325 return vmd_dma_ops(dev
)->map_page(to_vmd_dev(dev
), page
, offset
, size
,
329 static void vmd_unmap_page(struct device
*dev
, dma_addr_t addr
, size_t size
,
330 enum dma_data_direction dir
, unsigned long attrs
)
332 vmd_dma_ops(dev
)->unmap_page(to_vmd_dev(dev
), addr
, size
, dir
, attrs
);
335 static int vmd_map_sg(struct device
*dev
, struct scatterlist
*sg
, int nents
,
336 enum dma_data_direction dir
, unsigned long attrs
)
338 return vmd_dma_ops(dev
)->map_sg(to_vmd_dev(dev
), sg
, nents
, dir
, attrs
);
341 static void vmd_unmap_sg(struct device
*dev
, struct scatterlist
*sg
, int nents
,
342 enum dma_data_direction dir
, unsigned long attrs
)
344 vmd_dma_ops(dev
)->unmap_sg(to_vmd_dev(dev
), sg
, nents
, dir
, attrs
);
347 static void vmd_sync_single_for_cpu(struct device
*dev
, dma_addr_t addr
,
348 size_t size
, enum dma_data_direction dir
)
350 vmd_dma_ops(dev
)->sync_single_for_cpu(to_vmd_dev(dev
), addr
, size
, dir
);
353 static void vmd_sync_single_for_device(struct device
*dev
, dma_addr_t addr
,
354 size_t size
, enum dma_data_direction dir
)
356 vmd_dma_ops(dev
)->sync_single_for_device(to_vmd_dev(dev
), addr
, size
,
360 static void vmd_sync_sg_for_cpu(struct device
*dev
, struct scatterlist
*sg
,
361 int nents
, enum dma_data_direction dir
)
363 vmd_dma_ops(dev
)->sync_sg_for_cpu(to_vmd_dev(dev
), sg
, nents
, dir
);
366 static void vmd_sync_sg_for_device(struct device
*dev
, struct scatterlist
*sg
,
367 int nents
, enum dma_data_direction dir
)
369 vmd_dma_ops(dev
)->sync_sg_for_device(to_vmd_dev(dev
), sg
, nents
, dir
);
372 static int vmd_mapping_error(struct device
*dev
, dma_addr_t addr
)
374 return vmd_dma_ops(dev
)->mapping_error(to_vmd_dev(dev
), addr
);
377 static int vmd_dma_supported(struct device
*dev
, u64 mask
)
379 return vmd_dma_ops(dev
)->dma_supported(to_vmd_dev(dev
), mask
);
382 #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK
383 static u64
vmd_get_required_mask(struct device
*dev
)
385 return vmd_dma_ops(dev
)->get_required_mask(to_vmd_dev(dev
));
389 static void vmd_teardown_dma_ops(struct vmd_dev
*vmd
)
391 struct dma_domain
*domain
= &vmd
->dma_domain
;
393 if (get_dma_ops(&vmd
->dev
->dev
))
394 del_dma_domain(domain
);
397 #define ASSIGN_VMD_DMA_OPS(source, dest, fn) \
400 dest->fn = vmd_##fn; \
403 static void vmd_setup_dma_ops(struct vmd_dev
*vmd
)
405 const struct dma_map_ops
*source
= get_dma_ops(&vmd
->dev
->dev
);
406 struct dma_map_ops
*dest
= &vmd
->dma_ops
;
407 struct dma_domain
*domain
= &vmd
->dma_domain
;
409 domain
->domain_nr
= vmd
->sysdata
.domain
;
410 domain
->dma_ops
= dest
;
414 ASSIGN_VMD_DMA_OPS(source
, dest
, alloc
);
415 ASSIGN_VMD_DMA_OPS(source
, dest
, free
);
416 ASSIGN_VMD_DMA_OPS(source
, dest
, mmap
);
417 ASSIGN_VMD_DMA_OPS(source
, dest
, get_sgtable
);
418 ASSIGN_VMD_DMA_OPS(source
, dest
, map_page
);
419 ASSIGN_VMD_DMA_OPS(source
, dest
, unmap_page
);
420 ASSIGN_VMD_DMA_OPS(source
, dest
, map_sg
);
421 ASSIGN_VMD_DMA_OPS(source
, dest
, unmap_sg
);
422 ASSIGN_VMD_DMA_OPS(source
, dest
, sync_single_for_cpu
);
423 ASSIGN_VMD_DMA_OPS(source
, dest
, sync_single_for_device
);
424 ASSIGN_VMD_DMA_OPS(source
, dest
, sync_sg_for_cpu
);
425 ASSIGN_VMD_DMA_OPS(source
, dest
, sync_sg_for_device
);
426 ASSIGN_VMD_DMA_OPS(source
, dest
, mapping_error
);
427 ASSIGN_VMD_DMA_OPS(source
, dest
, dma_supported
);
428 #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK
429 ASSIGN_VMD_DMA_OPS(source
, dest
, get_required_mask
);
431 add_dma_domain(domain
);
433 #undef ASSIGN_VMD_DMA_OPS
435 static void vmd_teardown_dma_ops(struct vmd_dev
*vmd
) {}
436 static void vmd_setup_dma_ops(struct vmd_dev
*vmd
) {}
439 static char __iomem
*vmd_cfg_addr(struct vmd_dev
*vmd
, struct pci_bus
*bus
,
440 unsigned int devfn
, int reg
, int len
)
442 char __iomem
*addr
= vmd
->cfgbar
+
443 (bus
->number
<< 20) + (devfn
<< 12) + reg
;
445 if ((addr
- vmd
->cfgbar
) + len
>=
446 resource_size(&vmd
->dev
->resource
[VMD_CFGBAR
]))
453 * CPU may deadlock if config space is not serialized on some versions of this
454 * hardware, so all config space access is done under a spinlock.
456 static int vmd_pci_read(struct pci_bus
*bus
, unsigned int devfn
, int reg
,
459 struct vmd_dev
*vmd
= vmd_from_bus(bus
);
460 char __iomem
*addr
= vmd_cfg_addr(vmd
, bus
, devfn
, reg
, len
);
467 spin_lock_irqsave(&vmd
->cfg_lock
, flags
);
470 *value
= readb(addr
);
473 *value
= readw(addr
);
476 *value
= readl(addr
);
482 spin_unlock_irqrestore(&vmd
->cfg_lock
, flags
);
487 * VMD h/w converts non-posted config writes to posted memory writes. The
488 * read-back in this function forces the completion so it returns only after
489 * the config space was written, as expected.
491 static int vmd_pci_write(struct pci_bus
*bus
, unsigned int devfn
, int reg
,
494 struct vmd_dev
*vmd
= vmd_from_bus(bus
);
495 char __iomem
*addr
= vmd_cfg_addr(vmd
, bus
, devfn
, reg
, len
);
502 spin_lock_irqsave(&vmd
->cfg_lock
, flags
);
520 spin_unlock_irqrestore(&vmd
->cfg_lock
, flags
);
524 static struct pci_ops vmd_ops
= {
525 .read
= vmd_pci_read
,
526 .write
= vmd_pci_write
,
529 static void vmd_attach_resources(struct vmd_dev
*vmd
)
531 vmd
->dev
->resource
[VMD_MEMBAR1
].child
= &vmd
->resources
[1];
532 vmd
->dev
->resource
[VMD_MEMBAR2
].child
= &vmd
->resources
[2];
535 static void vmd_detach_resources(struct vmd_dev
*vmd
)
537 vmd
->dev
->resource
[VMD_MEMBAR1
].child
= NULL
;
538 vmd
->dev
->resource
[VMD_MEMBAR2
].child
= NULL
;
542 * VMD domains start at 0x1000 to not clash with ACPI _SEG domains.
544 static int vmd_find_free_domain(void)
547 struct pci_bus
*bus
= NULL
;
549 while ((bus
= pci_find_next_bus(bus
)) != NULL
)
550 domain
= max_t(int, domain
, pci_domain_nr(bus
));
554 static int vmd_enable_domain(struct vmd_dev
*vmd
)
556 struct pci_sysdata
*sd
= &vmd
->sysdata
;
557 struct resource
*res
;
560 LIST_HEAD(resources
);
562 res
= &vmd
->dev
->resource
[VMD_CFGBAR
];
563 vmd
->resources
[0] = (struct resource
) {
564 .name
= "VMD CFGBAR",
566 .end
= (resource_size(res
) >> 20) - 1,
567 .flags
= IORESOURCE_BUS
| IORESOURCE_PCI_FIXED
,
571 * If the window is below 4GB, clear IORESOURCE_MEM_64 so we can
572 * put 32-bit resources in the window.
574 * There's no hardware reason why a 64-bit window *couldn't*
575 * contain a 32-bit resource, but pbus_size_mem() computes the
576 * bridge window size assuming a 64-bit window will contain no
577 * 32-bit resources. __pci_assign_resource() enforces that
578 * artificial restriction to make sure everything will fit.
580 * The only way we could use a 64-bit non-prefechable MEMBAR is
581 * if its address is <4GB so that we can convert it to a 32-bit
582 * resource. To be visible to the host OS, all VMD endpoints must
583 * be initially configured by platform BIOS, which includes setting
584 * up these resources. We can assume the device is configured
585 * according to the platform needs.
587 res
= &vmd
->dev
->resource
[VMD_MEMBAR1
];
588 upper_bits
= upper_32_bits(res
->end
);
589 flags
= res
->flags
& ~IORESOURCE_SIZEALIGN
;
591 flags
&= ~IORESOURCE_MEM_64
;
592 vmd
->resources
[1] = (struct resource
) {
593 .name
= "VMD MEMBAR1",
600 res
= &vmd
->dev
->resource
[VMD_MEMBAR2
];
601 upper_bits
= upper_32_bits(res
->end
);
602 flags
= res
->flags
& ~IORESOURCE_SIZEALIGN
;
604 flags
&= ~IORESOURCE_MEM_64
;
605 vmd
->resources
[2] = (struct resource
) {
606 .name
= "VMD MEMBAR2",
607 .start
= res
->start
+ 0x2000,
613 sd
->vmd_domain
= true;
614 sd
->domain
= vmd_find_free_domain();
618 sd
->node
= pcibus_to_node(vmd
->dev
->bus
);
620 vmd
->irq_domain
= pci_msi_create_irq_domain(NULL
, &vmd_msi_domain_info
,
622 if (!vmd
->irq_domain
)
625 pci_add_resource(&resources
, &vmd
->resources
[0]);
626 pci_add_resource(&resources
, &vmd
->resources
[1]);
627 pci_add_resource(&resources
, &vmd
->resources
[2]);
628 vmd
->bus
= pci_create_root_bus(&vmd
->dev
->dev
, 0, &vmd_ops
, sd
,
631 pci_free_resource_list(&resources
);
632 irq_domain_remove(vmd
->irq_domain
);
636 vmd_attach_resources(vmd
);
637 vmd_setup_dma_ops(vmd
);
638 dev_set_msi_domain(&vmd
->bus
->dev
, vmd
->irq_domain
);
639 pci_rescan_bus(vmd
->bus
);
641 WARN(sysfs_create_link(&vmd
->dev
->dev
.kobj
, &vmd
->bus
->dev
.kobj
,
642 "domain"), "Can't create symlink to domain\n");
646 static irqreturn_t
vmd_irq(int irq
, void *data
)
648 struct vmd_irq_list
*irqs
= data
;
649 struct vmd_irq
*vmdirq
;
652 idx
= srcu_read_lock(&irqs
->srcu
);
653 list_for_each_entry_rcu(vmdirq
, &irqs
->irq_list
, node
)
654 generic_handle_irq(vmdirq
->virq
);
655 srcu_read_unlock(&irqs
->srcu
, idx
);
660 static int vmd_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
665 if (resource_size(&dev
->resource
[VMD_CFGBAR
]) < (1 << 20))
668 vmd
= devm_kzalloc(&dev
->dev
, sizeof(*vmd
), GFP_KERNEL
);
673 err
= pcim_enable_device(dev
);
677 vmd
->cfgbar
= pcim_iomap(dev
, VMD_CFGBAR
, 0);
682 if (dma_set_mask_and_coherent(&dev
->dev
, DMA_BIT_MASK(64)) &&
683 dma_set_mask_and_coherent(&dev
->dev
, DMA_BIT_MASK(32)))
686 vmd
->msix_count
= pci_msix_vec_count(dev
);
687 if (vmd
->msix_count
< 0)
690 vmd
->msix_count
= pci_alloc_irq_vectors(dev
, 1, vmd
->msix_count
,
691 PCI_IRQ_MSIX
| PCI_IRQ_AFFINITY
);
692 if (vmd
->msix_count
< 0)
693 return vmd
->msix_count
;
695 vmd
->irqs
= devm_kcalloc(&dev
->dev
, vmd
->msix_count
, sizeof(*vmd
->irqs
),
700 for (i
= 0; i
< vmd
->msix_count
; i
++) {
701 err
= init_srcu_struct(&vmd
->irqs
[i
].srcu
);
705 INIT_LIST_HEAD(&vmd
->irqs
[i
].irq_list
);
706 err
= devm_request_irq(&dev
->dev
, pci_irq_vector(dev
, i
),
707 vmd_irq
, 0, "vmd", &vmd
->irqs
[i
]);
712 spin_lock_init(&vmd
->cfg_lock
);
713 pci_set_drvdata(dev
, vmd
);
714 err
= vmd_enable_domain(vmd
);
718 dev_info(&vmd
->dev
->dev
, "Bound to PCI domain %04x\n",
719 vmd
->sysdata
.domain
);
723 static void vmd_cleanup_srcu(struct vmd_dev
*vmd
)
727 for (i
= 0; i
< vmd
->msix_count
; i
++)
728 cleanup_srcu_struct(&vmd
->irqs
[i
].srcu
);
731 static void vmd_remove(struct pci_dev
*dev
)
733 struct vmd_dev
*vmd
= pci_get_drvdata(dev
);
735 vmd_detach_resources(vmd
);
736 vmd_cleanup_srcu(vmd
);
737 sysfs_remove_link(&vmd
->dev
->dev
.kobj
, "domain");
738 pci_stop_root_bus(vmd
->bus
);
739 pci_remove_root_bus(vmd
->bus
);
740 vmd_teardown_dma_ops(vmd
);
741 irq_domain_remove(vmd
->irq_domain
);
744 #ifdef CONFIG_PM_SLEEP
745 static int vmd_suspend(struct device
*dev
)
747 struct pci_dev
*pdev
= to_pci_dev(dev
);
749 pci_save_state(pdev
);
753 static int vmd_resume(struct device
*dev
)
755 struct pci_dev
*pdev
= to_pci_dev(dev
);
757 pci_restore_state(pdev
);
761 static SIMPLE_DEV_PM_OPS(vmd_dev_pm_ops
, vmd_suspend
, vmd_resume
);
763 static const struct pci_device_id vmd_ids
[] = {
764 {PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x201d),},
767 MODULE_DEVICE_TABLE(pci
, vmd_ids
);
769 static struct pci_driver vmd_drv
= {
773 .remove
= vmd_remove
,
775 .pm
= &vmd_dev_pm_ops
,
778 module_pci_driver(vmd_drv
);
780 MODULE_AUTHOR("Intel Corporation");
781 MODULE_LICENSE("GPL v2");
782 MODULE_VERSION("0.6");