diff mbox

[1/3] pci: Track whether a PCI device is a virtual function

Message ID 20170817060446.1340-1-ruscur@russell.cc
State Accepted
Headers show

Commit Message

Russell Currey Aug. 17, 2017, 6:04 a.m. UTC
This can be checked from config space, but we will need to know this when
restoring the PCI topology, and it is not always safe to access config
space during this period.

Signed-off-by: Russell Currey <ruscur@russell.cc>
---
 core/pci-iov.c | 1 +
 core/pci.c     | 1 +
 include/pci.h  | 1 +
 3 files changed, 3 insertions(+)

Comments

Andrew Donnellan Aug. 17, 2017, 6:12 a.m. UTC | #1
On 17/08/17 16:04, Russell Currey wrote:
> This can be checked from config space, but we will need to know this when
> restoring the PCI topology, and it is not always safe to access config
> space during this period.
> 
> Signed-off-by: Russell Currey <ruscur@russell.cc>

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
>   core/pci-iov.c | 1 +
>   core/pci.c     | 1 +
>   include/pci.h  | 1 +
>   3 files changed, 3 insertions(+)
> 
> diff --git a/core/pci-iov.c b/core/pci-iov.c
> index 9d75b378..06fc4c6f 100644
> --- a/core/pci-iov.c
> +++ b/core/pci-iov.c
> @@ -175,6 +175,7 @@ static void pci_iov_init_VF(struct pci_device *pd, struct pci_device *vf)
>   {
>   	vf->is_bridge		= false;
>   	vf->is_multifunction	= false;
> +	vf->is_vf		= true;
>   	vf->dev_type		= PCIE_TYPE_ENDPOINT;
>   	vf->scan_map		= -1;
>   	vf->vdid		= pd->vdid;
> diff --git a/core/pci.c b/core/pci.c
> index 4296180a..32767db5 100644
> --- a/core/pci.c
> +++ b/core/pci.c
> @@ -273,6 +273,7 @@ static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren
>   	}
>   	pd->is_multifunction = !!(htype & 0x80);
>   	pd->is_bridge = (htype & 0x7f) != 0;
> +	pd->is_vf = false;
>   	pd->scan_map = 0xffffffff; /* Default */
>   	pd->primary_bus = (bdfn >> 8);
>   
> diff --git a/include/pci.h b/include/pci.h
> index 54a62fd1..884ce622 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -65,6 +65,7 @@ struct pci_device {
>   	uint16_t		bdfn;
>   	bool			is_bridge;
>   	bool			is_multifunction;
> +	bool			is_vf;
>   	uint8_t			dev_type; /* PCIE */
>   	uint8_t			primary_bus;
>   	uint8_t			secondary_bus;
>
Stewart Smith Aug. 21, 2017, 5:46 a.m. UTC | #2
Russell Currey <ruscur@russell.cc> writes:
> This can be checked from config space, but we will need to know this when
> restoring the PCI topology, and it is not always safe to access config
> space during this period.
>
> Signed-off-by: Russell Currey <ruscur@russell.cc>

Series merged to master as of f5d90498d52cc128b90f65ce410dfb42943ba004
diff mbox

Patch

diff --git a/core/pci-iov.c b/core/pci-iov.c
index 9d75b378..06fc4c6f 100644
--- a/core/pci-iov.c
+++ b/core/pci-iov.c
@@ -175,6 +175,7 @@  static void pci_iov_init_VF(struct pci_device *pd, struct pci_device *vf)
 {
 	vf->is_bridge		= false;
 	vf->is_multifunction	= false;
+	vf->is_vf		= true;
 	vf->dev_type		= PCIE_TYPE_ENDPOINT;
 	vf->scan_map		= -1;
 	vf->vdid		= pd->vdid;
diff --git a/core/pci.c b/core/pci.c
index 4296180a..32767db5 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -273,6 +273,7 @@  static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren
 	}
 	pd->is_multifunction = !!(htype & 0x80);
 	pd->is_bridge = (htype & 0x7f) != 0;
+	pd->is_vf = false;
 	pd->scan_map = 0xffffffff; /* Default */
 	pd->primary_bus = (bdfn >> 8);
 
diff --git a/include/pci.h b/include/pci.h
index 54a62fd1..884ce622 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -65,6 +65,7 @@  struct pci_device {
 	uint16_t		bdfn;
 	bool			is_bridge;
 	bool			is_multifunction;
+	bool			is_vf;
 	uint8_t			dev_type; /* PCIE */
 	uint8_t			primary_bus;
 	uint8_t			secondary_bus;