[dpdk-dev,v7,3/4] eal/linux: vfio: ignore mapping for ioport region

Message ID 1454853068-14621-4-git-send-email-sshukla@mvista.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Santosh Shukla Feb. 7, 2016, 1:51 p.m. UTC
  vfio_pci_mmap() try to map all pci bars. ioport region are not mapped in
vfio/kernel so ignore mmaping for ioport.

Signed-off-by: Santosh Shukla <sshukla@mvista.com>
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Anatoly Burakov Feb. 8, 2016, 9:15 a.m. UTC | #1
> vfio_pci_mmap() try to map all pci bars. ioport region are not mapped in
> vfio/kernel so ignore mmaping for ioport.
> 
> Signed-off-by: Santosh Shukla <sshukla@mvista.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index ffa2dd0..4832313 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -659,6 +659,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
>  	struct pci_map *maps;
>  	uint32_t msix_table_offset = 0;
>  	uint32_t msix_table_size = 0;
> +	uint32_t ioport_bar;
> 
>  	dev->intr_handle.fd = -1;
>  	dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; @@ -853,6
> +854,25 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
>  			return -1;
>  		}
> 
> +		/* chk for io port region */
> +		ret = pread64(vfio_dev_fd, &ioport_bar, sizeof(ioport_bar),
> +
> VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX)
> +			      + PCI_BASE_ADDRESS_0 + i*4);
> +
> +		if (ret != sizeof(ioport_bar)) {
> +			RTE_LOG(ERR, EAL,
> +				"Cannot read command (%x) from config
> space!\n",
> +				PCI_BASE_ADDRESS_0 + i*4);
> +			return -1;
> +		}
> +
> +		if (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) {
> +			RTE_LOG(INFO, EAL,
> +				"Ignore mapping IO port bar(%d) addr:
> %x\n",
> +				 i, ioport_bar);
> +			continue;
> +		}
> +
>  		/* skip non-mmapable BARs */
>  		if ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) == 0)
>  			continue;
> --
> 1.7.9.5

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Santosh Shukla Feb. 18, 2016, 5:26 a.m. UTC | #2
On Mon, Feb 8, 2016 at 2:45 PM, Burakov, Anatoly
<anatoly.burakov@intel.com> wrote:
>> vfio_pci_mmap() try to map all pci bars. ioport region are not mapped in
>> vfio/kernel so ignore mmaping for ioport.
>>
>> Signed-off-by: Santosh Shukla <sshukla@mvista.com>
>> ---
>>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> index ffa2dd0..4832313 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> @@ -659,6 +659,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
>>       struct pci_map *maps;
>>       uint32_t msix_table_offset = 0;
>>       uint32_t msix_table_size = 0;
>> +     uint32_t ioport_bar;
>>
>>       dev->intr_handle.fd = -1;
>>       dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; @@ -853,6
>> +854,25 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
>>                       return -1;
>>               }
>>
>> +             /* chk for io port region */
>> +             ret = pread64(vfio_dev_fd, &ioport_bar, sizeof(ioport_bar),
>> +
>> VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX)
>> +                           + PCI_BASE_ADDRESS_0 + i*4);
>> +
>> +             if (ret != sizeof(ioport_bar)) {
>> +                     RTE_LOG(ERR, EAL,
>> +                             "Cannot read command (%x) from config
>> space!\n",
>> +                             PCI_BASE_ADDRESS_0 + i*4);
>> +                     return -1;
>> +             }
>> +
>> +             if (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) {
>> +                     RTE_LOG(INFO, EAL,
>> +                             "Ignore mapping IO port bar(%d) addr:
>> %x\n",
>> +                              i, ioport_bar);
>> +                     continue;
>> +             }
>> +
>>               /* skip non-mmapable BARs */
>>               if ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) == 0)
>>                       continue;
>> --
>> 1.7.9.5
>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Merge request for this one too..
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index ffa2dd0..4832313 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -659,6 +659,7 @@  pci_vfio_map_resource(struct rte_pci_device *dev)
 	struct pci_map *maps;
 	uint32_t msix_table_offset = 0;
 	uint32_t msix_table_size = 0;
+	uint32_t ioport_bar;
 
 	dev->intr_handle.fd = -1;
 	dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
@@ -853,6 +854,25 @@  pci_vfio_map_resource(struct rte_pci_device *dev)
 			return -1;
 		}
 
+		/* chk for io port region */
+		ret = pread64(vfio_dev_fd, &ioport_bar, sizeof(ioport_bar),
+			      VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX)
+			      + PCI_BASE_ADDRESS_0 + i*4);
+
+		if (ret != sizeof(ioport_bar)) {
+			RTE_LOG(ERR, EAL,
+				"Cannot read command (%x) from config space!\n",
+				PCI_BASE_ADDRESS_0 + i*4);
+			return -1;
+		}
+
+		if (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) {
+			RTE_LOG(INFO, EAL,
+				"Ignore mapping IO port bar(%d) addr: %x\n",
+				 i, ioport_bar);
+			continue;
+		}
+
 		/* skip non-mmapable BARs */
 		if ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) == 0)
 			continue;