Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp889338yba; Thu, 18 Apr 2019 11:15:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxhz+SWvNej8bpE2tIFYMJqpM7C7C1H0hjBbL4xmXKfFw2MtAKtpoi4lsB9febQ0fTygsr X-Received: by 2002:a63:7e10:: with SMTP id z16mr83350475pgc.40.1555611339578; Thu, 18 Apr 2019 11:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611339; cv=none; d=google.com; s=arc-20160816; b=zJXu5cKwTXdy6RPJbXmYP+oYG/uIikymjoMDXlYaOk9Q0tNnlBLSH96GMd1QcFX0Fs 9oBJVMMbaVglFKGkrrItdKccVpBXntaSrpg3eDSXMOu6Ia41JqWKHVqJo6daBA31t8vj 3Xb9EyMplUiyQ8noHln4d2OT6Ek5hRCnok7KvrC3YkWX8yUeOxfzus7HcUQoVR/LGPeM 8ZXazrSnJKhnjMz+qzYStL61+CFB+87dpq8E7BIInEyYRtFA4CCrCt6pCOKZ3JEYoaD+ cjR5IUXtBPftxUkpjKNEiFYKTXjXaySQUYCix60MhicbgAX/glJmILxYWBiWFhAFx8lU KSDQ== 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=rmK8a+mjQGsFj2NCuFSEEMuhxgbL/zMArsJRkEZAEF0=; b=0N6B3bNre/XCkW4N9m0pNfYlUYKHm5BsSZY1z2nOj6P2qw7waiSR2yV7ZEs75yhdod NuIYVrpL3V64J35gQ48hd55ZPeV2w55j4ByZ1VVJRLN7vh1EpzSEiIR3ImVE42dndjHX fnML0JKP3WPOwUvTYWKhZkuDrGcsviofmdcQdneaAAqyRqUBxzqFw+teoLCWfx6tgPMO /gR9fR7ZBkXL3H7BS4KSUjmljnYv33ySmGRm7glCkmCS7nIYiNn0UmdB8fEmWnkqorzI h2kPus4hjBf+Oubo8YSwdfd6pLMOx5CInaC+bPt1VTJ9DgbtF2ZjGGPcPKCtaXGPTAc/ U+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="k5AbhS/h"; 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 v32si418349plb.146.2019.04.18.11.15.24; Thu, 18 Apr 2019 11:15:39 -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="k5AbhS/h"; 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 S2390694AbfDRSNk (ORCPT + 99 others); Thu, 18 Apr 2019 14:13:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404074AbfDRSNd (ORCPT ); Thu, 18 Apr 2019 14:13:33 -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 DD3492186A; Thu, 18 Apr 2019 18:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611213; bh=6tgg33U8eaYsQnWBaNoIIW9pos3Z+gZPxNZeAbaTdlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5AbhS/hYzQjZsMBJvBNRWIggFDb7+YqM6PF8LRaYrij0zoxArYJ7VMJTj0e+1WCG AB+aG8NRWHKfkejX8klis+0CykoQBHFbs+cyixju75YGeA/HmRJzq6csjGg8eTTCZ9 +/W/3y5tQpWT4SVlbFD8/CfDC0WXcAbbvfb3snEk= 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 5.0 93/93] IB/hfi1: Failed to drain send queue when QP is put into error state Date: Thu, 18 Apr 2019 19:58:11 +0200 Message-Id: <20190418160446.067021267@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 @@ -833,7 +833,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);