From patchwork Mon Feb 11 15:05:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ewan Milne X-Patchwork-Id: 10806101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0104517E0 for ; Mon, 11 Feb 2019 15:20:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43DC2AA36 for ; Mon, 11 Feb 2019 15:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A2B2AAF9; Mon, 11 Feb 2019 15:20:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87C352AA36 for ; Mon, 11 Feb 2019 15:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390710AbfBKPUp (ORCPT ); Mon, 11 Feb 2019 10:20:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53441 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390909AbfBKPFE (ORCPT ); Mon, 11 Feb 2019 10:05:04 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3EC0356F5; Mon, 11 Feb 2019 15:05:03 +0000 (UTC) Received: from emilne.bos.redhat.com (unknown [10.18.25.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC7210E81C0; Mon, 11 Feb 2019 15:05:02 +0000 (UTC) From: "Ewan D. Milne" To: linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org Cc: stable@vger.kernel.org, james.smart@broadcom.com, dick.kennedy@broadcom.com, martin.petersen@oracle.com, jejb@linux.ibm.com Subject: [PATCH] scsi: lpfc: fix calls to dma_set_mask_and_coherent() Date: Mon, 11 Feb 2019 10:05:02 -0500 Message-Id: <20190211150502.9999-1-emilne@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 11 Feb 2019 15:05:04 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The change to use dma_set_mask_and_coherent() incorrectly made a second call with the 32 bit DMA mask value when the call with the 64 bit DMA mask value succeeded. This resulted in NVMe/FC connections failing due to corrupted data buffers, and various other SCSI/FCP I/O errors. Fixes: f30e1bfd6154 ("scsi: lpfc: use dma_set_mask_and_coherent") Cc: Suggested-by: Don Dutile Signed-off-by: Ewan D. Milne Signed-off-by:  James Smart  --- drivers/scsi/lpfc/lpfc_init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index bede11e..60c178d 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -7367,9 +7367,9 @@ struct lpfc_rpi_hdr * return error; /* Set the device DMA mask size */ - if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || - dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) - return error; + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0) + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) + return error; /* Get the bus address of Bar0 and Bar2 and the number of bytes * required by each mapping. @@ -9745,9 +9745,9 @@ struct lpfc_cq_event * return error; /* Set the device DMA mask size */ - if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || - dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) - return error; + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0) + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) + return error; /* * The BARs and register set definitions and offset locations are