Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp877718yba; Thu, 18 Apr 2019 11:04:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF+R81khrINqgNndKpOzUeYSU8LYwXXiMEKrSFsSvoaW/y7S9kCrMCovBcMNIkiwiP0a7z X-Received: by 2002:a17:902:e683:: with SMTP id cn3mr95917807plb.115.1555610681460; Thu, 18 Apr 2019 11:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555610681; cv=none; d=google.com; s=arc-20160816; b=Ti13Q22gaJeA2xXLYu2iz3m6hJwYI3MEtaQI+ufLAqnpWXrv97q8MD4M3ZD5smN4qi HeBABXATKXmoOr2GIyePCI5mhagQO6A/6hI4hiYTLe4wMXAyYFMEJ5Aqa4Gg2dg+k5xf SeRO5897uKAnHq8tRmlYQm0yReLqD+iCiaCIRUbADeUhn87huME7NTINNcoZfEv2JTcv dg68RbvI3tfqAYUsxyj4i3yc2MrGTFiojcQBNf2oGfttLwORTz6pWcVuc5q20gTsN28I +zHyXz1YV8WBUcg5yE/2STvhlVCkGQin7zqA7pYI3hpUengkJAk6UVmmeC/uDezYZIK8 VNEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVwDoEaGLqwD3CsqoS76JA9kWKMJPny/tvta+iLZoxI=; b=LdD6AnUHl1B8T0/uct1zJWUakWObOLkAOnSo9pBInjet2njlDdzdckCYLCG0Qj1HHV gKlbrJZfWMmshZhQR0P2FEVbeXaJRsU2yvnHqCFrf9e2zwdUe7KdW1brVkoGizRBi70T NVXzkMg7f0mna5+4fTiqlylmD0iANBk4ELmqk+CBYwbFQ2B7wz6wxfoMbkljtl7le39T zUelbZ7h9kipFi4g2QSTR1Y3VkZhkXHCVMElr8L9hOWQ+dmdO3IFdhkABZxCb1wRblfr LC8gKVc0fT+aFbNDZgOdjJU1Ul3AufF19X3Y38z9ulOgcNqP6zm8B0GFFncvz8sOhyEL M8OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AK+dOu2l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si2836750pfn.203.2019.04.18.11.04.26; Thu, 18 Apr 2019 11:04:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AK+dOu2l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390793AbfDRSCn (ORCPT + 99 others); Thu, 18 Apr 2019 14:02:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:58888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390786AbfDRSCk (ORCPT ); Thu, 18 Apr 2019 14:02:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 62058218A1; Thu, 18 Apr 2019 18:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610559; bh=4hGNxzcFmBJluvLlOhgi5yAixVmolzW5Xa0IA3Pq6i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AK+dOu2lzwqwpv6tKLj+XvyJ6O7ibPf9mpFEFGXJPw30dJnoQHJ4J4mlhgtyV6NAa /5ieovu+OcYG393r4Ns4N1vbIqwmufq3YDdR1WFYK7WC2Tug41vbFMHYN4Wmrl0i2R eryAl6vCKyHZqgaOmXkp5X3JbrDb8XDG66weAarI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , Alex Estrin , Kaike Wan , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 4.19 108/110] IB/hfi1: Failed to drain send queue when QP is put into error state Date: Thu, 18 Apr 2019 19:57:37 +0200 Message-Id: <20190418160447.737038054@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160437.484158340@linuxfoundation.org> References: <20190418160437.484158340@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kaike Wan commit 662d66466637862ef955f7f6e78a286d8cf0ebef upstream. When a QP is put into error state, all pending requests in the send work queue should be drained. The following sequence of events could lead to a failure, causing a request to hang: (1) The QP builds a packet and tries to send through SDMA engine. However, PIO engine is still busy. Consequently, this packet is put on the QP's tx list and the QP is put on the PIO waiting list. The field qp->s_flags is set with HFI1_S_WAIT_PIO_DRAIN; (2) The QP is put into error state by the user application and notify_error_qp() is called, which removes the QP from the PIO waiting list and the packet from the QP's tx list. In addition, qp->s_flags is cleared of RVT_S_ANY_WAIT_IO bits, which does not include HFI1_S_WAIT_PIO_DRAIN bit; (3) The hfi1_schdule_send() function is called to drain the QP's send queue. Subsequently, hfi1_do_send() is called. Since the flag bit HFI1_S_WAIT_PIO_DRAIN is set in qp->s_flags, hfi1_send_ok() fails. As a result, hfi1_do_send() bails out without draining any request from the send queue; (4) The PIO engine completes the sending and tries to wake up any QP on its waiting list. But the QP has been removed from the PIO waiting list and therefore is kept in sleep forever. The fix is to clear qp->s_flags of HFI1_S_ANY_WAIT_IO bits in step (2). HFI1_S_ANY_WAIT_IO includes RVT_S_ANY_WAIT_IO and HFI1_S_WAIT_PIO_DRAIN. Fixes: 2e2ba09e48b7 ("IB/rdmavt, IB/hfi1: Create device dependent s_flags") Cc: # 4.19.x+ Reviewed-by: Mike Marciniszyn Reviewed-by: Alex Estrin Signed-off-by: Kaike Wan Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/hfi1/qp.c +++ b/drivers/infiniband/hw/hfi1/qp.c @@ -784,7 +784,7 @@ void notify_error_qp(struct rvt_qp *qp) write_seqlock(lock); if (!list_empty(&priv->s_iowait.list) && !(qp->s_flags & RVT_S_BUSY)) { - qp->s_flags &= ~RVT_S_ANY_WAIT_IO; + qp->s_flags &= ~HFI1_S_ANY_WAIT_IO; list_del_init(&priv->s_iowait.list); priv->s_iowait.lock = NULL; rvt_put_qp(qp);