]> git.itanic.dy.fi Git - linux-stable/commitdiff
PCI/DPC: Use defined fields with DPC_CTL register
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 18 Oct 2023 11:32:52 +0000 (14:32 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 24 Oct 2023 15:54:04 +0000 (10:54 -0500)
Instead of using a literal to clear bits, add PCI_EXP_DPC_CTL_EN_MASK
and use the usual pattern to modify a bitfield.

While at it, rearrange RMW code more logically together.

Link: https://lore.kernel.org/r/20231018113254.17616-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pcie/dpc.c

index a5c259ada9eac1c0b24efcd6914b9858c7d9fc1a..0048a11bd11963165228bf664ed46a2b226581a6 100644 (file)
@@ -18,6 +18,9 @@
 #include "portdrv.h"
 #include "../pci.h"
 
+#define PCI_EXP_DPC_CTL_EN_MASK        (PCI_EXP_DPC_CTL_EN_FATAL | \
+                                PCI_EXP_DPC_CTL_EN_NONFATAL)
+
 static const char * const rp_pio_error_string[] = {
        "Configuration Request received UR Completion",  /* Bit Position 0  */
        "Configuration Request received CA Completion",  /* Bit Position 1  */
@@ -369,12 +372,13 @@ static int dpc_probe(struct pcie_device *dev)
        }
 
        pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CAP, &cap);
-       pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, &ctl);
 
-       ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN;
+       pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, &ctl);
+       ctl &= ~PCI_EXP_DPC_CTL_EN_MASK;
+       ctl |= PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN;
        pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl);
-       pci_info(pdev, "enabled with IRQ %d\n", dev->irq);
 
+       pci_info(pdev, "enabled with IRQ %d\n", dev->irq);
        pci_info(pdev, "error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
                 cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT),
                 FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP),