* [PATCH] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register
@ 2013-03-27 9:05 Yijing Wang
2013-04-01 15:16 ` Alex Williamson
0 siblings, 1 reply; 3+ messages in thread
From: Yijing Wang @ 2013-03-27 9:05 UTC (permalink / raw)
To: Alex Williamson
Cc: Bjorn Helgaas, linux-pci, Arnd Bergmann, linux-kernel, Hanjun Guo,
jiang.liu, Yijing Wang
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.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
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..afc6ca4 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 ((pdev->pcie_flags_reg & PCI_EXP_FLAGS_VERS) == 1)
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
else
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register
2013-03-27 9:05 [PATCH] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register Yijing Wang
@ 2013-04-01 15:16 ` Alex Williamson
2013-04-02 1:47 ` Yijing Wang
0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2013-04-01 15:16 UTC (permalink / raw)
To: Yijing Wang
Cc: Bjorn Helgaas, linux-pci, Arnd Bergmann, linux-kernel, Hanjun Guo,
jiang.liu
On Wed, 2013-03-27 at 17:05 +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_flags_reg instead of another access PCI-E Capabilities Register.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
> 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..afc6ca4 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 ((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
> return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
> else
> return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register
2013-04-01 15:16 ` Alex Williamson
@ 2013-04-02 1:47 ` Yijing Wang
0 siblings, 0 replies; 3+ messages in thread
From: Yijing Wang @ 2013-04-02 1:47 UTC (permalink / raw)
To: Alex Williamson
Cc: Bjorn Helgaas, linux-pci, Arnd Bergmann, linux-kernel, Hanjun Guo,
jiang.liu
>> @@ -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)
>
> It looks like we should be using pcie_caps_reg(pdev) here instead of
> directly accessing pcie_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
>
> Alex
>
>> return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
>> else
>> return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
>
>
>
>
> .
>
--
Thanks!
Yijing
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-02 1:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-27 9:05 [PATCH] PCI/VFIO: use pcie_flags_reg instead of access PCI-E Capabilities Register Yijing Wang
2013-04-01 15:16 ` Alex Williamson
2013-04-02 1:47 ` Yijing Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).