From patchwork Wed Jul 15 04:49:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 6791831 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 2CA429F380 for ; Wed, 15 Jul 2015 04:50:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AEE2206B5 for ; Wed, 15 Jul 2015 04:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EF3520698 for ; Wed, 15 Jul 2015 04:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbbGOEum (ORCPT ); Wed, 15 Jul 2015 00:50:42 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:34146 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750946AbbGOEul (ORCPT ); Wed, 15 Jul 2015 00:50:41 -0400 Received: by pdbep18 with SMTP id ep18so18416373pdb.1 for ; Tue, 14 Jul 2015 21:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=avagotech.com; s=google; h=from:to:cc:subject:date:message-id; bh=JpRqBcJrsXt7nXahn3GvaB0CKDcqolJtsBAOW4vMZHk=; b=jlSBd0w57ohwxEd2i25NEhTti2XbLqobfyUo6lYySi89eQqbvLUq/Rn/uFRzLdg2el 5wfsLua4WQIuqk2lW/TSQFv8DRGoiuPnus0uyPXGAaAzUPXzGA3ooOmOVSFnw2RtL7nC MaR4qM2IOxp+Xf83xAZahC/ZWmfDAltuk9zfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JpRqBcJrsXt7nXahn3GvaB0CKDcqolJtsBAOW4vMZHk=; b=ImSslcCjsjCBKBTC5rl0moaJ47Fz/bZLHdrJhyrnrQmqXXAkJ7N/x+Im31Spns4J+A wh6sxu2R/wmEP+b8TjvWVegd5ihX6N0sFgz7CEz8fxoUOlXecLMev5rR2n4SnopWe+s+ +fJL/1YxIAx2haUmP26Tmfoa81Doa5puBrQjwsxX80fzu9c4TMFXJga1ueMumNEG57F4 DEgnFxbWseFwSM+2G/vY4blEPjia8hZ9rDL2Rwz3WWeSWSeld0k4Uaz8NyeiGbZFDg0Y Lf7aULFCVxDHAJtmuYhtHeOI/TvOTPAl+IJhM67HLrNoXPQQhbrNGQ1EYJYovGYy3m/F ebCQ== X-Gm-Message-State: ALoCoQmeDiX/Ex7fwcMvSPZREgqP6+Pa3L0wEVa6VbjZGzmi6nkKtRLsPBG/UxPOSj7ggtqt/q4C X-Received: by 10.70.128.226 with SMTP id nr2mr4109096pdb.139.1436935840547; Tue, 14 Jul 2015 21:50:40 -0700 (PDT) Received: from host1.lsi.com ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id nk1sm3036132pdb.36.2015.07.14.21.50.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 21:50:39 -0700 (PDT) From: Sreekanth Reddy X-Google-Original-From: Sreekanth Reddy To: tpearson@raptorengineeringinc.com, jejb@kernel.org Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, JBottomley@Parallels.com, Sathya.Prakash@avagotech.com, linux-kernel@vger.kernel.org, hch@infradead.org, Sreekanth Reddy Subject: [PATCH v3] [SCSI] mpt2sas, mpt3sas: Abort initialization if no memory I/O resources detected Date: Wed, 15 Jul 2015 10:19:56 +0530 Message-Id: <1436935796-28995-1-git-send-email-Sreekanth.Reddy@avagotech.com> X-Mailer: git-send-email 2.0.2 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Driver crashes if the BIOS do not set up at least one memory I/O resource. This failure can happen if the device is too slow to respond during POST and is missed by the BIOS, but Linux then detects the device later in the boot process. Changes in v3: Rearranged the code to remove the code redundancy Signed-off-by: Sreekanth Reddy Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt2sas/mpt2sas_base.c | 16 +++++++++------- drivers/scsi/mpt3sas/mpt3sas_base.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 11248de..6dec7cf 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c @@ -1557,7 +1557,8 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) goto out_fail; } - for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) { + for (i = 0, memap_sz = 0, pio_sz = 0; (i < DEVICE_COUNT_RESOURCE) && + (!memap_sz || !pio_sz); i++) { if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { if (pio_sz) continue; @@ -1572,16 +1573,17 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) chip_phys = (u64)ioc->chip_phys; memap_sz = pci_resource_len(pdev, i); ioc->chip = ioremap(ioc->chip_phys, memap_sz); - if (ioc->chip == NULL) { - printk(MPT2SAS_ERR_FMT "unable to map " - "adapter memory!\n", ioc->name); - r = -EINVAL; - goto out_fail; - } } } } + if (ioc->chip == NULL) { + printk(MPT2SAS_ERR_FMT "unable to map adapter memory! " + "or resource not found\n", ioc->name); + r = -EINVAL; + goto out_fail; + } + _base_mask_interrupts(ioc); r = _base_get_ioc_facts(ioc, CAN_SLEEP); diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 14a781b..43f87e9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -1843,7 +1843,8 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) goto out_fail; } - for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) { + for (i = 0, memap_sz = 0, pio_sz = 0; (i < DEVICE_COUNT_RESOURCE) && + (!memap_sz || !pio_sz); i++) { if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { if (pio_sz) continue; @@ -1856,15 +1857,16 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) chip_phys = (u64)ioc->chip_phys; memap_sz = pci_resource_len(pdev, i); ioc->chip = ioremap(ioc->chip_phys, memap_sz); - if (ioc->chip == NULL) { - pr_err(MPT3SAS_FMT "unable to map adapter memory!\n", - ioc->name); - r = -EINVAL; - goto out_fail; - } } } + if (ioc->chip == NULL) { + pr_err(MPT3SAS_FMT "unable to map adapter memory! " + " or resource not found\n", ioc->name); + r = -EINVAL; + goto out_fail; + } + _base_mask_interrupts(ioc); r = _base_get_ioc_facts(ioc, CAN_SLEEP);