mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 16:49:22 +00:00
AMD IOMMU: save pci_dev instead of devid
We need the pci_dev later anyways to enable MSI for the IOMMU hardware. So remove the devid pointing to the BDF and replace it with the pci_dev structure where the IOMMU is implemented. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
ee893c24ed
commit
3eaf28a1cd
2 changed files with 19 additions and 11 deletions
|
@ -242,9 +242,12 @@ static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
|
||||||
/* Function to enable the hardware */
|
/* Function to enable the hardware */
|
||||||
void __init iommu_enable(struct amd_iommu *iommu)
|
void __init iommu_enable(struct amd_iommu *iommu)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "AMD IOMMU: Enabling IOMMU at ");
|
printk(KERN_INFO "AMD IOMMU: Enabling IOMMU "
|
||||||
print_devid(iommu->devid, 0);
|
"at %02x:%02x.%x cap 0x%hx\n",
|
||||||
printk(" cap 0x%hx\n", iommu->cap_ptr);
|
iommu->dev->bus->number,
|
||||||
|
PCI_SLOT(iommu->dev->devfn),
|
||||||
|
PCI_FUNC(iommu->dev->devfn),
|
||||||
|
iommu->cap_ptr);
|
||||||
|
|
||||||
iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
|
iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
|
||||||
}
|
}
|
||||||
|
@ -511,15 +514,14 @@ static void __init set_device_exclusion_range(u16 devid, struct ivmd_header *m)
|
||||||
*/
|
*/
|
||||||
static void __init init_iommu_from_pci(struct amd_iommu *iommu)
|
static void __init init_iommu_from_pci(struct amd_iommu *iommu)
|
||||||
{
|
{
|
||||||
int bus = PCI_BUS(iommu->devid);
|
|
||||||
int dev = PCI_SLOT(iommu->devid);
|
|
||||||
int fn = PCI_FUNC(iommu->devid);
|
|
||||||
int cap_ptr = iommu->cap_ptr;
|
int cap_ptr = iommu->cap_ptr;
|
||||||
u32 range;
|
u32 range;
|
||||||
|
|
||||||
iommu->cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_CAP_HDR_OFFSET);
|
pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
|
||||||
|
&iommu->cap);
|
||||||
|
pci_read_config_dword(iommu->dev, cap_ptr + MMIO_RANGE_OFFSET,
|
||||||
|
&range);
|
||||||
|
|
||||||
range = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET);
|
|
||||||
iommu->first_device = calc_devid(MMIO_GET_BUS(range),
|
iommu->first_device = calc_devid(MMIO_GET_BUS(range),
|
||||||
MMIO_GET_FD(range));
|
MMIO_GET_FD(range));
|
||||||
iommu->last_device = calc_devid(MMIO_GET_BUS(range),
|
iommu->last_device = calc_devid(MMIO_GET_BUS(range),
|
||||||
|
@ -674,7 +676,10 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
|
||||||
/*
|
/*
|
||||||
* Copy data from ACPI table entry to the iommu struct
|
* Copy data from ACPI table entry to the iommu struct
|
||||||
*/
|
*/
|
||||||
iommu->devid = h->devid;
|
iommu->dev = pci_get_bus_and_slot(PCI_BUS(h->devid), h->devid & 0xff);
|
||||||
|
if (!iommu->dev)
|
||||||
|
return 1;
|
||||||
|
|
||||||
iommu->cap_ptr = h->cap_ptr;
|
iommu->cap_ptr = h->cap_ptr;
|
||||||
iommu->pci_seg = h->pci_seg;
|
iommu->pci_seg = h->pci_seg;
|
||||||
iommu->mmio_phys = h->mmio_phys;
|
iommu->mmio_phys = h->mmio_phys;
|
||||||
|
@ -695,6 +700,8 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
|
||||||
init_iommu_from_acpi(iommu, h);
|
init_iommu_from_acpi(iommu, h);
|
||||||
init_iommu_devices(iommu);
|
init_iommu_devices(iommu);
|
||||||
|
|
||||||
|
pci_enable_device(iommu->dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,8 +215,9 @@ struct amd_iommu {
|
||||||
/* locks the accesses to the hardware */
|
/* locks the accesses to the hardware */
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
|
||||||
/* device id of this IOMMU */
|
/* Pointer to PCI device of this IOMMU */
|
||||||
u16 devid;
|
struct pci_dev *dev;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Capability pointer. There could be more than one IOMMU per PCI
|
* Capability pointer. There could be more than one IOMMU per PCI
|
||||||
* device function if there are more than one AMD IOMMU capability
|
* device function if there are more than one AMD IOMMU capability
|
||||||
|
|
Loading…
Reference in a new issue