From patchwork Wed Sep 30 17:48:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 289276 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.8 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 8B239C4727C for ; Wed, 30 Sep 2020 17:49:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A4172074B for ; Wed, 30 Sep 2020 17:49:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="o+F4v1do" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731287AbgI3Rs7 (ORCPT ); Wed, 30 Sep 2020 13:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgI3Rs7 (ORCPT ); Wed, 30 Sep 2020 13:48:59 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4DFC0613D0 for ; Wed, 30 Sep 2020 10:48:59 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id n14so1670153pff.6 for ; Wed, 30 Sep 2020 10:48:59 -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=/YTvNtrLxFHo4qW2QcfkLf5fd9lIOH+F5JK98NHFCBM=; b=o+F4v1doreRvqKhE5HUdsdAmy2eUVx6rCW0hdtttV1UabiIteoXct7Gg5AGjo/2abg RbUBeBN41VO9e9T0Bn/a25G968hE+x7FU74GFCOF3Y5GNQXGwrZVXpFqvTat9HkWap3h 4O8j3VOy+fSiYAANTck66BYMlneB9Q7h1fkST3PqPbnthvYHqeQPPredBYvLhfHDKJgA onCKje4bN16d0Gd1jS/MiDZAEB15Gl/k1yaoLsBb0irXz14b/FJWXUzu9Pv7GwhL0KQZ /9d2BoIa5LDj0h80QzlTthZ7Dpm+pszbfw7SWbZJ6AyKErEXcQ6QTUV38MSv/pYyNLRQ MMmw== 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=/YTvNtrLxFHo4qW2QcfkLf5fd9lIOH+F5JK98NHFCBM=; b=YcFLafGtx01vnbYTeFO5vf3MzZJ4qx0GuJ46GxFm1Qa6uuKuB4/9WRLlcS1vhJK12g AS2xJYMSNQ8YhhYK8VYC4u+9VUsrPCiamlj8OriDlf7I6v8XcGSEUezW2TGbeP2kvssS dn/AGBp1EBmICIz1tk6PA7MWgmFiuqhV3UjmbeRKqpWdjA6B2RCG8WphGbFiTRxV9C7o HCnuO+iAvvRd14MOKwYSXp5VXJ9UG0rnjjl/sEyKEVTAgL109Plpx2t0PsWU++zNBu5U 2GA8wBIv5dJ4/v+w+sKvCVSj4Z/VrLOwGt/FIo9R+xavK06O8Bl5uz55oE7fLfUih1/q Jxwg== X-Gm-Message-State: AOAM532wldSWjowLNn8h9M9Kz9+TQH1EjjwGdulaeLlq18MTSL9tVuU8 z74NEVWcRdGnyNXh7jwOZOcq/fQe+ZGAAQ== X-Google-Smtp-Source: ABdhPJzXXYc1dAI07GHd6yMcF8teJysGXp6XlytTyouCEzkz6iPDPCjFejh0otslgsWqQKgJzEYDGQ== X-Received: by 2002:a63:fd03:: with SMTP id d3mr2916986pgh.201.1601488138632; Wed, 30 Sep 2020 10:48:58 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id l13sm2993974pgq.33.2020.09.30.10.48.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2020 10:48:58 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v2 net-next 1/2] ionic: stop watchdog timer earlier on remove Date: Wed, 30 Sep 2020 10:48:27 -0700 Message-Id: <20200930174828.39657-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930174828.39657-1-snelson@pensando.io> References: <20200930174828.39657-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 a02f710200da..16b6b65e8319 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 Wed Sep 30 17:48:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 289277 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.8 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 D242CC4741F for ; Wed, 30 Sep 2020 17:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CCFC2076A for ; Wed, 30 Sep 2020 17:49:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="XNgATelF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731405AbgI3RtB (ORCPT ); Wed, 30 Sep 2020 13:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgI3RtA (ORCPT ); Wed, 30 Sep 2020 13:49:00 -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 45AFBC061755 for ; Wed, 30 Sep 2020 10:49:00 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id y14so1507496pgf.12 for ; Wed, 30 Sep 2020 10:49:00 -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=fU2c4c7iM/48MX+o4q+fyiFqE7snGU7LBCYm26MndCc=; b=XNgATelFyYMwnBU/kuhCeEYiPiLyRxoEs4FW7+vKX+eQBim9AmrSwCXWbsGIH7PGAx grJa2rGSrYpW+jZke4HYnUpYjYOLzMr+gEOp51VHFrjFNGBdCoidOWhaCVnB0cxiyB35 TVm7RVwKAfXK5CJUNlMj7/dDM8xtP7CE/iwt3NJLVa7dyiZr3nqRpB7UpdTZWPqi6YTw D/EyUBfW5qk9wQ8KsnuB9JG4Lnty3386gVL+Hcncd/+MHGZ/d1WHQRf3Pr7WgayX7iJT Yp9uiFUmln2OXenx6OY/cVsA//nYSjFd4xO+QpL5oJrM0BkbFhow28LyE05kEuYzEHBS CXBg== 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=fU2c4c7iM/48MX+o4q+fyiFqE7snGU7LBCYm26MndCc=; b=WK/Hd0hFCUUwEEekpmxUoaLdj/fDVv2uS7h4MyRMdklVbHk122AnTVFlUg3etbytps EtCTuuJvwskOH8Nzv1Y3qqdNYhNUHiyagoAF19t3a8/k0t5KfzjwGW7TsB/STLqAzYdi 4Qh+aseBzbWX/WVh6ncVTOdBnGSenH7gJ1Yi/s9ia1qjwlyCPZjsgSI/6ixhBqMi04DH I+dTBRzG3uLuFzKmaVgAxZaBeJtJAK5tK+72JRAauselFwb7GuG07q4WZgIwCZrZiE+3 Fss+fIiFigrAypkKe3QrvguqcsypdPcWzm7Q5q8SyAYelMVtSO/PFT6YfqQjCnlMPk4E hpKQ== X-Gm-Message-State: AOAM530u7cPjOPpS28C/cpQoTYD9s1nKXi79czNIayXzwRnSrA8ECnn9 7CQWeoTb2n6T+bzJQyHL7sqTLl+8GuwCrQ== X-Google-Smtp-Source: ABdhPJyYsA0PSOzhF89XtPAjVJ2jIzmJ9Z9e/T7P1idei/kKH+fzHcJrh8UVEjEnrDtOL1JODZJwfA== X-Received: by 2002:a63:f961:: with SMTP id q33mr2832800pgk.95.1601488139510; Wed, 30 Sep 2020 10:48:59 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id l13sm2993974pgq.33.2020.09.30.10.48.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2020 10:48:59 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v2 net-next 2/2] ionic: prevent early watchdog check Date: Wed, 30 Sep 2020 10:48:28 -0700 Message-Id: <20200930174828.39657-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930174828.39657-1-snelson@pensando.io> References: <20200930174828.39657-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 16b6b65e8319..545c99b15df8 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, false); }