From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Turton Subject: [PATCH] Make MSI-X work with 64-bit BARs Date: Wed, 14 May 2008 14:09:33 +0100 Message-ID: <482AE48D.4040402@solarflare.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030802070105030302090803" Return-path: 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 List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------030802070105030302090803 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit The code for working out the base address of a 64-bit BAR currently puts the two halves together in the wrong order and leaves the type bits in the resulting value. It also treats PCI_BASE_ADDRESS_MEM_TYPE_64 as an flag rather than an enumeration value. This patch fixes these issues. Signed-off-by: Neil Turton --------------030802070105030302090803 Content-Type: text/plain; name="msix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="msix.patch" diff -r 810d8c3ac992 xen/arch/x86/msi.c --- a/xen/arch/x86/msi.c Thu May 08 16:58:33 2008 +0100 +++ b/xen/arch/x86/msi.c Wed May 14 13:44:34 2008 +0100 @@ -521,17 +521,20 @@ static u64 pci_resource_start(struct pci static u64 pci_resource_start(struct pci_dev *dev, u8 bar_index) { u64 bar_base; + u32 reg_val; u8 bus = dev->bus; u8 slot = PCI_SLOT(dev->devfn); u8 func = PCI_FUNC(dev->devfn); - bar_base = pci_conf_read32(bus, slot, func, - PCI_BASE_ADDRESS_0 + 4 * bar_index); - if ( bar_base & PCI_BASE_ADDRESS_MEM_TYPE_64 ) - { - bar_base <<= 32; - bar_base += pci_conf_read32(bus, slot, func, - PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1)); + reg_val = pci_conf_read32(bus, slot, func, + PCI_BASE_ADDRESS_0 + 4 * bar_index); + bar_base = reg_val & PCI_BASE_ADDRESS_MEM_MASK; + if ( ( reg_val & PCI_BASE_ADDRESS_MEM_TYPE_MASK ) == + PCI_BASE_ADDRESS_MEM_TYPE_64 ) + { + reg_val = pci_conf_read32(bus, slot, func, + PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1)); + bar_base |= ((u64)reg_val) << 32; } return bar_base; --------------030802070105030302090803 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------030802070105030302090803--