scsi: lpfc: Memory allocation error during driver start-up on power8
authorJames Smart <jsmart2021@gmail.com>
Mon, 5 Mar 2018 20:04:08 +0000 (12:04 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Mar 2018 01:55:24 +0000 (21:55 -0400)
The driver fails to allocate command buffers in the routine
lpfc_new_scsi_buf_s4

There is an inconsistency between lpfc_mem_alloc(), where the
phba->lpfc_sg_dma_buf_pool is created, and lpfc_new_scsi_buf_s4(),
when we allocate a buffer from the pool and check the alignment.  The
alignment should be on a page boundary, based on LPFC_SLI3_BG_ENABLED in
sli3_options, for both cases.

Fix by explicitly tracking sli4 vs sli3 and BG options.  The result is that
phba->cfg_sg_dma_buf_size is now set correctly for SLI-4.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c

index 46f6d97d21d6e44e02e032929a09905dd81e2fe2..2ac1d21c553f14e0853964507d2336fcf1319b3a 100644 (file)
@@ -6344,6 +6344,10 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
                phba->cfg_poll = 0;
        else
                phba->cfg_poll = lpfc_poll;
+
+       if (phba->cfg_enable_bg)
+               phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
+
        lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp);
 
        lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type);
index 17551540a1c51d527d2f842db03c99b3e8423f97..7887468c71b4db440f288879115533219d34ae23 100644 (file)
@@ -5912,7 +5912,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
         * Since lpfc_sg_seg_cnt is module param, the sg_dma_buf_size
         * used to create the sg_dma_buf_pool must be calculated.
         */
-       if (phba->cfg_enable_bg) {
+       if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
                /*
                 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd,
                 * the FCP rsp, and a SGE. Sice we have no control
index fb81e8a8fb1ceaa9c2104d61ec2d7b08f315c861..050f04418f5fb2f4f95c5b5f655a256733dc80a8 100644 (file)
@@ -837,8 +837,13 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc)
                 * 4K Page alignment is CRITICAL to BlockGuard, double check
                 * to be sure.
                 */
-               if (phba->cfg_enable_bg  && (((unsigned long)(psb->data) &
+               if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
+                   (((unsigned long)(psb->data) &
                    (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) {
+                       lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
+                                       "3369 Memory alignment error "
+                                       "addr=%lx\n",
+                                       (unsigned long)psb->data);
                        dma_pool_free(phba->lpfc_sg_dma_buf_pool,
                                      psb->data, psb->dma_handle);
                        kfree(psb);
index 1a9083adef1f0ff36ecf36055bda110bd3b65df3..cb17e2b2be8187458c07d2656709dde8aad43b6e 100644 (file)
@@ -4993,13 +4993,14 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
                phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get;
                phba->port_gp = phba->mbox->us.s3_pgp.port;
 
-               if (phba->cfg_enable_bg) {
-                       if (pmb->u.mb.un.varCfgPort.gbg)
-                               phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
-                       else
+               if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
+                       if (pmb->u.mb.un.varCfgPort.gbg == 0) {
+                               phba->cfg_enable_bg = 0;
+                               phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED;
                                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
                                                "0443 Adapter did not grant "
                                                "BlockGuard\n");
+                       }
                }
        } else {
                phba->hbq_get = NULL;
@@ -6991,12 +6992,12 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
         * then turn off the global config parameters to disable the
         * feature in the driver.  This is not a fatal error.
         */
-       phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED;
-       if (phba->cfg_enable_bg) {
-               if (bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))
-                       phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
-               else
+       if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
+               if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) {
+                       phba->cfg_enable_bg = 0;
+                       phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED;
                        ftr_rsp++;
+               }
        }
 
        if (phba->max_vpi && phba->cfg_enable_npiv &&