]>
Commit | Line | Data |
---|---|---|
6194356d SL |
1 | From c681bf711459e12cc5f0a38c2024452ef5dfee57 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Wed, 18 Oct 2023 14:32:51 +0300 | |
4 | Subject: PCI/DPC: Use FIELD_GET() | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: Bjorn Helgaas <bhelgaas@google.com> | |
10 | ||
11 | [ Upstream commit 9a9eec4765737b9b2a8d6ae03de6480a5f12dd5c ] | |
12 | ||
13 | Use FIELD_GET() to remove dependencies on the field position, i.e., the | |
14 | shift value. No functional change intended. | |
15 | ||
16 | Link: https://lore.kernel.org/r/20231018113254.17616-5-ilpo.jarvinen@linux.intel.com | |
17 | Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | |
18 | Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> | |
19 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
20 | --- | |
baf248c1 GKH |
21 | drivers/pci/pcie/dpc.c | 5 +++-- |
22 | drivers/pci/quirks.c | 2 +- | |
23 | include/uapi/linux/pci_regs.h | 1 + | |
6194356d SL |
24 | 3 files changed, 5 insertions(+), 3 deletions(-) |
25 | ||
6194356d SL |
26 | --- a/drivers/pci/pcie/dpc.c |
27 | +++ b/drivers/pci/pcie/dpc.c | |
28 | @@ -9,6 +9,7 @@ | |
29 | #define dev_fmt(fmt) "DPC: " fmt | |
30 | ||
31 | #include <linux/aer.h> | |
32 | +#include <linux/bitfield.h> | |
33 | #include <linux/delay.h> | |
34 | #include <linux/interrupt.h> | |
35 | #include <linux/init.h> | |
baf248c1 | 36 | @@ -202,7 +203,7 @@ static void dpc_process_rp_pio_error(str |
6194356d SL |
37 | |
38 | /* Get First Error Pointer */ | |
39 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &dpc_status); | |
40 | - first_error = (dpc_status & 0x1f00) >> 8; | |
41 | + first_error = FIELD_GET(PCI_EXP_DPC_RP_PIO_FEP, dpc_status); | |
42 | ||
43 | for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { | |
44 | if ((status & ~mask) & (1 << i)) | |
45 | @@ -338,7 +339,7 @@ void pci_dpc_init(struct pci_dev *pdev) | |
46 | /* Quirks may set dpc_rp_log_size if device or firmware is buggy */ | |
47 | if (!pdev->dpc_rp_log_size) { | |
48 | pdev->dpc_rp_log_size = | |
49 | - (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; | |
50 | + FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, cap); | |
51 | if (pdev->dpc_rp_log_size < 4 || pdev->dpc_rp_log_size > 9) { | |
52 | pci_err(pdev, "RP PIO log size %u is invalid\n", | |
53 | pdev->dpc_rp_log_size); | |
6194356d SL |
54 | --- a/drivers/pci/quirks.c |
55 | +++ b/drivers/pci/quirks.c | |
baf248c1 | 56 | @@ -6198,7 +6198,7 @@ static void dpc_log_size(struct pci_dev |
6194356d SL |
57 | if (!(val & PCI_EXP_DPC_CAP_RP_EXT)) |
58 | return; | |
59 | ||
60 | - if (!((val & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8)) { | |
61 | + if (FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, val) == 0) { | |
62 | pci_info(dev, "Overriding RP PIO Log Size to 4\n"); | |
63 | dev->dpc_rp_log_size = 4; | |
64 | } | |
6194356d SL |
65 | --- a/include/uapi/linux/pci_regs.h |
66 | +++ b/include/uapi/linux/pci_regs.h | |
baf248c1 | 67 | @@ -1045,6 +1045,7 @@ |
6194356d SL |
68 | #define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */ |
69 | #define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */ | |
70 | #define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */ | |
71 | +#define PCI_EXP_DPC_RP_PIO_FEP 0x1f00 /* RP PIO First Err Ptr */ | |
72 | ||
73 | #define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */ | |
74 |