From patchwork Tue Sep 29 22:19:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 289340 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,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 5D348C4727C for ; Tue, 29 Sep 2020 22:20:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9FEE20848 for ; Tue, 29 Sep 2020 22:20:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="rB6pBO57" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbgI2WUJ (ORCPT ); Tue, 29 Sep 2020 18:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbgI2WUH (ORCPT ); Tue, 29 Sep 2020 18:20:07 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513EBC0613D0 for ; Tue, 29 Sep 2020 15:20:06 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id l126so6161511pfd.5 for ; Tue, 29 Sep 2020 15:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lto530r924fTZ9R2/barckIXJi8HbI2/fiK18OAiuAU=; b=rB6pBO57fbQBfmM2trAEWyfcj2PKPpf9kfsnGGCaNxbwoXm686IiHDBYRGhhqZsv6f 8Q79XRwjhEGcENk67GCes4oaPkocbB8StqGcpWglQPxKEGoc799/YNoei1zp1EX7GInH b3FDowqwqBey5F3IAyqlio5L3h/oMzqiYc3q0Je+BDnvDV/3Y7ooZV5vAqRAhqTKRkra iDtK2/3ccu/nWhhJuautN1q6SxtCsHG0akM+8+BQOTDlkK/h0PACRSo+ONKWkidCbOkz 7CT6VHVTgKLQb2hDm2AQcqqdmG5qDXOPwX2NJGdNay1WavNYk1lCl1YRGIpGxSw290pj avPw== 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:in-reply-to :references; bh=lto530r924fTZ9R2/barckIXJi8HbI2/fiK18OAiuAU=; b=BDpRRqCbEpGuS+deOTRT3Q1G6TIPvJaIWleMlBevJWUZTabKdVFe7N+EAWJhxDq7pL rNTIomqV9r4TsMUwLgDy4DP6bBJ6X3hvb7c4zRufyZjKWSUbQ3EuTOa61ttj+YRsC1OP 3CC2MUv26V3JgEeUkjEPzYJABi8gT/l1Ot5BNfi6Pwy9foYoLAF4ECtWmNu1VOeU2HBI xJTYuV8MLP1eNIio2MvwJC1UBDzrbFIEAPENBBNuEZuMAqMjZu04dPVK/FmfgHXP38xc +Nayr6NNFxPB+1JoVZJwtBCtRPOivLA2StsVhpw0RHuBzK35tCViVyJau/pHCKqV2ywY atyQ== X-Gm-Message-State: AOAM530X7TM1RtshlyK8sj24682I6b9afX2j2w6TNUv+nmwEcySlChj+ kG/D9fKf0Wc6YDF9wLpDy9xY7VHdw91yiA== X-Google-Smtp-Source: ABdhPJxTM/6Yu0YE9YE+dHncrixPYyqyHG4+ytWGp/IKxjMLqe4WLq/NxSStGMJEYifvY0x8WcGVQw== X-Received: by 2002:a17:902:a713:b029:d2:6356:8761 with SMTP id w19-20020a170902a713b02900d263568761mr6608316plq.77.1601418005450; Tue, 29 Sep 2020 15:20:05 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id e27sm6756428pfj.62.2020.09.29.15.20.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2020 15:20:04 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH net-next 1/2] ionic: stop watchdog timer earlier on remove Date: Tue, 29 Sep 2020 15:19:55 -0700 Message-Id: <20200929221956.3521-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929221956.3521-1-snelson@pensando.io> References: <20200929221956.3521-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We need to be better at making sure we don't have a link check watchdog go off while we're shutting things down, so let's stop the timer as soon as we start the remove. Meanwhile, since that was the only thing in ionic_dev_teardown(), simplify and remove that function. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 5 +++-- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 5 ----- drivers/net/ethernet/pensando/ionic/ionic_dev.h | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c index d1d6fb6669e5..2749ce009ebc 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c @@ -350,7 +350,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_reset: ionic_reset(ionic); err_out_teardown: - ionic_dev_teardown(ionic); + del_timer_sync(&ionic->watchdog_timer); pci_clear_master(pdev); /* Don't fail the probe for these errors, keep * the hw interface around for inspection @@ -378,6 +378,8 @@ static void ionic_remove(struct pci_dev *pdev) if (!ionic) return; + del_timer_sync(&ionic->watchdog_timer); + if (ionic->lif) { ionic_devlink_unregister(ionic); ionic_lif_unregister(ionic->lif); @@ -389,7 +391,6 @@ static void ionic_remove(struct pci_dev *pdev) ionic_port_reset(ionic); ionic_reset(ionic); - ionic_dev_teardown(ionic); pci_clear_master(pdev); ionic_unmap_bars(ionic); pci_release_regions(pdev); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 6068f51a11d9..306e9401b09b 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -98,11 +98,6 @@ int ionic_dev_setup(struct ionic *ionic) return 0; } -void ionic_dev_teardown(struct ionic *ionic) -{ - del_timer_sync(&ionic->watchdog_timer); -} - /* Devcmd Interface */ int ionic_heartbeat_check(struct ionic *ionic) { diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 8842dc4a716f..c109cd5a0471 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -283,7 +283,6 @@ static inline bool ionic_q_has_space(struct ionic_queue *q, unsigned int want) void ionic_init_devinfo(struct ionic *ionic); int ionic_dev_setup(struct ionic *ionic); -void ionic_dev_teardown(struct ionic *ionic); void ionic_dev_cmd_go(struct ionic_dev *idev, union ionic_dev_cmd *cmd); u8 ionic_dev_cmd_status(struct ionic_dev *idev); From patchwork Tue Sep 29 22:19:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 259885 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,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 712CEC4727D for ; Tue, 29 Sep 2020 22:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 065D52083B for ; Tue, 29 Sep 2020 22:20:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="MlkNNxJC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728529AbgI2WUI (ORCPT ); Tue, 29 Sep 2020 18:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgI2WUH (ORCPT ); Tue, 29 Sep 2020 18:20:07 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A34CDC061755 for ; Tue, 29 Sep 2020 15:20:07 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 197so5087807pge.8 for ; Tue, 29 Sep 2020 15:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3btRs2kj3XYpMXiTF0+2va+upFL4/opojo+Cy3TopUE=; b=MlkNNxJC+7jtwAUSFOXdOfzRccKW+Djfp4y5lEqas5vPNWmUNvk9NQ1UTGOH9bA+rq yGL5X+whnQ0IiUmwjU7Q4AfT71fVGlzVhAkIgvpQkcamqmMY3VmVqlXilfX8wpX45g8E OrX2OgtApdARIZ+D0xbzimQBR///tMoK5gaqRBi9JusIfzGXbY2C5D1Vf+yH5VQdvqkY ryCg3VuQ0IcPd1X9zRlguoWCECF+7xsF9h3RXqhAZ3mvJYv3Wvsg+JapQCBJoo682mwE vkkUvpbM70O6jY+b/rkt4Q+y8kaFMDvYibgci1AS6sBmd5aOYXRqIJbNP523GcsaFetO FXTA== 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:in-reply-to :references; bh=3btRs2kj3XYpMXiTF0+2va+upFL4/opojo+Cy3TopUE=; b=mdNW3VQPsmxgOro2AmOWvrLOah7Tc5NtFxxoYoeKnv8q1f5Nl4Hq2/Jd7NAIaOOFak jmZfImhpA/yozq2YJYeYeZAMI/nhQ5zhthrm39Cja7JO1vcHD0ymYPX5bvDKd09BYbmp 7mBWzQsdhCTKtzTr1rdfaWlP7C1P6jqPNR7w0MCi2dP+DZ6KH55dsCGTlvxOWX10Bpg4 T70++0jd0DZkL3FPg+4ycaQ32lHUDqBpm7uQWdH2UadSMEfPq8sZbHHih+JVwPNRLvdQ ZMDfgiDaABUFX4IM9nljxIOskjs4tPMItya6YRYPULUIMHP2D5ofL9Jhgx3dRkCaiqGr vxGA== X-Gm-Message-State: AOAM532u/4QnL8SE9Sr+AnyYr/nqtvLitXeV4JCiMImFxf7vUiZUxwLf oJYB/2JoQmalUi/aVvo0lHlCmHw4fH8kNg== X-Google-Smtp-Source: ABdhPJyK8YDa6Lq2FtZed34GMmk7+h6UUtxdF9hahUjFYCQzfFhg+nE2EmX1Zhk0Ncr1CaKUZEwBKw== X-Received: by 2002:a17:902:9a84:b029:d2:9390:5e6 with SMTP id w4-20020a1709029a84b02900d2939005e6mr5978474plp.37.1601418006833; Tue, 29 Sep 2020 15:20:06 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id e27sm6756428pfj.62.2020.09.29.15.20.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2020 15:20:06 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH net-next 2/2] ionic: prevent early watchdog check Date: Tue, 29 Sep 2020 15:19:56 -0700 Message-Id: <20200929221956.3521-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929221956.3521-1-snelson@pensando.io> References: <20200929221956.3521-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In one corner case scenario, the driver device lif setup can get delayed such that the ionic_watchdog_cb() timer goes off before the ionic->lif is set, thus causing a NULL pointer panic. We catch the problem by checking for a NULL lif just a little earlier in the callback. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 306e9401b09b..f90322ec3e18 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -19,9 +19,12 @@ static void ionic_watchdog_cb(struct timer_list *t) mod_timer(&ionic->watchdog_timer, round_jiffies(jiffies + ionic->watchdog_period)); + if (!ionic->lif) + return; + hb = ionic_heartbeat_check(ionic); - if (hb >= 0 && ionic->lif) + if (hb >= 0) ionic_link_status_check_request(ionic->lif); }