From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 627B91B173 for ; Wed, 24 Jan 2018 16:39:14 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 17672226CC; Wed, 24 Jan 2018 10:39:14 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:39:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=kI6f8HCq70zR/RIA/ z7OVsnwGkhz+XG+S7jM47YH9+Q=; b=D+FEtrpBPTMmD95Z3TQCOdnVh+3d+ly9+ YCG5iuG6rwP7HPLLlO8nLaZHDx91SR3uW9cdFAVLpOZJIzzxAh6b7UFIViRI6l2i wFNoSlxuSzN3Ele8mP+XDEEGrgkUeBns5agvlXhk+TdwQvMKdR2mXIeWix7Nftoy yEMG4jnLJp1kcW9woNBjWdwl1Em7eAeyOALaDRkvuBSNeX9KZgRE0WK0F+BK4LiG UPjQAjp1tBAH67lgVW9SglieSdCPm7tpI6Yfp3goQwnDzgPd6yVD8++UUplKeMDf BHE9FmrPnUwxynX6M+AQP8PQh40BYhrsLb/Yoe5IAnLUWR3Fv6X8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=kI6f8HCq70zR/RIA/z7OVsnwGkhz+XG+S7jM47YH9+Q=; b=H1ScAOdQ J6IJOZKi39otjBCC4b4Bya4/s3kd+TfPktq79jtqj83VpcnCDXPI2XYGQVGm2AYz ftreRN2qu8lNIEkDAbamBX686FdIHcVGbGKN/QLmkJ6NMcx5p8mKhjZCan0AMmr5 1rM8SLSRpvrwdoVzWAOoRrkLPmoGLz00RSbvpjMa5M9+HItifunbYHlaVRoJ1QyW 8Kzl6e32CVe+TguIA5ANMWlkP1gfE7gVqYxLb44GEioPfplXAKdYEbsVN18ic1uo 523SNFTRjupFWorKkkr7EicqBWtXWAyfv1D/35FeyYqgD2cIknZIwaBszmublqLL c32f3Bfz3QOd/g== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 92C737E43A; Wed, 24 Jan 2018 10:39:11 -0500 (EST) From: Yuanhan Liu To: Andrew Rybchenko Cc: Ivan Malov , Andy Moreton , dpdk stable Date: Wed, 24 Jan 2018 23:32:22 +0800 Message-Id: <1516808026-25523-74-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/sfc: do not hold management event queue lock while MCDI' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:39:14 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 72cbe69159dc8522b13da5e6d77227d266e7cc2b Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Sun, 24 Dec 2017 10:46:32 +0000 Subject: [PATCH] net/sfc: do not hold management event queue lock while MCDI [ upstream commit f042136ee2ed1cff425dd28c69c7c5f80acc4526 ] MCDI execution may require MCDI proxy handling which involves management event queue polling. So, it is a bad idea to hold managment event queue lock when MCDI is executed. Event queue creation and destruction are MCDI operations. Fixes: 4650ed44c120 ("net/sfc: support MCDI proxy") Signed-off-by: Andrew Rybchenko Reviewed-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 22 ++++++++++++++++++++++ drivers/net/sfc/sfc_ev.c | 23 ++++++++++++++--------- drivers/net/sfc/sfc_intr.c | 5 +++-- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index b72eba0..ef980a4 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -212,7 +212,29 @@ struct sfc_adapter { unsigned int evq_count; unsigned int mgmt_evq_index; + /* + * The lock is used to serialise management event queue polling + * which can be done from different context. Also the lock + * guarantees that mgmt_evq_running is preserved while the lock + * is held. It is used to serialise polling and start/stop + * operations. + * + * Locks which may be held when the lock is acquired: + * - adapter lock, when: + * - device start/stop to change mgmt_evq_running + * - any control operations in client side MCDI proxy handling to + * poll management event queue waiting for proxy response + * - MCDI lock, when: + * - any control operations in client side MCDI proxy handling to + * poll management event queue waiting for proxy response + * + * Locks which are acquired with the lock held: + * - nic_lock, when: + * - MC event processing on management event queue polling + * (e.g. MC REBOOT or BADASSERT events) + */ rte_spinlock_t mgmt_evq_lock; + bool mgmt_evq_running; struct sfc_evq *mgmt_evq; unsigned int rxq_count; diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index b29eb2f..5fbebbf 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -565,10 +565,8 @@ void sfc_ev_mgmt_qpoll(struct sfc_adapter *sa) { if (rte_spinlock_trylock(&sa->mgmt_evq_lock)) { - struct sfc_evq *mgmt_evq = sa->mgmt_evq; - - if (mgmt_evq->init_state == SFC_EVQ_STARTED) - sfc_ev_qpoll(mgmt_evq); + if (sa->mgmt_evq_running) + sfc_ev_qpoll(sa->mgmt_evq); rte_spinlock_unlock(&sa->mgmt_evq_lock); } @@ -734,20 +732,26 @@ sfc_ev_start(struct sfc_adapter *sa) goto fail_ev_init; /* Start management EVQ used for global events */ - rte_spinlock_lock(&sa->mgmt_evq_lock); + /* + * Management event queue start polls the queue, but it cannot + * interfere with other polling contexts since mgmt_evq_running + * is false yet. + */ rc = sfc_ev_qstart(sa->mgmt_evq, sa->mgmt_evq_index); if (rc != 0) goto fail_mgmt_evq_start; + rte_spinlock_lock(&sa->mgmt_evq_lock); + sa->mgmt_evq_running = true; + rte_spinlock_unlock(&sa->mgmt_evq_lock); + if (sa->intr.lsc_intr) { rc = sfc_ev_qprime(sa->mgmt_evq); if (rc != 0) goto fail_mgmt_evq_prime; } - rte_spinlock_unlock(&sa->mgmt_evq_lock); - /* * Start management EVQ polling. If interrupts are disabled * (not used), it is required to process link status change @@ -767,7 +771,6 @@ fail_mgmt_evq_prime: sfc_ev_qstop(sa->mgmt_evq); fail_mgmt_evq_start: - rte_spinlock_unlock(&sa->mgmt_evq_lock); efx_ev_fini(sa->nic); fail_ev_init: @@ -783,9 +786,11 @@ sfc_ev_stop(struct sfc_adapter *sa) sfc_ev_mgmt_periodic_qpoll_stop(sa); rte_spinlock_lock(&sa->mgmt_evq_lock); - sfc_ev_qstop(sa->mgmt_evq); + sa->mgmt_evq_running = false; rte_spinlock_unlock(&sa->mgmt_evq_lock); + sfc_ev_qstop(sa->mgmt_evq); + efx_ev_fini(sa->nic); } diff --git a/drivers/net/sfc/sfc_intr.c b/drivers/net/sfc/sfc_intr.c index ee59cb1..de65f8c 100644 --- a/drivers/net/sfc/sfc_intr.c +++ b/drivers/net/sfc/sfc_intr.c @@ -57,8 +57,9 @@ sfc_intr_handle_mgmt_evq(struct sfc_adapter *sa) evq = sa->mgmt_evq; - if (evq->init_state != SFC_EVQ_STARTED) { - sfc_log_init(sa, "interrupt on stopped EVQ %u", evq->evq_index); + if (!sa->mgmt_evq_running) { + sfc_log_init(sa, "interrupt on not running management EVQ %u", + evq->evq_index); } else { sfc_ev_qpoll(evq); -- 2.7.4