From: Lukas Hejtmanek Subject: Re: InfiniBand device in Xen Date: Tue, 26 Jun 2007 13:43:19 +0200 Message-ID: <20070626114319.GL3867@ics.muni.cz> References: <20070625134020.GH3867@ics.muni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <20070625134020.GH3867@ics.muni.cz> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Mon, Jun 25, 2007 at 03:40:20PM +0200, Lukas Hejtmanek wrote: > I'm trying to get working infiniband device in Xen. I have Xen v3 with = 2.6.18 > kernel. I export PCI device from Dom0 into DomU. I've enabled permisive= device > in Dom0. >=20 > Do you have any advices what should I try? The device running in Dom0 w= orks as > expected. The problem is in DomU with exported PCI device. >=20 > It seems that the iomapped adrea returns all ones instead of reasonable= values. I have found that this code is problematic in DomU. In Dom0, it works ok. After the reset, the device respondes so it continues on the good label, = but it=20 seems that PCI config is not restored as it should be. hca_header =3D kmalloc(256, GFP_KERNEL); if (!hca_header) { err =3D -ENOMEM; mthca_err(mdev, "Couldn't allocate memory to save HCA " "PCI header, aborting.\n"); goto out; } for (i =3D 0; i < 64; ++i) { if (i =3D=3D 22 || i =3D=3D 23) continue; if (pci_read_config_dword(mdev->pdev, i * 4, hca_header + i)) { err =3D -ENODEV; mthca_err(mdev, "Couldn't save HCA " "PCI header, aborting.\n"); goto out; } } /* actually hit reset */ { void __iomem *reset =3D ioremap(pci_resource_start(mdev->pdev, 0) + MTHCA_RESET_OFFSET, 4); if (!reset) { err =3D -ENOMEM; mthca_err(mdev, "Couldn't map HCA reset register, " "aborting.\n"); goto out; } writel(MTHCA_RESET_VALUE, reset); iounmap(reset); } /* Docs say to wait one second before accessing device */ msleep(1000); /* Now wait for PCI device to start responding again */ { u32 v; int c =3D 0; for (c =3D 0; c < 100; ++c) { if (pci_read_config_dword(bridge ? bridge : mdev->pdev, 0, &v)) = { err =3D -ENODEV; mthca_err(mdev, "Couldn't access HCA after reset,= " "aborting.\n"); goto out; } if (v !=3D 0xffffffff) goto good; msleep(100); } err =3D -ENODEV; mthca_err(mdev, "PCI device did not come back after reset, " "aborting.\n"); } good: devctl =3D hca_header[(hca_pcie_cap + PCI_EXP_DEVCTL) / 4]; if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_DEVCTL, devc= tl)) { err =3D -ENODEV; mthca_err(mdev, "Couldn't restore HCA PCI Express " "Device Control register, aborting.\n"); goto out; } linkctl =3D hca_header[(hca_pcie_cap + PCI_EXP_LNKCTL) / 4]; if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_LNKCTL, link= ctl)) { err =3D -ENODEV; mthca_err(mdev, "Couldn't restore HCA PCI Express " "Link control register, aborting.\n"); goto out; } for (i =3D 0; i < 16; ++i) { if (i * 4 =3D=3D PCI_COMMAND) continue; if (pci_write_config_dword(mdev->pdev, i * 4, hca_header[i])) { err =3D -ENODEV; mthca_err(mdev, "Couldn't restore HCA reg %x, " "aborting.\n", i); goto out; } } if (pci_write_config_dword(mdev->pdev, PCI_COMMAND, hca_header[PCI_COMMAN= D / 4])) { err =3D -ENODEV; mthca_err(mdev, "Couldn't restore HCA COMMAND, " "aborting.\n"); goto out; } --=20 Luk=E1=B9 Hejtm=E1nek