~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to arch/x86/kernel/amd_iommu_init.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
 
138
138
/* IOMMUs have a non-present cache? */
139
139
bool amd_iommu_np_cache __read_mostly;
 
140
bool amd_iommu_iotlb_sup __read_mostly = true;
140
141
 
141
142
/*
142
143
 * The ACPI table parsing functions set this variable on an error
180
181
static u32 alias_table_size;    /* size of the alias table */
181
182
static u32 rlookup_table_size;  /* size if the rlookup table */
182
183
 
 
184
/*
 
185
 * This function flushes all internal caches of
 
186
 * the IOMMU used by this driver.
 
187
 */
 
188
extern void iommu_flush_all_caches(struct amd_iommu *iommu);
 
189
 
183
190
static inline void update_last_devid(u16 devid)
184
191
{
185
192
        if (devid > amd_iommu_last_bdf)
293
300
/* Function to enable the hardware */
294
301
static void iommu_enable(struct amd_iommu *iommu)
295
302
{
296
 
        printk(KERN_INFO "AMD-Vi: Enabling IOMMU at %s cap 0x%hx\n",
 
303
        static const char * const feat_str[] = {
 
304
                "PreF", "PPR", "X2APIC", "NX", "GT", "[5]",
 
305
                "IA", "GA", "HE", "PC", NULL
 
306
        };
 
307
        int i;
 
308
 
 
309
        printk(KERN_INFO "AMD-Vi: Enabling IOMMU at %s cap 0x%hx",
297
310
               dev_name(&iommu->dev->dev), iommu->cap_ptr);
298
311
 
 
312
        if (iommu->cap & (1 << IOMMU_CAP_EFR)) {
 
313
                printk(KERN_CONT " extended features: ");
 
314
                for (i = 0; feat_str[i]; ++i)
 
315
                        if (iommu_feature(iommu, (1ULL << i)))
 
316
                                printk(KERN_CONT " %s", feat_str[i]);
 
317
        }
 
318
        printk(KERN_CONT "\n");
 
319
 
299
320
        iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
300
321
}
301
322
 
651
672
static void __init init_iommu_from_pci(struct amd_iommu *iommu)
652
673
{
653
674
        int cap_ptr = iommu->cap_ptr;
654
 
        u32 range, misc;
 
675
        u32 range, misc, low, high;
655
676
        int i, j;
656
677
 
657
678
        pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
667
688
                                        MMIO_GET_LD(range));
668
689
        iommu->evt_msi_num = MMIO_MSI_NUM(misc);
669
690
 
 
691
        if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB)))
 
692
                amd_iommu_iotlb_sup = false;
 
693
 
 
694
        /* read extended feature bits */
 
695
        low  = readl(iommu->mmio_base + MMIO_EXT_FEATURES);
 
696
        high = readl(iommu->mmio_base + MMIO_EXT_FEATURES + 4);
 
697
 
 
698
        iommu->features = ((u64)high << 32) | low;
 
699
 
670
700
        if (!is_rd890_iommu(iommu->dev))
671
701
                return;
672
702
 
701
731
{
702
732
        u8 *p = (u8 *)h;
703
733
        u8 *end = p, flags = 0;
704
 
        u16 dev_i, devid = 0, devid_start = 0, devid_to = 0;
705
 
        u32 ext_flags = 0;
 
734
        u16 devid = 0, devid_start = 0, devid_to = 0;
 
735
        u32 dev_i, ext_flags = 0;
706
736
        bool alias = false;
707
737
        struct ivhd_entry *e;
708
738
 
857
887
/* Initializes the device->iommu mapping for the driver */
858
888
static int __init init_iommu_devices(struct amd_iommu *iommu)
859
889
{
860
 
        u16 i;
 
890
        u32 i;
861
891
 
862
892
        for (i = iommu->first_device; i <= iommu->last_device; ++i)
863
893
                set_iommu_for_device(iommu, i);
1004
1034
        if (pci_enable_msi(iommu->dev))
1005
1035
                return 1;
1006
1036
 
1007
 
        r = request_irq(iommu->dev->irq, amd_iommu_int_handler,
1008
 
                        IRQF_SAMPLE_RANDOM,
1009
 
                        "AMD-Vi",
1010
 
                        NULL);
 
1037
        r = request_threaded_irq(iommu->dev->irq,
 
1038
                                 amd_iommu_int_handler,
 
1039
                                 amd_iommu_int_thread,
 
1040
                                 0, "AMD-Vi",
 
1041
                                 iommu->dev);
1011
1042
 
1012
1043
        if (r) {
1013
1044
                pci_disable_msi(iommu->dev);
1146
1177
 */
1147
1178
static void init_device_table(void)
1148
1179
{
1149
 
        u16 devid;
 
1180
        u32 devid;
1150
1181
 
1151
1182
        for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
1152
1183
                set_dev_entry_bit(devid, DEV_ENTRY_VALID);
1244
1275
                iommu_set_exclusion_range(iommu);
1245
1276
                iommu_init_msi(iommu);
1246
1277
                iommu_enable(iommu);
 
1278
                iommu_flush_all_caches(iommu);
1247
1279
        }
1248
1280
}
1249
1281
 
1274
1306
         * we have to flush after the IOMMUs are enabled because a
1275
1307
         * disabled IOMMU will never execute the commands we send
1276
1308
         */
1277
 
        amd_iommu_flush_all_devices();
1278
 
        amd_iommu_flush_all_domains();
 
1309
        for_each_iommu(iommu)
 
1310
                iommu_flush_all_caches(iommu);
1279
1311
}
1280
1312
 
1281
1313
static int amd_iommu_suspend(void)