scsi: lpfc: Add support for optional PLDV handling
authorJames Smart <jsmart2021@gmail.com>
Mon, 27 Sep 2021 18:35:18 +0000 (11:35 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 29 Sep 2021 03:28:07 +0000 (23:28 -0400)
At adapter attachment or SLI port initialization, read the SLIPORT_STATUS
register to check for pldv_enable. If found, the driver will perform a PCIe
configuration space write when attaching to an SLI port instance that is an
LPe32000 series adapter.

Link: https://lore.kernel.org/r/20210927183518.22130-1-jsmart2021@gmail.com
Co-developed-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_hw4.h
drivers/scsi/lpfc/lpfc_init.c

index 79a4872c2edb062b3d8927189f25d6c1a41277c3..143b73f713336b4677fe829708d3c126b88764c5 100644 (file)
@@ -673,6 +673,10 @@ struct lpfc_register {
 #define lpfc_sliport_status_rdy_SHIFT  23
 #define lpfc_sliport_status_rdy_MASK   0x1
 #define lpfc_sliport_status_rdy_WORD   word0
+#define lpfc_sliport_status_pldv_SHIFT 0
+#define lpfc_sliport_status_pldv_MASK  0x1
+#define lpfc_sliport_status_pldv_WORD  word0
+#define CFG_PLD                                0x3C
 #define MAX_IF_TYPE_2_RESETS           6
 
 #define LPFC_CTL_PORT_CTL_OFFSET       0x408
index 0be8c8ab3d94008993c406fa65ceb1619d14e861..b9d3c848ac8895a70b86a03271fcf69e66029bdb 100644 (file)
@@ -68,6 +68,7 @@
 static enum cpuhp_state lpfc_cpuhp_state;
 /* Used when mapping IRQ vectors in a driver centric manner */
 static uint32_t lpfc_present_cpu;
+static bool lpfc_pldv_detect;
 
 static void __lpfc_cpuhp_remove(struct lpfc_hba *phba);
 static void lpfc_cpuhp_remove(struct lpfc_hba *phba);
@@ -9359,7 +9360,15 @@ lpfc_sli4_post_status_check(struct lpfc_hba *phba)
                                        phba->work_status[0],
                                        phba->work_status[1]);
                                port_error = -ENODEV;
+                               break;
                        }
+
+                       if (lpfc_pldv_detect &&
+                           bf_get(lpfc_sli_intf_sli_family,
+                                  &phba->sli4_hba.sli_intf) ==
+                                       LPFC_SLI_INTF_FAMILY_G6)
+                               pci_write_config_byte(phba->pcidev,
+                                                     LPFC_SLI_INTF, CFG_PLD);
                        break;
                case LPFC_SLI_INTF_IF_TYPE_1:
                default:
@@ -11567,6 +11576,9 @@ wait:
                        goto out;
                }
 
+               if (bf_get(lpfc_sliport_status_pldv, &reg_data))
+                       lpfc_pldv_detect = true;
+
                if (!port_reset) {
                        /*
                         * Reset the port now
@@ -15560,6 +15572,8 @@ lpfc_init(void)
        /* Initialize in case vector mapping is needed */
        lpfc_present_cpu = num_present_cpus();
 
+       lpfc_pldv_detect = false;
+
        error = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
                                        "lpfc/sli4:online",
                                        lpfc_cpu_online, lpfc_cpu_offline);