From: Amey Narkhede <ameynarkhede03@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: alex.williamson@redhat.com,
Raphael Norwitz <raphael.norwitz@nutanix.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
kw@linux.com, Shanker Donthineni <sdonthineni@nvidia.com>,
Sinan Kaya <okaya@kernel.org>, Len Brown <lenb@kernel.org>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Amey Narkhede <ameynarkhede03@gmail.com>
Subject: [PATCH v16 1/9] PCI: Cache PCIe FLR capability
Date: Tue, 17 Aug 2021 23:39:29 +0530 [thread overview]
Message-ID: <20210817180937.3123-2-ameynarkhede03@gmail.com> (raw)
In-Reply-To: <20210817180937.3123-1-ameynarkhede03@gmail.com>
Add a new member called devcap in struct pci_dev for caching the device
capabilities to avoid reading PCI_EXP_DEVCAP multiple times.
Refactor pcie_has_flr() to use cached device capabilities.
Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
drivers/pci/pci.c | 6 ++----
drivers/pci/probe.c | 5 +++--
include/linux/pci.h | 1 +
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 452351025..1fafd05ca 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -31,6 +31,7 @@
#include <linux/vmalloc.h>
#include <asm/dma.h>
#include <linux/aer.h>
+#include <linux/bitfield.h>
#include "pci.h"
DEFINE_MUTEX(pci_slot_mutex);
@@ -4620,13 +4621,10 @@ EXPORT_SYMBOL(pci_wait_for_pending_transaction);
*/
bool pcie_has_flr(struct pci_dev *dev)
{
- u32 cap;
-
if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET)
return false;
- pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
- return cap & PCI_EXP_DEVCAP_FLR;
+ return FIELD_GET(PCI_EXP_DEVCAP_FLR, dev->devcap) == 1;
}
EXPORT_SYMBOL_GPL(pcie_has_flr);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3a62d09b8..df3f9db6e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -19,6 +19,7 @@
#include <linux/hypervisor.h>
#include <linux/irqdomain.h>
#include <linux/pm_runtime.h>
+#include <linux/bitfield.h>
#include "pci.h"
#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
@@ -1497,8 +1498,8 @@ void set_pcie_port_type(struct pci_dev *pdev)
pdev->pcie_cap = pos;
pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16);
pdev->pcie_flags_reg = reg16;
- pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16);
- pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD;
+ pci_read_config_dword(pdev, pos + PCI_EXP_DEVCAP, &pdev->devcap);
+ pdev->pcie_mpss = FIELD_GET(PCI_EXP_DEVCAP_PAYLOAD, pdev->devcap);
parent = pci_upstream_bridge(pdev);
if (!parent)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c20211e59..697b1f085 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -333,6 +333,7 @@ struct pci_dev {
struct rcec_ea *rcec_ea; /* RCEC cached endpoint association */
struct pci_dev *rcec; /* Associated RCEC device */
#endif
+ u32 devcap; /* PCIe device capabilities */
u8 pcie_cap; /* PCIe capability offset */
u8 msi_cap; /* MSI capability offset */
u8 msix_cap; /* MSI-X capability offset */
--
2.32.0
next prev parent reply other threads:[~2021-08-17 18:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 18:09 [PATCH v16 0/9] PCI: Expose and manage PCI device reset Amey Narkhede
2021-08-17 18:09 ` Amey Narkhede [this message]
2021-08-17 18:09 ` [PATCH v16 2/9] PCI: Add pcie_reset_flr to follow calling convention of other reset methods Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 3/9] PCI: Add new array for keeping track of ordering of " Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 4/9] PCI: Remove reset_fn field from pci_dev Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 5/9] PCI: Allow userspace to query and set device reset mechanism Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 6/9] PCI: Define a function to set ACPI_COMPANION in pci_dev Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 7/9] PCI: Setup ACPI fwnode early and at the same time with OF Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 8/9] PCI: Add support for ACPI _RST reset method Amey Narkhede
2021-08-17 18:09 ` [PATCH v16 9/9] PCI: Change the type of probe argument in reset functions Amey Narkhede
2021-08-18 22:46 ` [PATCH v16 0/9] PCI: Expose and manage PCI device reset Bjorn Helgaas
2021-08-19 6:01 ` Amey Narkhede
-- strict thread matches above, loose matches on Subject: below --
2021-08-17 18:04 Amey Narkhede
2021-08-17 18:04 ` [PATCH v16 1/9] PCI: Cache PCIe FLR capability Amey Narkhede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210817180937.3123-2-ameynarkhede03@gmail.com \
--to=ameynarkhede03@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=okaya@kernel.org \
--cc=raphael.norwitz@nutanix.com \
--cc=rjw@rjwysocki.net \
--cc=sdonthineni@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).