From patchwork Sat Feb 6 01:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 377958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_NO_TEXT, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03CACC433DB for ; Sat, 6 Feb 2021 02:57:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9D4864F95 for ; Sat, 6 Feb 2021 02:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbhBFCzu (ORCPT ); Fri, 5 Feb 2021 21:55:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbhBFCrx (ORCPT ); Fri, 5 Feb 2021 21:47:53 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AE3C03327A for ; Fri, 5 Feb 2021 17:37:38 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id 18so3347373pfz.3 for ; Fri, 05 Feb 2021 17:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=Rg7d6bX1HnJ0MPVvD5bMiwtkKqnQXvTXMgHvYqnrsks=; b=LSRkyjOA/VGbVxc6ZREyktywxAUJQIs6pLBj7nExxAPTyX+KGIesYn6VfhYCt+SvOu NzxgGNcGe63Y5pNZgFdJUwYG5GA7lrWYndD91KTbndfLl8XdyMrz3rRgtGg4O0iTvKtO hKqQq5vJiEhwmC8TWx0ikkLLhOwStRM3cvjak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=Rg7d6bX1HnJ0MPVvD5bMiwtkKqnQXvTXMgHvYqnrsks=; b=CL++I3Dsw3SFA6mj9q5ovuxY4pMDv3JBZKigDXFV0xa2jqh3VOwhIgMTrYb93Hovdw 9XMP4eYvIIsflSO6qig2qFBSFk1pXvULPJCzIfwW/GPubcbLn2fYdoF2J0BWqEmmPYmc UldXMybvKVa6okFnq77EdeRtuOzrqPb6+SslSgDYg9kQ0FG0ujXNuH2b9GlfxbQ0GdCn sw13+5lE7RgPW5gGAuBRON5bvRIZ81QreOy4Sj0soSwSZWDtz5nejmWOssnu6hh3/Scp PqQduSq9TmgCzzO8N1nP8Lo2nXidXmojBju0DBnXRZD3AaO+zzfXCHgi2C8o0/2AsK4Y 9b3w== X-Gm-Message-State: AOAM531pSsTgVDBcqUjsohJqKYUrTLNewitugDuKjJKVQJIGa9B0xKHQ BTbpujThZ3m19kb+KSts8iLVyRY7ae65KF5Adb1JiAtIsqR/qToCXXrlbJceJAIzNN02Tbgzw5i pI0iaF8JzbLiZdJKLIxQ9hJukJSaKZn/ce648nPTxSF9NLPOHPhQASJR39oZbalucy+y+bRfS X-Google-Smtp-Source: ABdhPJzt6sTvgK7eHusQw0XJWFpRSemHDpwyPah+AcR75ivLWJJKZyinzSC0LcNCpdZslqCADQpeDA== X-Received: by 2002:a62:401:0:b029:1c3:fb36:8f55 with SMTP id 1-20020a6204010000b02901c3fb368f55mr7287933pfe.52.1612575457515; Fri, 05 Feb 2021 17:37:37 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id t18sm1422pjs.57.2021.02.05.17.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 17:37:36 -0800 (PST) From: Edwin Peer To: netdev@vger.kernel.org Cc: Edwin Peer , "David S . Miller" , Jakub Kicinski , Andrew Gospodarek , Michael Chan Subject: [PATCH net] net: watchdog: hold device global xmit lock during tx disable Date: Fri, 5 Feb 2021 17:37:32 -0800 Message-Id: <20210206013732.508552-1-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Prevent netif_tx_disable() running concurrently with dev_watchdog() by taking the device global xmit lock. Otherwise, the recommended: netif_carrier_off(dev); netif_tx_disable(dev); driver shutdown sequence can happen after the watchdog has already checked carrier, resulting in possible false alarms. This is because netif_tx_lock() only sets the frozen bit without maintaining the locks on the individual queues. Fixes: c3f26a269c24 ("netdev: Fix lockdep warnings in multiqueue configurations.") Signed-off-by: Edwin Peer Reviewed-by: Jakub Kicinski --- include/linux/netdevice.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 259be67644e3..5ff27c12ce68 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4352,6 +4352,7 @@ static inline void netif_tx_disable(struct net_device *dev) local_bh_disable(); cpu = smp_processor_id(); + spin_lock(&dev->tx_global_lock); for (i = 0; i < dev->num_tx_queues; i++) { struct netdev_queue *txq = netdev_get_tx_queue(dev, i); @@ -4359,6 +4360,7 @@ static inline void netif_tx_disable(struct net_device *dev) netif_tx_stop_queue(txq); __netif_tx_unlock(txq); } + spin_unlock(&dev->tx_global_lock); local_bh_enable(); }