From patchwork Thu Nov 5 04:46:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 7557311 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 133C19F36A for ; Thu, 5 Nov 2015 04:47:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D9192085C for ; Thu, 5 Nov 2015 04:47:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59ED22085B for ; Thu, 5 Nov 2015 04:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965531AbbKEEri (ORCPT ); Wed, 4 Nov 2015 23:47:38 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58228 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965287AbbKEEqu (ORCPT ); Wed, 4 Nov 2015 23:46:50 -0500 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 8A86813FDB9; Thu, 5 Nov 2015 04:46:49 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 7931313FDBE; Thu, 5 Nov 2015 04:46:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from drakthul.qualcomm.com (rrcs-67-52-130-30.west.biz.rr.com [67.52.130.30]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 28ADB13FDAD; Thu, 5 Nov 2015 04:46:48 +0000 (UTC) From: Sinan Kaya To: linux-scsi@vger.kernel.org, timur@codeaurora.org, cov@codeaurora.org, jcm@redhat.com Cc: Sinan Kaya , Nagalakshmi Nandigama , Praveen Krishnamoorthy , Sreekanth Reddy , Abhijit Mahajan , "James E.J. Bottomley" , MPT-FusionLinux.pdl@avagotech.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] scsi: mpt3sas: try 64 bit DMA when 32 bit DMA fails Date: Wed, 4 Nov 2015 23:46:27 -0500 Message-Id: <1446698789-19308-2-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1446698789-19308-1-git-send-email-okaya@codeaurora.org> References: <1446698789-19308-1-git-send-email-okaya@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP 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 Current code gives up when 32 bit DMA is not supported. This patch tests 64 bit support before bailing out in such conditions. Signed-off-by: Sinan Kaya --- drivers/scsi/mpt3sas/mpt3sas_base.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index d4f1dcd..6dc391c 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -1535,9 +1535,29 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev) ioc->base_add_sg_single = &_base_add_sg_single_32; ioc->sge_size = sizeof(Mpi2SGESimple32_t); ioc->dma_mask = 32; - } else + } else { + /* Try 64 bit, 32 bit failed */ + consistent_dma_mask = DMA_BIT_MASK(64); + if (sizeof(dma_addr_t) > 4) { + const uint64_t required_mask = + dma_get_required_mask(&pdev->dev); + int consistent_mask = + pci_set_consistent_dma_mask(pdev, + consistent_dma_mask); + + if ((required_mask > DMA_BIT_MASK(32)) && + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && + !consistent_mask) { + ioc->base_add_sg_single = + &_base_add_sg_single_64; + ioc->sge_size = sizeof(Mpi2SGESimple64_t); + ioc->dma_mask = 64; + goto out; + } + } return -ENODEV; + } out: si_meminfo(&s); pr_info(MPT3SAS_FMT