2013-04-02 01:53:21

by Yijing Wang

[permalink] [raw]
Subject: [PATCH -v2] 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.

Signed-off-by: Yijing Wang <[email protected]>
---
drivers/vfio/pci/vfio_pci_config.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index aeb00fc..12a81f7 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -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;
--
1.7.1


2013-04-11 11:55:12

by Yijing Wang

[permalink] [raw]
Subject: Re: [PATCH -v2] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register

ping?

On 2013/4/2 9:52, Yijing Wang wrote:
> 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.
>
> Signed-off-by: Yijing Wang <[email protected]>
> ---
> drivers/vfio/pci/vfio_pci_config.c | 6 +-----
> 1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index aeb00fc..12a81f7 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -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;
>


--
Thanks!
Yijing

2013-04-15 15:11:31

by Alex Williamson

[permalink] [raw]
Subject: Re: [PATCH -v2] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register

On Tue, 2013-04-02 at 09:52 +0800, Yijing Wang wrote:
> 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.
>
> Signed-off-by: Yijing Wang <[email protected]>
> ---
> drivers/vfio/pci/vfio_pci_config.c | 6 +-----
> 1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index aeb00fc..12a81f7 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -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;

Applied. Thanks!

Alex