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_caps_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 ((pcie_caps_reg (pdev) &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
ping?
Quoted 29 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_caps_reg()instead 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 +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 ((pcie_caps_reg (pdev) &PCI_EXP_FLAGS_VERS ) ==1 )return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 ;else return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 ;
Signature · 2 lines
Thanks! Yijing
Alex Williamson
AppliedQuoted 18 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_caps_reg()instead 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
-1@@ -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);
drivers/vfio/pci/vfio_pci_config.c static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) · line 1025
Quoted 10 lines
drivers/vfio/pci/vfio_pci_config.c +1
-4-if (ret) -return pcibios_err_to_errno (ret); - vdev->extended_caps = true; -if ((word &PCI_EXP_FLAGS_VERS ) ==1 ) +if ((pcie_caps_reg (pdev) &PCI_EXP_FLAGS_VERS ) ==1 )return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 ;else return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 ;
Applied. Thanks!
Alex