From owner-svn-src-stable@freebsd.org Fri Jan 6 07:19:05 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39D1ECA183A; Fri, 6 Jan 2017 07:19:05 +0000 (UTC) (envelope-from arybchik@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 mx1.freebsd.org (Postfix) with ESMTPS id 144B6154E; Fri, 6 Jan 2017 07:19:05 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v067J4ms038420; Fri, 6 Jan 2017 07:19:04 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v067J3sH038413; Fri, 6 Jan 2017 07:19:03 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201701060719.v067J3sH038413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 6 Jan 2017 07:19:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r311486 - stable/11/sys/dev/sfxge/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jan 2017 07:19:05 -0000 Author: arybchik Date: Fri Jan 6 07:19:03 2017 New Revision: 311486 URL: https://svnweb.freebsd.org/changeset/base/311486 Log: MFC r310813 sfxge(4): add per-command timeout reporting to the common code In newer firmware that supports multithreaded MCDI processing, longer running commands may be run ina background thread. Add support for drivers to query the appropriate timeout for each MCDI request. Submitted by: Andy Moreton Sponsored by: Solarflare Communications, Inc. Modified: stable/11/sys/dev/sfxge/common/ef10_impl.h stable/11/sys/dev/sfxge/common/ef10_mcdi.c stable/11/sys/dev/sfxge/common/efx.h stable/11/sys/dev/sfxge/common/efx_impl.h stable/11/sys/dev/sfxge/common/efx_mcdi.c stable/11/sys/dev/sfxge/common/siena_impl.h stable/11/sys/dev/sfxge/common/siena_mcdi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sfxge/common/ef10_impl.h ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_impl.h Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/ef10_impl.h Fri Jan 6 07:19:03 2017 (r311486) @@ -330,6 +330,12 @@ ef10_mcdi_feature_supported( __in efx_mcdi_feature_id_t id, __out boolean_t *supportedp); +extern void +ef10_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *timeoutp); + #endif /* EFSYS_OPT_MCDI */ /* NVRAM */ Modified: stable/11/sys/dev/sfxge/common/ef10_mcdi.c ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_mcdi.c Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/ef10_mcdi.c Fri Jan 6 07:19:03 2017 (r311486) @@ -108,6 +108,46 @@ ef10_mcdi_fini( emip->emi_new_epoch = B_FALSE; } +/* + * In older firmware all commands are processed in a single thread, so a long + * running command for one PCIe function can block processing for another + * function (see bug 61269). + * + * In newer firmware that supports multithreaded MCDI processing, we can extend + * the timeout for long-running requests which we know firmware may choose to + * process in a background thread. + */ +#define EF10_MCDI_CMD_TIMEOUT_US (10 * 1000 * 1000) +#define EF10_MCDI_CMD_LONG_TIMEOUT_US (60 * 1000 * 1000) + + void +ef10_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *timeoutp) +{ + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); + + switch (emrp->emr_cmd) { + case MC_CMD_POLL_BIST: + case MC_CMD_NVRAM_ERASE: + case MC_CMD_LICENSING_V3: + case MC_CMD_NVRAM_UPDATE_FINISH: + if (encp->enc_fw_verified_nvram_update_required != B_FALSE) { + /* + * Potentially longer running commands, which firmware + * may choose to process in a background thread. + */ + *timeoutp = EF10_MCDI_CMD_LONG_TIMEOUT_US; + break; + } + /* FALLTHRU */ + default: + *timeoutp = EF10_MCDI_CMD_TIMEOUT_US; + break; + } +} + void ef10_mcdi_send_request( __in efx_nic_t *enp, Modified: stable/11/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/11/sys/dev/sfxge/common/efx.h Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/efx.h Fri Jan 6 07:19:03 2017 (r311486) @@ -243,6 +243,12 @@ efx_mcdi_new_epoch( __in efx_nic_t *enp); extern void +efx_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *usec_timeoutp); + +extern void efx_mcdi_request_start( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp, Modified: stable/11/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/11/sys/dev/sfxge/common/efx_impl.h Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/efx_impl.h Fri Jan 6 07:19:03 2017 (r311486) @@ -428,7 +428,10 @@ typedef struct efx_mcdi_ops_s { boolean_t (*emco_poll_response)(efx_nic_t *); void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t); void (*emco_fini)(efx_nic_t *); - efx_rc_t (*emco_feature_supported)(efx_nic_t *, efx_mcdi_feature_id_t, boolean_t *); + efx_rc_t (*emco_feature_supported)(efx_nic_t *, + efx_mcdi_feature_id_t, boolean_t *); + void (*emco_get_timeout)(efx_nic_t *, efx_mcdi_req_t *, + uint32_t *); } efx_mcdi_ops_t; typedef struct efx_mcdi_s { Modified: stable/11/sys/dev/sfxge/common/efx_mcdi.c ============================================================================== --- stable/11/sys/dev/sfxge/common/efx_mcdi.c Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/efx_mcdi.c Fri Jan 6 07:19:03 2017 (r311486) @@ -67,6 +67,7 @@ static const efx_mcdi_ops_t __efx_mcdi_s siena_mcdi_read_response, /* emco_read_response */ siena_mcdi_fini, /* emco_fini */ siena_mcdi_feature_supported, /* emco_feature_supported */ + siena_mcdi_get_timeout, /* emco_get_timeout */ }; #endif /* EFSYS_OPT_SIENA */ @@ -81,6 +82,7 @@ static const efx_mcdi_ops_t __efx_mcdi_e ef10_mcdi_read_response, /* emco_read_response */ ef10_mcdi_fini, /* emco_fini */ ef10_mcdi_feature_supported, /* emco_feature_supported */ + ef10_mcdi_get_timeout, /* emco_get_timeout */ }; #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ @@ -605,6 +607,17 @@ efx_mcdi_request_abort( return (aborted); } + void +efx_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *timeoutp) +{ + const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop; + + emcop->emco_get_timeout(enp, emrp, timeoutp); +} + __checkReturn efx_rc_t efx_mcdi_request_errcode( __in unsigned int err) Modified: stable/11/sys/dev/sfxge/common/siena_impl.h ============================================================================== --- stable/11/sys/dev/sfxge/common/siena_impl.h Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/siena_impl.h Fri Jan 6 07:19:03 2017 (r311486) @@ -127,6 +127,12 @@ siena_mcdi_feature_supported( __in efx_mcdi_feature_id_t id, __out boolean_t *supportedp); +extern void +siena_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *timeoutp); + #endif /* EFSYS_OPT_MCDI */ #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD Modified: stable/11/sys/dev/sfxge/common/siena_mcdi.c ============================================================================== --- stable/11/sys/dev/sfxge/common/siena_mcdi.c Fri Jan 6 07:16:05 2017 (r311485) +++ stable/11/sys/dev/sfxge/common/siena_mcdi.c Fri Jan 6 07:19:03 2017 (r311486) @@ -247,4 +247,19 @@ fail1: return (rc); } +/* Default timeout for MCDI command processing. */ +#define SIENA_MCDI_CMD_TIMEOUT_US (10 * 1000 * 1000) + + void +siena_mcdi_get_timeout( + __in efx_nic_t *enp, + __in efx_mcdi_req_t *emrp, + __out uint32_t *timeoutp) +{ + _NOTE(ARGUNUSED(enp, emrp)) + + *timeoutp = SIENA_MCDI_CMD_TIMEOUT_US; +} + + #endif /* EFSYS_OPT_SIENA && EFSYS_OPT_MCDI */