From: Keir Fraser Subject: Re: [PATCH] pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument Date: Wed, 21 Oct 2009 08:19:23 +0100 Message-ID: References: <45c43ef50910201712qce79e09lbaa15167f2a4c28f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <45c43ef50910201712qce79e09lbaa15167f2a4c28f@mail.gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Bruce Edge , "xen-devel@lists.xensource.com" Cc: Ian Jackson List-Id: xen-devel@lists.xenproject.org If you don't cc Ian Jackson, the tree maintainer, the patch may get missed. -- Keir On 21/10/2009 01:12, "Bruce Edge" wrote: > I submitted this patch last week and did'nt see any feedback or indicatio= n as > to why it would not be accepted. > This is a confirmed tested fix that is required for pci passthorugh with > msi-x. >=20 > If there is something wrong with the format or the contents please let me= know > so that I can fix and resubmit. >=20 > Thanks in advance. >=20 > -Bruce >=20 > Force msi-x init mmap to a page boundary or mmap fails with. > =A0 =A0pt_msix_init: Error: Can't map physical MSI-X table: Invalid argument >=20 > Signed-off-by: Bruce Edge > >=20 > --- ./tools/ioemu-remote/hw/pass-through.h.orig 2009-10-15 > 10:22:17.000000000 -0700 > +++ ./tools/ioemu-remote/hw/pass-through.h =A0 =A0 =A02009-10-15 > 11:08:58.000000000 -0700 > @@ -193,6 +193,7 @@ > =A0 =A0int mmio_index; > =A0 =A0void *phys_iomem_base; > =A0 =A0struct msix_entry_info msix_entry[0]; > + =A0 =A0 =A0 uint32_t table_offset_adjust; =A0 /* page align mmap */ > =A0}; >=20 > =A0struct pt_pm_info { >=20 >=20 > --- ./tools/ioemu-remote/hw/pt-msi.c.orig =A0 =A0 =A0 2009-10-13 > 11:54:11.000000000 -0700 > +++ ./tools/ioemu-remote/hw/pt-msi.c =A0 =A02009-10-15 10:29:50.000000000 -07= 00 > @@ -542,6 +542,7 @@ > =A0 =A0int i, total_entries, table_off, bar_index; > =A0 =A0struct pci_dev *pd =3D dev->pci_dev; > =A0 =A0int fd; > + =A0 =A0int err; >=20 > =A0 =A0id =3D pci_read_byte(pd, pos + PCI_CAP_LIST_ID); >=20 > @@ -584,9 +585,15 @@ > =A0 =A0 =A0 =A0PT_LOG("Error: Can't open /dev/mem: %s\n", strerror(errno)); > =A0 =A0 =A0 =A0goto error_out; > =A0 =A0} > - =A0 =A0dev->msix->phys_iomem_base =3D mmap(0, total_entries * 16, > + =A0 =A0PT_LOG("table_off =3D %llx, total_entries =3D %d\n",table_off,total_entr= ies); > + =A0 =A0dev->msix->table_offset_adjust =3D table_off & 0x0fff; > + =A0 =A0dev->msix->phys_iomem_base =3D mmap(0, total_entries * 16 + > dev->msix->table_offset_adjust, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PROT_WRITE | PROT_READ, MAP_SHARED | MAP_LOCKED= , > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fd, dev->msix->table_base + table_off); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fd, dev->msix->table_base + table_off - > dev->msix->table_offset_adjust); > + =A0 =A0dev->msix->phys_iomem_base =3D (void *)((char *)dev->msix->phys_iomem_= base > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev->msix->table_offset_adjust); > + =A0 =A0err =3D errno; > + =A0 =A0PT_LOG("errno =3D %d\n",err); > =A0 =A0if ( dev->msix->phys_iomem_base =3D=3D MAP_FAILED ) > =A0 =A0{ > =A0 =A0 =A0 =A0PT_LOG("Error: Can't map physical MSI-X table: %s\n", > strerror(errno)); > @@ -612,7 +619,8 @@ > =A0 =A0{ > =A0 =A0 =A0 =A0PT_LOG("unmapping physical MSI-X table from %lx\n", > =A0 =A0 =A0 =A0 =A0 (unsigned long)dev->msix->phys_iomem_base); > - =A0 =A0 =A0 =A0munmap(dev->msix->phys_iomem_base, dev->msix->total_entries * 16= ); > + =A0 =A0 =A0 =A0munmap(dev->msix->phys_iomem_base, dev->msix->total_entries * 16= + > + =A0 =A0 =A0 =A0 =A0 dev->msix->table_offset_adjust); > =A0 =A0} >=20 > =A0 =A0free(dev->msix); >=20 >=20 >=20