Received: by 10.223.185.116 with SMTP id b49csp8410075wrg; Fri, 2 Mar 2018 00:58:52 -0800 (PST) X-Google-Smtp-Source: AG47ELvbfDwvVjdeeCY/IhogymXYE+tVDmryJOmmZVisRw6Nbtcu92txXOoVy5VG04MsnNXClWBV X-Received: by 2002:a17:902:506:: with SMTP id 6-v6mr4730729plf.365.1519981132153; Fri, 02 Mar 2018 00:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519981132; cv=none; d=google.com; s=arc-20160816; b=TG207xrC26tYkKRQCg2Nxa0zG+haeCSVTWG/sayO8koeJULQXS3ay6pgUwneWXGmvQ c7SAMYoNrggh9e4/IbI796NX1LmwVTKVM7jX5vUuP2vUPoajl4UBmW8urNUooBhAJB2v tfdgQuZUtioRJ8/vipgNNu8aTWg20iSOM1TdyZ9r7ofGYNHvIRB3RyWf260N4H+hSKOu P17lkW84g8vitl7ovPjPF/tEokcrMR0lU9/VdfqEFEqca0u95SH/cKaS0luNs+Pr24l5 Sphnv2TD5ioWJmDGDbVCpXEr8IpfBhDMqxnT1YKRb+IBa1k1kclhmZk718Z4lW7GFcwF 2GvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HLqR+L2LEacFA1xtKwZUKU12JRlbWN+5DYcIINNjk98=; b=aHZreBjplSbFa2HTzOPHS2CHhbHKprfT5YSeVeeoYwzySajvRbagDBftXJY/19pYwv IvTp7LqaR8y2hM8tekiA2CyIjY7uwBOdmWm4NnyFO49RqyUqT9+AHkdlyLd59PBb8aFP iQXmuqJCgVMQrgWKUA/gD69ZN41lwUsCA5X5knWvIhtLzSJGUB4+j6SMX3XKlv2D6/rJ breEMWQ5F00M3MX8Thhl5an+Vfy/Mc30Cov1zLLm8LCZslrf4w2auac2qehpRCRMxCEv C9aAKA01oPknGNyfnX7GLwSxRmf8X4HkH2O05ZgWnaRmbr1rL/ewyAr67AvdyTi9bby5 lbuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l69si4561104pfk.180.2018.03.02.00.58.37; Fri, 02 Mar 2018 00:58:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423510AbeCBIy2 (ORCPT + 99 others); Fri, 2 Mar 2018 03:54:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50430 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423495AbeCBIyY (ORCPT ); Fri, 2 Mar 2018 03:54:24 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5C67C1205; Fri, 2 Mar 2018 08:54:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abdul Haleem , "Guilherme G. Piccoli" , Shahed Shaikh , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 15/34] bnx2x: Improve reliability in case of nested PCI errors Date: Fri, 2 Mar 2018 09:51:11 +0100 Message-Id: <20180302084436.942538303@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Guilherme G. Piccoli" [ Upstream commit f7084059a9cb9e56a186e1677b1dcffd76c2cd24 ] While in recovery process of PCI error (called EEH on PowerPC arch), another PCI transaction could be corrupted causing a situation of nested PCI errors. Also, this scenario could be reproduced with error injection mechanisms (for debug purposes). We observe that in case of nested PCI errors, bnx2x might attempt to initialize its shmem and cause a kernel crash due to bad addresses read from MCP. Multiple different stack traces were observed depending on the point the second PCI error happens. This patch avoids the crashes by: * failing PCI recovery in case of nested errors (since multiple PCI errors in a row are not expected to lead to a functional adapter anyway), and by, * preventing access to adapter FW when MCP is failed (we mark it as failed when shmem cannot get initialized properly). Reported-by: Abdul Haleem Signed-off-by: Guilherme G. Piccoli Acked-by: Shahed Shaikh Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 4 ++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -3052,7 +3052,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, i del_timer_sync(&bp->timer); - if (IS_PF(bp)) { + if (IS_PF(bp) && !BP_NOMCP(bp)) { /* Set ALWAYS_ALIVE bit in shmem */ bp->fw_drv_pulse_wr_seq |= DRV_PULSE_ALWAYS_ALIVE; bnx2x_drv_pulse(bp); @@ -3134,7 +3134,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, i bp->cnic_loaded = false; /* Clear driver version indication in shmem */ - if (IS_PF(bp)) + if (IS_PF(bp) && !BP_NOMCP(bp)) bnx2x_update_mng_version(bp); /* Check if there are pending parity attentions. If there are - set --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -9570,6 +9570,15 @@ static int bnx2x_init_shmem(struct bnx2x do { bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); + + /* If we read all 0xFFs, means we are in PCI error state and + * should bail out to avoid crashes on adapter's FW reads. + */ + if (bp->common.shmem_base == 0xFFFFFFFF) { + bp->flags |= NO_MCP_FLAG; + return -ENODEV; + } + if (bp->common.shmem_base) { val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]); if (val & SHR_MEM_VALIDITY_MB) @@ -14214,7 +14223,10 @@ static pci_ers_result_t bnx2x_io_slot_re BNX2X_ERR("IO slot reset --> driver unload\n"); /* MCP should have been reset; Need to wait for validity */ - bnx2x_init_shmem(bp); + if (bnx2x_init_shmem(bp)) { + rtnl_unlock(); + return PCI_ERS_RESULT_DISCONNECT; + } if (IS_PF(bp) && SHMEM2_HAS(bp, drv_capabilities_flag)) { u32 v;