From patchwork Fri Apr 19 18:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13636734 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FD4FA947 for ; Fri, 19 Apr 2024 18:35:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713551707; cv=none; b=Ugzgl5ACw3YYV1ctKBPOKNTYRZg8JabFcDaAzCCj4u91lr5zaIXB7YIycfjQ/bGfFq3tiLX6qWla6agb4lOsiIxsEOuxgmPidBQp8kA7jq9EeMdUMrLcy9184oyiW/iwJ/QcgDbIyPoI75LJvjr0PfXG5WCJeKR6WGT970P4g4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713551707; c=relaxed/simple; bh=ODLBCNi+4XTn+x2Q1U9bu0/Py42RFeA0vPUT2NsUuWs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=YTx057lhZKUyJv2rGfdP40vahAQkjEQEYzxgmky95CiJEVSRukmfP4SmWm4xwVT9gvuBl8SITERSXGGBw/QfDqLNM7Z+DjugDHg5XxceapVCYyCx3acVMTJbuoVptlxBG4sc6nPDvyWfMBNdwXR0tLbu0xxbkDy1S0bGq6cgPAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=AfZqiIGP; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="AfZqiIGP" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-78d62c1e82bso160107985a.3 for ; Fri, 19 Apr 2024 11:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1713551704; x=1714156504; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+CnqHY/Y8Xc8FYH1/QaGZHUgrrfdXNTtT3SYEC309Bg=; b=AfZqiIGP9ClqCV1fRKLQpCmruxbwnet/UEw/DJpAKOZNqHAW1atyAvHG+V2Pl7fKso kpb/d70jVTE5NhLN6Qua7h9J/Zq+/78dV2f/N+e67RAQUk4wm9uUEQ2D+f4tQiNkEf6U /jxOnhZAV45PW+YMfbsGhP40fM3k+9Lxibalw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713551704; x=1714156504; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+CnqHY/Y8Xc8FYH1/QaGZHUgrrfdXNTtT3SYEC309Bg=; b=T0P+DPF1RphB7cQm1Dw+x2fFV/1ZMjVZU3jbHL8KRNGP1jSQGrHAsH5w+JJ6nB9b8E u4PicgJwxJHASLdZqJ3Ms5lTESl4leBuA+CZrcWWQgqVa4fpi2x7D4M9I0ZxFIQYhtox vsGs9y2BtvHI8q3LqDTgmhR9bOjZ8Y5NoTcZss4UaSf67G3tyUv1YI4EFN4HayRtRpuw jjhyzm7DkZIwUuBr7vvh13+h9la1A0qA6K5CVx81YcdwK4AFtVyh3tGOWx2cwWaNBf4r rIM3CMeHn4hjBm0JBMJhBM4ru2e5qIPjXGNxI7/xmDzRlbitS/AQ582UWweqk3kuyMJl 9Ipg== X-Gm-Message-State: AOJu0Yw4ilwHvx0zsQw59udg7X31a+F6S1iQ0Nsf/6clcw+1Py+LvHLO 4pEKlE7S5++xVQQRkf/nqqqIp+M7d+CiwQQkLRb9Z21TL1dGhEARX5uI/7lHtA== X-Google-Smtp-Source: AGHT+IGsqeFmIa9meB4mY5UWFlLAg9zbgss7Q2BgAulSfFoCMWE6cfelOEi6Glb6ay9nTwf+hO23sQ== X-Received: by 2002:a05:622a:87:b0:436:df6a:dcab with SMTP id o7-20020a05622a008700b00436df6adcabmr3632111qtw.46.1713551704240; Fri, 19 Apr 2024 11:35:04 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d12-20020ac851cc000000b00438527a4eb5sm547940qtn.10.2024.04.19.11.35.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2024 11:35:03 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, Vikas Gupta Subject: [PATCH net 2/3] bnxt_en: Fix the PCI-AER routines Date: Fri, 19 Apr 2024 11:34:48 -0700 Message-Id: <20240419183449.234327-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240419183449.234327-1-michael.chan@broadcom.com> References: <20240419183449.234327-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Vikas Gupta We do not support two simultaneous recoveries so check for reset flag, BNXT_STATE_IN_FW_RESET, and do not proceed with AER further. When the pci channel state is pci_channel_io_frozen, the PCIe link can not be trusted so we disable the traffic immediately and stop BAR access by calling bnxt_fw_fatal_close(). BAR access after AER fatal error can cause an NMI. Fixes: f75d9a0aa967 ("bnxt_en: Re-write PCI BARs after PCI fatal error.") Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c852f87c842f..86c1c30c70d5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -15378,6 +15378,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, { struct net_device *netdev = pci_get_drvdata(pdev); struct bnxt *bp = netdev_priv(netdev); + bool abort = false; netdev_info(netdev, "PCI I/O error detected\n"); @@ -15386,16 +15387,27 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, bnxt_ulp_stop(bp); - if (state == pci_channel_io_perm_failure) { + if (test_and_set_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { + netdev_err(bp->dev, "Firmware reset already in progress\n"); + abort = true; + } + + if (abort || state == pci_channel_io_perm_failure) { rtnl_unlock(); return PCI_ERS_RESULT_DISCONNECT; } - if (state == pci_channel_io_frozen) + /* Link is not reliable anymore if state is pci_channel_io_frozen + * so we disable bus master to prevent any potential bad DMAs before + * freeing kernel memory. + */ + if (state == pci_channel_io_frozen) { set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); + bnxt_fw_fatal_close(bp); + } if (netif_running(netdev)) - bnxt_close(netdev); + __bnxt_close_nic(bp, true, true); if (pci_is_enabled(pdev)) pci_disable_device(pdev); @@ -15479,6 +15491,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) } reset_exit: + clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); bnxt_clear_reservations(bp, true); rtnl_unlock();