pci: pci_set_ops() always assigns to the kernel The IOMMU sets an identity mapping for the kernel, by default, for all devices. In essence, this is assigned to the kernel. If someone wants a different state, like unassigned, then do it manually. e.g. pci_set_ops(pdev); ... pci_device_unassign(pdev, NULL); Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/arch/x86/pci.c b/kern/arch/x86/pci.c index 7cc797a..36f9671 100644 --- a/kern/arch/x86/pci.c +++ b/kern/arch/x86/pci.c
@@ -850,11 +850,10 @@ } } -void pci_set_ops(struct pci_device *pdev, struct pci_ops *ops, int pci_state) +void pci_set_ops(struct pci_device *pdev, struct pci_ops *ops) { pdev->_ops = ops; - assert(pdev->state == DEV_STATE_UNKNOWN); - pdev->state = pci_state; + pdev->state = DEV_STATE_ASSIGNED_KERNEL; } static void __pci_device_assign_check(struct pci_device *pdev)
diff --git a/kern/arch/x86/pci.h b/kern/arch/x86/pci.h index 60e0d65..bd51935 100644 --- a/kern/arch/x86/pci.h +++ b/kern/arch/x86/pci.h
@@ -317,7 +317,7 @@ int pci_set_cacheline_size(struct pci_device *dev); int pci_set_mwi(struct pci_device *dev); void pci_clear_mwi(struct pci_device *dev); -void pci_set_ops(struct pci_device *pdev, struct pci_ops *ops, int pci_state); +void pci_set_ops(struct pci_device *pdev, struct pci_ops *ops); void pci_device_assign(struct pci_device *pdev, struct proc *proc); void pci_device_unassign_known(struct pci_device *pdev, struct proc *proc); void pci_device_unassign(struct pci_device *pdev, struct proc *proc);
diff --git a/kern/drivers/dma/ioat/init.c b/kern/drivers/dma/ioat/init.c index 1ab1a5f..5c6622c 100644 --- a/kern/drivers/dma/ioat/init.c +++ b/kern/drivers/dma/ioat/init.c
@@ -1596,8 +1596,7 @@ if (p->ven_id != PCI_VENDOR_ID_INTEL) continue; if (ioat_pci_init(p)) - pci_set_ops(p, &ioat_pci_ops, - DEV_STATE_ASSIGNED_KERNEL); + pci_set_ops(p, &ioat_pci_ops); } } /* The 'arch_initcall' setup functions run at level 2. */