Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1985027pxx; Sat, 31 Oct 2020 04:52:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/QhK3AE/JA+2vwdQFsMjLy+5jihA8M7zvI/QiyVN25sPz9onNX6SSxnWX+8s1XZYo3SdD X-Received: by 2002:a05:6402:742:: with SMTP id p2mr7350557edy.107.1604145138603; Sat, 31 Oct 2020 04:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145138; cv=none; d=google.com; s=arc-20160816; b=hnXOQZtpOJ4I7VM5jHjGUkb9yzknmujIcSHNcaJnLwk+ya01WHOsNO4ycZbb3EjADN udO6O81XlA/+mC9lGs+oyZTWpU5vxDKQh+DGhhTJfX+gF1dMyK6oA3rTwIQO8sW/WcA0 B1R5k4Clvr5q3bz+CuZQ4eJu4CxtD7KiFN/11GdjNDlpJEeXyj0ImLQpPTYRLAfbeDS7 Lbs0cgUEnyd4p2TgOr0cHkCtL/RhQEnHVO/MSTuKYGRAMc1jb4ro7/685Up5ijRKgTQz ZrCL5owgyXhn3TkXLsqyf3p+8fuEu+bD2gt8mu53uP9w0GcME6ChpzJ33kK/YSnjCt8h ICPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vdgkvXlSfaTUao1ySXWvb6hQXaB956CtAfwBobnziXY=; b=R4QBWrgJrOuraVoOzLga3DYVqHg5Ef8aM7rulA7F2R6dz+VjN5rjiZsXVdPGby5djK IDth1KjySxY4Pe+pZmSda6PqBmT++ms0Web29B6AhGn9ux4roQAacWVNoC9r6eX8nj+a jxvGNEf0lNgV5ltIjaGcMKVBNNkiVNycI4A081SA9/Hm8qG9q/auviVbge8JIh83ecsd RKReokq46jT8YHwiJ9QO9KRvDcm3eDiHcDAElTIQh4ycEbAR+DqcmyxZiEiT6vVo/6I8 WEmLtU9ZAtasJX/6hylAn9DiZuXYwYoJrBZCc0hT3oRtTid0BtyJ0H4ZWMgoAiGrUqVe 3APw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U9F4m4vc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si6363870ejy.274.2020.10.31.04.51.56; Sat, 31 Oct 2020 04:52:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U9F4m4vc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727623AbgJaLlO (ORCPT + 99 others); Sat, 31 Oct 2020 07:41:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:40104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727329AbgJaLlJ (ORCPT ); Sat, 31 Oct 2020 07:41:09 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE5A620791; Sat, 31 Oct 2020 11:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144468; bh=u4LAuafSZn8+T0csQ5y0gTcOXyb6hkF6KO30E1jQtx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9F4m4vcx4JrBURY9kuM9vwfwi0gvGRYBKxaGx9XAfvNuvvqu4OIexJQRfvQpwBJN +NIteHLeUHtvhP6XXmhN4q20nBgitJoz0K8agWmwi5Af1Vi0heX2ZFbEGCRuXguJpd 1w/Ey3+YCfa21PRtzGyl2o3uJklb6ErhbyMUs0sg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasundhara Volam , Michael Chan , Jakub Kicinski Subject: [PATCH 5.8 30/70] bnxt_en: Re-write PCI BARs after PCI fatal error. Date: Sat, 31 Oct 2020 12:36:02 +0100 Message-Id: <20201031113500.946611144@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasundhara Volam [ Upstream commit f75d9a0aa96721d20011cd5f8c7a24eb32728589 ] When a PCIe fatal error occurs, the internal latched BAR addresses in the chip get reset even though the BAR register values in config space are retained. pci_restore_state() will not rewrite the BAR addresses if the BAR address values are valid, causing the chip's internal BAR addresses to stay invalid. So we need to zero the BAR registers during PCIe fatal error to force pci_restore_state() to restore the BAR addresses. These write cycles to the BAR registers will cause the proper BAR addresses to latch internally. Fixes: 6316ea6db93d ("bnxt_en: Enable AER support.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 ++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12233,6 +12233,9 @@ static pci_ers_result_t bnxt_io_error_de return PCI_ERS_RESULT_DISCONNECT; } + if (state == pci_channel_io_frozen) + set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); + if (netif_running(netdev)) bnxt_close(netdev); @@ -12259,7 +12262,7 @@ static pci_ers_result_t bnxt_io_slot_res { struct net_device *netdev = pci_get_drvdata(pdev); struct bnxt *bp = netdev_priv(netdev); - int err = 0; + int err = 0, off; pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT; netdev_info(bp->dev, "PCI Slot Reset\n"); @@ -12271,6 +12274,20 @@ static pci_ers_result_t bnxt_io_slot_res "Cannot re-enable PCI device after reset.\n"); } else { pci_set_master(pdev); + /* Upon fatal error, our device internal logic that latches to + * BAR value is getting reset and will restore only upon + * rewritting the BARs. + * + * As pci_restore_state() does not re-write the BARs if the + * value is same as saved value earlier, driver needs to + * write the BARs to 0 to force restore, in case of fatal error. + */ + if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, + &bp->state)) { + for (off = PCI_BASE_ADDRESS_0; + off <= PCI_BASE_ADDRESS_5; off += 4) + pci_write_config_dword(bp->pdev, off, 0); + } pci_restore_state(pdev); pci_save_state(pdev); --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1672,6 +1672,7 @@ struct bnxt { #define BNXT_STATE_ABORT_ERR 5 #define BNXT_STATE_FW_FATAL_COND 6 #define BNXT_STATE_DRV_REGISTERED 7 +#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 #define BNXT_NO_FW_ACCESS(bp) \ (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \