免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: epegasus
打印 上一主题 下一主题

还是不理解IOMMU、北桥、PCI的MMIO和ioremap [复制链接]

论坛徽章:
0
41 [报告]
发表于 2008-04-09 20:46 |只看该作者
原帖由 epegasus 于 2008-4-9 16:53 发表

哪些芯片是北桥的啊?
Processors
Motherboard
Chipsets
Desktop
Notebook
Mobile Internet Devices (MIDs)
Server and workstation
Intel Graphics
Communications
Embedded
Fl ...

印象中Intel管北桥叫MCH

论坛徽章:
0
42 [报告]
发表于 2008-04-10 23:21 |只看该作者
原帖由 crspo 于 2008-4-7 20:40 发表

目前的Xen已经为在HVM中使用PV driver预留了接口,也就是说在HVM中可以使用PV驱动程序,
可以参考:
http://www.nabble.com/Release-0. ... ows-td16368906.html
我的意思并非说要 ...

HVM domain中很早以前就可以使用pv driver了
有了iommu,就不需要pv driver了啊
当然现实的情况还是会pv driver和iommu混合使用,比如可以将网卡asign给guest domain, 磁盘还是使用pv driver

论坛徽章:
0
43 [报告]
发表于 2008-04-15 10:39 |只看该作者

回复 #11 zx_wing 的帖子

小弟在这个地方有疑问:
      在pci系统初始化时候,这个地方的pdev指向的pci设备功能的区间0的resource结构就被挂在了pci系统的资源树上了。这里调用request_mem_region(),试着把pdev的区间0的resource结构挂在iomem_resource的children上。这种尝试似乎应该会发生pdev的区间0和iomem_resource的children链上的某个区间的冲突,从而不会执行下面的ioremap().小弟在这里一直困惑不解。

论坛徽章:
0
44 [报告]
发表于 2008-04-15 22:07 |只看该作者
原帖由 ahhhhwang 于 2008-4-15 10:39 发表
小弟在这个地方有疑问:
      在pci系统初始化时候,这个地方的pdev指向的pci设备功能的区间0的resource结构就被挂在了pci系统的资源树上了。这里调用request_mem_region(),试着把pdev的区间0的resource结构 ...

pci初始化的时候会为每个设备的bar0注册到resource树里吗?我对PCI不熟悉,在什么地方注册的,兄弟把代码的路径贴出来看看

论坛徽章:
0
45 [报告]
发表于 2008-04-15 23:49 |只看该作者
将全部6个bar注册到resource树,但是并没有记IORESOURCE_BUSY

论坛徽章:
0
46 [报告]
发表于 2008-04-16 10:15 |只看该作者

回复 #44 zx_wing 的帖子

挂到资源树上的代码:
static void __init pcibios_allocate_resources(int pass)
{
        struct pci_dev *dev;
        int idx, disabled;
        u16 command;
        struct resource *r, *pr;

        pci_for_each_dev(dev) {
                pci_read_config_word(dev, PCI_COMMAND, &command);
                for(idx = 0; idx < 6; idx++) {
                        r = &dev->resource[idx];
                        if (r->parent)                /* Already allocated */
                                continue;
                        if (!r->start)                /* Address not assigned at all */
                                continue;
                        if (r->flags & IORESOURCE_IO)
                                disabled = !(command & PCI_COMMAND_IO);
                        else
                                disabled = !(command & PCI_COMMAND_MEMORY);
                        if (pass == disabled) {
                                DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
                                    r->start, r->end, r->flags, disabled, pass);
                                pr = pci_find_parent_resource(dev, r);
                                if (!pr || request_resource(pr, r) < 0) {
                                        printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, dev->slot_name);
                                        /* We'll assign a new address later */
                                        r->end -= r->start;
                                        r->start = 0;
                                }
                        }
                }
                if (!pass) {
                        r = &dev->resource[PCI_ROM_RESOURCE];
                        if (r->flags & PCI_ROM_ADDRESS_ENABLE) {
                                /* Turn the ROM off, leave the resource region, but keep it unregistered. */
                                u32 reg;
                                DBG("PCI: Switching off ROM of %s\n", dev->slot_name);
                                r->flags &= ~PCI_ROM_ADDRESS_ENABLE;
                                pci_read_config_dword(dev, dev->rom_base_reg, &reg);
                                pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE);
                        }
                }
        }
}

论坛徽章:
0
47 [报告]
发表于 2008-04-16 14:02 |只看该作者
PCI初始化时,确实注册了这些resource,但这并没有什么问题。

在enable_pci_device的时候,会遍历这些resource,找到一个(“冲突”) && (非IORESOURCE_BUSY)的resource,记IORESOURCE_BUSY。

论坛徽章:
0
48 [报告]
发表于 2008-04-16 16:58 |只看该作者

to ahhhhwang

我认为不会冲突。
因为request_mem_region()(request_region())是以iomem_resource(ioport_resource)这两个全局resource为根分别建立的resource树。我认为kernel这样做是方便管理IO port和MMIO资源。
而pcibios_allocate_resources是以pci_root_buses链表中,总线的resource变量为根建立的resource树。它和上面两者本身就不是一个东西。故不会发生冲突。
可以认为这里有3个独立的resource树,分别是iomem_resource、ioport_resource和bus->resource,它们是独立的,故向其中一个树注册资源不会到其它树里去查找是否冲突。

个人意见,供你参考

论坛徽章:
0
49 [报告]
发表于 2008-04-16 20:01 |只看该作者

回复 #48 zx_wing 的帖子

加入是单主总线的话,pci_root_buses链中的唯一一个总线的resource就只有ioport_resource和iomem_resource:
struct pci_bus * __devinit  pci_alloc_primary_bus(int bus)
{
        struct pci_bus *b;

        if (pci_bus_exists(&pci_root_buses, bus)) {
                /* If we already got to this bus through a different bridge, ignore it */
                DBG("PCI: Bus %02x already known\n", bus);
                return NULL;
        }

        b = pci_alloc_bus();
        list_add_tail(&b->node, &pci_root_buses);

        b->number = b->secondary = bus;
        b->resource[0] = &ioport_resource;
        b->resource[1] = &iomem_resource;
        return b;
}

所以这个时候应该是只有两个独立的资源树。

论坛徽章:
0
50 [报告]
发表于 2008-04-16 20:02 |只看该作者

回复 #48 zx_wing 的帖子

如果是单主总线的话,pci_root_buses链中的唯一一个总线的resource就只有ioport_resource和iomem_resource:
struct pci_bus * __devinit  pci_alloc_primary_bus(int bus)
{
        struct pci_bus *b;

        if (pci_bus_exists(&pci_root_buses, bus)) {
                /* If we already got to this bus through a different bridge, ignore it */
                DBG("PCI: Bus %02x already known\n", bus);
                return NULL;
        }

        b = pci_alloc_bus();
        list_add_tail(&b->node, &pci_root_buses);

        b->number = b->secondary = bus;
        b->resource[0] = &ioport_resource;
        b->resource[1] = &iomem_resource;
        return b;
}

所以这个时候应该是只有两个独立的资源树。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP