From patchwork Sat Mar 8 01:08:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 14007332 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 6C97E3C38; Sat, 8 Mar 2025 01:08:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396125; cv=none; b=t9ScDnXutYrGEPQdcly/uYMUlewZf70ICLqbRuggAAWYf4zgsPCfphSsnftSctsTm5PScLq0Kg6MZ9nT3XemM2Ah4sOtCuCyq52ahlYLUYevd35XDlT7uLHm0TfXHMzw1CpPeDeoUxr+x9MR8O834sTWFJg37z1C7pUiDv/wMgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396125; c=relaxed/simple; bh=han6XIBLQLzR4StkcQHRyFfL8Og3xS7ZdUkP6nRmRcs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=s40ZcZxejzIzXim5Wu2U+AOBSkLt92M1bs+gy7M3pKGnlhUXwuGt/BPPpocMgMleIGB37F3/rw/dRJ17b0sHHND6LRuwWAVhIutOh2Ku4V6m1a7kZrYMDu/V5qqgYtNjf2Ub5ZZ06KRVkXiJDh9ienbzfVb4EKd5TNMUH68YywA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2f42992f608so4417136a91.0; Fri, 07 Mar 2025 17:08:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741396121; x=1742000921; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lZceUGzZQI+8M1i/0MdDKtz8ApRiyWMZXylPBeplVtk=; b=JwVXwDpzLQQazTkROqC3Wn7KPfE3q1z+RepmcnP0Iaebn7HprXHtq0IvsF1NlHIxMs exQxqZkqxR0NZ8RGGBDXyZhmTaascV8Lrv4BeTyhO9cuqvsefvzP0V6sdpPhanVVNqEQ Z/AzZxQdCXZuIcnm28egARZ1sOGygbdltgVrzZCFRyiQEpQJbITfBiDOC9fAMORKcQIs /AlBCt9/kSpBVOK27isqWx6BQFj8uTobcfNZm4C9LUl/M+FyQY/trLiGHboI+H51Va/F +U+0wWwwytSfj+bk858l3tKaTkzSc+rCLcHxzYE7lR2AZeJF6D0EwbcIyLMjsgRSn6sb jn2Q== X-Forwarded-Encrypted: i=1; AJvYcCVj/IXunEFzOUNuY9G4pOXE1pkibGyFeMNjPkdYCxsvo5Xm+gwBq/cRyxK3clzcC4lyzJpP5kHN4HAiiWI=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx5mLC7b96eaUALNvcwAJZQUDA3J65/bfb70NbasNYZu8BoxXP USNAliB+HUVEu2rBL2qzFgfKm1KDZdt8pZyTG9dwdSgGD9xbAQvIprzU X-Gm-Gg: ASbGncu9l7gdiJ07CAd9q0Kca46OxLS8JlDFQOT0/ZWFJZH/BYwok2cqUbeqMfRgk4D K9BrOmY4ENPNi1zOcxhyT1KIlCgV1mqEyqwb2cdPyD1Bn8u2TwLUi+mNCBNE9VYc/yKQy/CQbQW BvnILiedUFR3XHZjzslqEXVygWZIdD0XbuqB5UkhNzFvt8cnxAhbTa7lx5iZFy+z1OBkk1fkTWo y+s94F5gPCjczKXafiLCFocRu5dZV2IyBelP3KDF7Dd/ojvcnhk6aTOuTQhBamxZPMQmqzUiDSx mLkU4vgfpUrNlGaMp6QUNytutYnGLI/p99ej70s/9PkF X-Google-Smtp-Source: AGHT+IH0xN13AElE92Eegmk3L+r+oO5h6CaskheJmANUrI0dN4CrC7FaJlKLvvzlA/CgRP8k3Pd2+g== X-Received: by 2002:a17:90b:52c3:b0:2fe:9581:fbea with SMTP id 98e67ed59e1d1-2ff7cf22de4mr8548082a91.29.1741396121322; Fri, 07 Mar 2025 17:08:41 -0800 (PST) Received: from localhost ([2601:646:9e00:f56e:2844:3d8f:bf3e:12cc]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2ff4e789356sm5578812a91.24.2025.03.07.17.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 17:08:40 -0800 (PST) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, sdf@fomichev.me Subject: [PATCH net-next 1/3] eth: bnxt: switch to netif_close Date: Fri, 7 Mar 2025 17:08:38 -0800 Message-ID: <20250308010840.910382-1-sdf@fomichev.me> X-Mailer: git-send-email 2.48.1 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 All (error) paths that call dev_close are already holding instance lock, so switch to netif_close to avoid the deadlock. Fixes: 004b5008016a ("eth: bnxt: remove most dependencies on RTNL") Reported-by: Jakub Kicinski Signed-off-by: Stanislav Fomichev --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1a1e6da77777..e874530f1db2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12801,7 +12801,7 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) rc = __bnxt_open_nic(bp, irq_re_init, link_re_init); if (rc) { netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); - dev_close(bp->dev); + netif_close(bp->dev); } return rc; } @@ -12839,7 +12839,7 @@ int bnxt_half_open_nic(struct bnxt *bp) half_open_err: bnxt_free_skbs(bp); bnxt_free_mem(bp, true); - dev_close(bp->dev); + netif_close(bp->dev); return rc; } @@ -14194,7 +14194,7 @@ void bnxt_fw_reset(struct bnxt *bp) netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", n); clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); - dev_close(bp->dev); + netif_close(bp->dev); goto fw_reset_exit; } else if (n > 0) { u16 vf_tmo_dsecs = n * 10; @@ -14809,7 +14809,7 @@ static void bnxt_fw_reset_abort(struct bnxt *bp, int rc) if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) bnxt_dl_health_fw_status_update(bp, false); bp->fw_reset_state = 0; - dev_close(bp->dev); + netif_close(bp->dev); } static void bnxt_fw_reset_task(struct work_struct *work) @@ -16275,7 +16275,7 @@ int bnxt_restore_pf_fw_resources(struct bnxt *bp) if (netif_running(bp->dev)) { if (rc) - dev_close(bp->dev); + netif_close(bp->dev); else rc = bnxt_open_nic(bp, true, false); } @@ -16668,7 +16668,7 @@ static void bnxt_shutdown(struct pci_dev *pdev) goto shutdown_exit; if (netif_running(dev)) - dev_close(dev); + netif_close(dev); bnxt_ptp_clear(bp); bnxt_clear_int_mode(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index b06fcddfc81c..b6d6fcd105d7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -461,7 +461,7 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, if (rc) { NL_SET_ERR_MSG_MOD(extack, "Failed to deregister"); if (netif_running(bp->dev)) - dev_close(bp->dev); + netif_close(bp->dev); netdev_unlock(bp->dev); rtnl_unlock(); break; @@ -576,7 +576,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti *actions_performed |= BIT(action); } else if (netif_running(bp->dev)) { netdev_lock(bp->dev); - dev_close(bp->dev); + netif_close(bp->dev); netdev_unlock(bp->dev); } rtnl_unlock(); From patchwork Sat Mar 8 01:08:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 14007331 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.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 A79898C11; Sat, 8 Mar 2025 01:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396125; cv=none; b=cVXBvB9ekCG1Uj0PP6g/0fg71ihYaCms81jw9AX6jp5spu+ZoFT869VQi588ORC2xIM3boElttMko6qt9Mz/wflR3KiLI03bBPopobXHg6v2vykliAUuBJI7DEersgfHbdgDJ0l1yvXqfXjZFMJXiSJBhtN32RWkxOplGpLcjw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396125; c=relaxed/simple; bh=Q6UANAkHsbT+S3c55tbICBTDomSC06el0+MjXvYATi8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qfEjOVuwKUa2e+JXjBMcqvGlkt/8RlT+C3RUG8cP84Hs8DNYBJBzT1c/OejSTOsz3ipGlN8E2FVyhatVF+5b2Xhp6alKcYs1ZwTDG5zmrQxtHRV2Ept3OymDk1XZ15vy6v6Qq+R0G4izmQAVEHeH744ZNBGgn6AH+ggrLiOr65Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-22438c356c8so15684955ad.1; Fri, 07 Mar 2025 17:08:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741396123; x=1742000923; h=content-transfer-encoding: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=s0N9xtKzH+7HwP/Ov2uhiuWXfnYo6fKPPkQhcVJZEz0=; b=Uegb+47UAk156WsOclXL3bMrFmtkzDDZKQpMlkpDwlcUOtYNYLtZqxjaqTkD3P1UGw NBy4EwkzgrDLmWvND8YKo0MPEUs6rL9/Mt5i6bhc56SAowAYNklD6j4wlN7lfgdnA8oT JQ3IiO2jawgZiHdLKta7YFDlF3Y0SAkAlGjDToWUcc7ubFnOyTRpNDiQbK2bb4X1Fwob AYENqc7B+oA0dZvPLnszqRkhckLw8OXRkhUh1cSdXdL1crkI3Cwt0SWhoYouth6+rpg8 NcJUCTQRKPMoG+U/ISg6tpPVrvW5o34fKo6nGYF9vvHZ/9rG6xh5arYUOL/YDLnGMRU4 6JvQ== X-Forwarded-Encrypted: i=1; AJvYcCXSUQzhPrPgDnUMm5eMRDia/seakuwCp1ejqzSJT7VpVO8M76dkHKkw3imLjmZGa4lxx4gsUPgW4A/W76A=@vger.kernel.org X-Gm-Message-State: AOJu0YzFBZOpkLmp1sIpsVpSClC6Ci6ljHV/Dyw/M/6upLFiN0VgXCo0 7+pTKtoAldusdGxUDjajAT5BwGByoVkIDdMffEKMvl0llpgs12m31eBA X-Gm-Gg: ASbGncsVTgvMdhooYZTcy/PoNWGVrKh07ObOsS7+mqYQMFtzbNxok+bs+oaV9tZ9yAw J/VrkiWa9UdpDZd1zt9mbCHtqFU3pkYGHyTT1w/99jge5hmkD59/eeGyVshkPviS1CeazvEO5jq Gp6mmpvp/QRyF5nINIhYH77lGq01WXrLddKi7IcH30OYi/uiUk6bn6rQhMwgWUa89b14KQI+gqJ Itgd9JjQ0Qlwlbw79Vv/za7kC//S47fctmoV1fksCFOWNPBKAH0WnOoPQWxcavC3h8cit7BJ3CP Tyht3kApfLnRKAnc1/GzEbvVSGrdVwz7N6UIx3hmdsHH X-Google-Smtp-Source: AGHT+IEbzXbR2m8Dn93znHMkHmNwpA9xSMJ2jRH0osMrDmIEsgMo+fMzrYGo4w/VgX/ou4CdgjY4Kg== X-Received: by 2002:a05:6a00:cc2:b0:736:6279:ca25 with SMTP id d2e1a72fcca58-736aaaed7admr10746780b3a.24.1741396122662; Fri, 07 Mar 2025 17:08:42 -0800 (PST) Received: from localhost ([2601:646:9e00:f56e:2844:3d8f:bf3e:12cc]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-73698206871sm3956527b3a.24.2025.03.07.17.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 17:08:42 -0800 (PST) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, sdf@fomichev.me Subject: [PATCH net-next 2/3] eth: bnxt: request unconditional ops lock Date: Fri, 7 Mar 2025 17:08:39 -0800 Message-ID: <20250308010840.910382-2-sdf@fomichev.me> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250308010840.910382-1-sdf@fomichev.me> References: <20250308010840.910382-1-sdf@fomichev.me> 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 netdev_lock_ops conditionally grabs instance lock when queue_mgmt_ops is defined. However queue_mgmt_ops support is signaled via FW so we can sometimes boot without queue_mgmt_ops being set. This will result in bnxt running without instance lock which the driver now heavily depends on. Set request_ops_lock to true unconditionally to always request netdev instance lock. Fixes: 004b5008016a ("eth: bnxt: remove most dependencies on RTNL") Signed-off-by: Stanislav Fomichev --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e874530f1db2..225d3e2db541 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -16612,6 +16612,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; if (BNXT_SUPPORTS_QUEUE_API(bp)) dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops; + dev->request_ops_lock = true; rc = register_netdev(dev); if (rc) From patchwork Sat Mar 8 01:08:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 14007333 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 031CABE4F; Sat, 8 Mar 2025 01:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396126; cv=none; b=LGEHisd+sI3IrHJNMERKNCjxnxCd/aL+LXidt0OnTNELZhPEscFM0sru8EjjCg+leSHvSmAUSDDVcBt6Tsf8D7mK6NxtgSJDGxHsvuXF2+cF6fB7BtUH305AbOhPn7c5ffAhuuNM+gz1rccNjevHkZRTH+4XsNlYO69XEBUlWu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741396126; c=relaxed/simple; bh=wwil/2v41H0XAHT4WhGN3oUbvCK5TX1lOhPw1rpP4vU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KM+pzzL1eJDHxDcUiPnLZVdZ5I5C/nvk9uaNZlRnlBXBT1g7CQMOteNXAFkxagoFKwCYszpIf8XJQfsjDxM5zXRbo++7h9SpJd8/fVMsp1kUSnokyWsWbt5kJ7x4xbOxKl5F6VKvH84APGUN1fBaX8SVmC9kiCIitAE1QT1tt18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2239f8646f6so47136245ad.2; Fri, 07 Mar 2025 17:08:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741396124; x=1742000924; h=content-transfer-encoding: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=yZzG6RJCUE4w9vBi92LziU0iLdE8HumGGZ3TnO1HuEk=; b=aaVC623Ez4+gTatItGjvSZyumQFNEdo5ZhpNwhf2TmMWR6darINkVPQCoqNJMbwvU5 DUSMENzSFPk7BZmDTM+mV+S5JKSIx9NfgbfOQkaZoXezdt1j4XouA4wI+vajp/XwGV9m h6sxR1bybuHIJlK7uFvLWo6JyIxOTOoIOPoEksMpDP7DbFWstXUKyfEKyR5sECDuUUTK Ah2AQPsAxvfdPlejiDbuqIfc1x2dDxNRDCjHz1PWIU6yD4ZNYzoZNX/sVTUcwLe5FYT7 OQnE3jSVh+6m2RfQkZ8wosb5Uq8sUrjo/joqMGRIA6gTzCQYgvWysg1eSNFM5dmfCPax iW5w== X-Forwarded-Encrypted: i=1; AJvYcCV5wJuWH9kGcjT+OyyiQFIbL5Rndqw42RWyZgO0E5b3ycOaUx8xBAW2dSJE7z5zL5Rt1rk7ZG1RJ7Pj++o=@vger.kernel.org X-Gm-Message-State: AOJu0YwYeDYNtzKqS8wma7FQEsbcbZy+I82ZcvETpIUetlTMl/ZIbfha 2Qgv5KX6tL3LLOIHeas4SdPzN+M7Xay4DE5Go1+gXS6+k75fbRXf3Ie6 X-Gm-Gg: ASbGncvV4E7Wiw9yyE5OMdzKC0M2ZqCKbonho8gVOVn3TehqqLp3DuCrbbFpK3lo5BW TGdgWPr44dMGU/eXFANNdN8mtyaa3UEhhcQwiPDPFxX3O2/lCXAr11kE8991X5fe8/+OAdyiV6x 9hoTpVO75Ivf8CCoaq1ciFDkBWF/LdKOUr7M/S1rMpcgJaDQqC7AKY/IIZlGcY5fnE5ea+k1F88 mlR1ERLP+bGla/YmPldFTZzJo/SA8Ee8cmDu+YzK9BWse5czIPk09SkG7D9Y963DjFMAcqx4Y5U KDj/U552ZsGzHZ7cFemXCff3YZrJW43qvIxPEDpNi110 X-Google-Smtp-Source: AGHT+IFLicPF9DYHopLUsyxSlIIaJHPsUCyq/CCGJkidujAVcbCjmBBrELmykKF33i3geS5NWWBBWw== X-Received: by 2002:a17:903:1a05:b0:224:1294:1d26 with SMTP id d9443c01a7336-2242888bf0fmr79353515ad.13.1741396123952; Fri, 07 Mar 2025 17:08:43 -0800 (PST) Received: from localhost ([2601:646:9e00:f56e:2844:3d8f:bf3e:12cc]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22410a91993sm36754865ad.175.2025.03.07.17.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 17:08:43 -0800 (PST) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, sdf@fomichev.me Subject: [PATCH net-next 3/3] eth: bnxt: add missing netdev lock management to bnxt_dl_reload_up Date: Fri, 7 Mar 2025 17:08:40 -0800 Message-ID: <20250308010840.910382-3-sdf@fomichev.me> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250308010840.910382-1-sdf@fomichev.me> References: <20250308010840.910382-1-sdf@fomichev.me> 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 bnxt_dl_reload_up is completely missing instance lock management which can result in `devlink dev reload` leaving with instance lock held. Add the missing calls. Also add netdev_assert_locked to make it clear that the up() method is running with the instance lock grabbed. Fixes: 004b5008016a ("eth: bnxt: remove most dependencies on RTNL") Signed-off-by: Stanislav Fomichev --- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index b6d6fcd105d7..ea7f789be760 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -518,6 +518,8 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti struct bnxt *bp = bnxt_get_bp_from_dl(dl); int rc = 0; + netdev_assert_locked(bp->dev); + *actions_performed = 0; switch (action) { case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { @@ -542,6 +544,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti if (!netif_running(bp->dev)) NL_SET_ERR_MSG_MOD(extack, "Device is closed, not waiting for reset notice that will never come"); + netdev_unlock(bp->dev); rtnl_unlock(); while (test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) { if (time_after(jiffies, timeout)) { @@ -557,6 +560,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti msleep(50); } rtnl_lock(); + netdev_lock(bp->dev); if (!rc) *actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT); clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); @@ -575,10 +579,9 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti } *actions_performed |= BIT(action); } else if (netif_running(bp->dev)) { - netdev_lock(bp->dev); netif_close(bp->dev); - netdev_unlock(bp->dev); } + netdev_unlock(bp->dev); rtnl_unlock(); if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT) bnxt_ulp_start(bp, rc);