PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register
Subsystems (2)
PATCH 1/1 PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register
Currently, we use pcie_flags_reg to cache PCI-E Capabilities Register, because PCI-E Capabilities Register bits are almost read-only. This patch use pcie_flags_reg instead of another access PCI-E Capabilities Register.
--- drivers/vfio/pci/vfio_pci_config.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
drivers/vfio/pci/vfio_pci_config.c +1 -5
@@ -1017,13 +1017,9 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)return byte;case PCI_CAP_ID_EXP :/* length based on version */ - ret =pci_read_config_word (pdev, pos +PCI_EXP_FLAGS , &word); -if (ret) -return pcibios_err_to_errno (ret); - vdev->extended_caps = true; -if ((word &PCI_EXP_FLAGS_VERS ) ==1 ) +if ((pdev->pcie_flags_reg &PCI_EXP_FLAGS_VERS ) ==1 )return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 ;else return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 ;
Signature · 1 line
1.7.1
Quoted 15 lines · Yijing Wang
Currently, we use
pcie_flags_regto cache PCI-E Capabilities Register, because PCI-E Capabilities Register bits are almost read-only. This patch usepcie_flags_reginstead of another access PCI-E Capabilities Register.Signed-off-by Yijing Wang <[email protected]>--- drivers/vfio/pci/vfio_pci_config.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)drivers/vfio/pci/vfio_pci_config.c +0
-0@@ -1017,13 +1017,9 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)return byte;
drivers/vfio/pci/vfio_pci_config.c static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) · line 1022
Quoted 10 lines
drivers/vfio/pci/vfio_pci_config.c +1
-5case PCI_CAP_ID_EXP :/* length based on version */ - ret =pci_read_config_word (pdev, pos +PCI_EXP_FLAGS , &word); -if (ret) -return pcibios_err_to_errno (ret); - vdev->extended_caps = true; -if ((word &PCI_EXP_FLAGS_VERS ) ==1 ) +if ((pdev->pcie_flags_reg &PCI_EXP_FLAGS_VERS ) ==1 )
It looks like we should be using pcie_caps_reg(pdev) here instead of directly accessing pcie_flags_reg. Thanks,
Alex
Quoted 3 lines
drivers/vfio/pci/vfio_pci_config.c +0
-0return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 ; else return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
Quoted 10 lines
Quoted 10 lines
drivers/vfio/pci/vfio_pci_config.c +0
-4@@ -1017,13 +1017,9 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)return byte;case PCI_CAP_ID_EXP :/* length based on version */ - ret =pci_read_config_word (pdev, pos +PCI_EXP_FLAGS , &word); -if (ret) -return pcibios_err_to_errno (ret); - vdev->extended_caps = true;
Quoted 5 lines
drivers/vfio/pci/vfio_pci_config.c static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) · line 1022
Quoted 2 lines
drivers/vfio/pci/vfio_pci_config.c +1
-1-if ((word &PCI_EXP_FLAGS_VERS ) ==1 ) +if ((pdev->pcie_flags_reg &PCI_EXP_FLAGS_VERS ) ==1 )It looks like we should be using
pcie_caps_reg(pdev)here instead of directly accessingpcie_flags_reg. Thanks,
That's right, I forget Myron Stowe introduced the PCIe Cap accessor function pcie_caps_reg(). I will resend the updated patch.
Thanks!
Yijing
Quoted 12 lines
Alex
drivers/vfio/pci/vfio_pci_config.c static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) · line 1025
Quoted 3 lines
drivers/vfio/pci/vfio_pci_config.c +0
-0return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 ; else return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;.
Signature · 2 lines
Thanks! Yijing