函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:arch\x86\kernel\amd_nb.c Create Date:2022-07-27 09:43:01
首页 Copyright©Brick

449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
void amd_flush_garts(void)
{
    int flushed, i;
    unsigned long flags;
    static DEFINE_SPINLOCK(gart_lock);
 
    if (!amd_nb_has_feature(AMD_NB_GART))
        return;
 
    /*
     * Avoid races between AGP and IOMMU. In theory it's not needed
     * but I'm not sure if the hardware won't lose flush requests
     * when another is pending. This whole thing is so expensive anyways
     * that it doesn't matter to serialize more. -AK
     */
    spin_lock_irqsave(&gart_lock, flags);
    flushed = 0;
    for (i = 0; i < amd_northbridges.num; i++) {
        pci_write_config_dword(node_to_amd_nb(i)->misc, 0x9c,
                       flush_words[i] | 1);
        flushed++;
    }
    for (i = 0; i < amd_northbridges.num; i++) {
        u32 w;
        /* Make sure the hardware actually executed the flush*/
        for (;;) {
            pci_read_config_dword(node_to_amd_nb(i)->misc,
                          0x9c, &w);
            if (!(w & 1))
                break;
            cpu_relax();
        }
    }
    spin_unlock_irqrestore(&gart_lock, flags);
    if (!flushed)
        pr_notice("nothing to flush?\n");
}