From owner-svn-src-all@freebsd.org Thu Oct 31 15:39:55 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C21C15D0FC; Thu, 31 Oct 2019 15:39:55 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 473qJW1jrgz4TQP; Thu, 31 Oct 2019 15:39:55 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E59C24C82; Thu, 31 Oct 2019 15:39:55 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9VFdt06053144; Thu, 31 Oct 2019 15:39:55 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9VFds1q053143; Thu, 31 Oct 2019 15:39:54 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201910311539.x9VFds1q053143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Thu, 31 Oct 2019 15:39:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354219 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 354219 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Oct 2019 15:39:55 -0000 Author: mw Date: Thu Oct 31 15:39:54 2019 New Revision: 354219 URL: https://svnweb.freebsd.org/changeset/base/354219 Log: Fix ENA keep-alive timeout due to prolonged reset When the ENA_FLAG_DEVICE_RUNNING flag is disabled, the AENQ handlers aren't executed. To fix that, the watchdog timestamp should be updated just before enabling the watchdog. Timer service was always being enabled, even if the device wasn't up before the reset. That shouldn't happen, as the timer service is being executed only for working interface. Differential Revision: https://reviews.freebsd.org/D21932 Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc. Modified: head/sys/dev/ena/ena.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Thu Oct 31 15:38:17 2019 (r354218) +++ head/sys/dev/ena/ena.c Thu Oct 31 15:39:54 2019 (r354219) @@ -2350,8 +2350,14 @@ ena_up(struct ena_adapter *adapter) if_setdrvflagbits(adapter->ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); - callout_reset_sbt(&adapter->timer_service, SBT_1S, SBT_1S, - ena_timer_service, (void *)adapter, 0); + /* Activate timer service only if the device is running. + * If this flag is not set, it means that the driver is being + * reset and timer service will be activated afterwards. + */ + if (ENA_FLAG_ISSET(ENA_FLAG_DEVICE_RUNNING, adapter)) { + callout_reset_sbt(&adapter->timer_service, SBT_1S, + SBT_1S, ena_timer_service, (void *)adapter, 0); + } ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEV_UP, adapter); @@ -4222,9 +4228,20 @@ ena_restore_device(struct ena_adapter *adapter) } } + /* Indicate that device is running again and ready to work */ ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEVICE_RUNNING, adapter); - callout_reset_sbt(&adapter->timer_service, SBT_1S, SBT_1S, - ena_timer_service, (void *)adapter, 0); + + if (ENA_FLAG_ISSET(ENA_FLAG_DEV_UP_BEFORE_RESET, adapter)) { + /* + * As the AENQ handlers weren't executed during reset because + * the flag ENA_FLAG_DEVICE_RUNNING was turned off, the + * timestamp must be updated again That will prevent next reset + * caused by missing keep alive. + */ + adapter->keep_alive_timestamp = getsbinuptime(); + callout_reset_sbt(&adapter->timer_service, SBT_1S, SBT_1S, + ena_timer_service, (void *)adapter, 0); + } device_printf(dev, "Device reset completed successfully, Driver info: %s\n", ena_version);